共 25 篇文章 |
|
# 载入数据data = np.genfromtxt(''''''''data.csv'''''''', delimiter='''''''','''''''')x_data = data[:,0]y_data = data[:,1]plt.scatter(x_data,y_data)# 重构的数据x_data = np.array(reconMat)[:,0]... 阅7 转0 评0 公众公开 23-03-20 09:10 |
这些是 Python 的所有算法。Python 是一种很棒的编程语言,几乎可以构建任何东西,那么如果有一种方法可以查看可以用 Python 实现的所有算法呢?这个 GitHub 项目实际上以展示“所有用 Python 实现的算法”而让很多人得知,如果你想查看这个项目,请查看下面的链接:这些文件夹中的每一个都包含一个 Python 文件,该文件将包含与该文件夹名称关... 阅1 转0 评0 公众公开 23-03-18 11:29 |
然后使用任何排序算法或通过递归调用桶排序算法对每个桶中的元素进行排序。桶排序算法的最坏情况复杂度为 O(n2)。def shellSort(data, length): gap = length//2 while gap >0: for iIndex in range(gap, length): temp = data[iIndex] jIndex = iIndex while jIndex >= gap and data[jIndex - gap] >temp: data[jIndex] = data[jInde... 阅8 转0 评0 公众公开 23-01-03 22:49 |
阅6 转1 评0 公众公开 22-12-06 10:09 |
阅1 转0 评0 公众公开 22-12-01 14:52 |
Python数据结构与算法-二叉树的遍历二叉树的遍历。先序遍历 在先序遍历中,我们先访问根节点,然后递归使用先序遍历访问左子树,再递归使用先序遍历访问右子树根节点->左子树->右子树def preorder(self, root): '''''''''''''''''''''''... 阅2 转0 评0 公众公开 22-11-28 20:39 |
class Decision_Node: # define a decision node def __init__(self, index, value, left, right): self.index, self.value = index, value self.left, self.right = left, rightclass Leaf: # define a leaf node def __init__(self, y): self.counts = dict(zip(*np.unique(y, return_counts = True))) self.prediction = max(self.counts.ke... 阅10 转0 评0 公众公开 22-11-26 17:06 |
首先在未排序序列中找到最小(大)元素,存放到排序序列的起始位置,然后,再从剩余未排序元素中继续寻找最小(大)元素,然后放到已排序序列的末尾。 阅2 转0 评0 公众公开 22-11-20 07:32 |
Insertion-sort-example.gifdef insert_sort(alist): # 从第二个位置,即下标为1的元素开始向前插入 for i in range(1, len(alist)): # 从第i个元素开始向前比较,如果小于前一个元素,交换位置 for j in range(i, 0, -1): if alist[j] <alist[j-1]: alist[j], alist[j-1] = alist[j-1], alist[j]alist = [54,26,93,17,77,31,44,55,20]inser... 阅5 转0 评0 公众公开 22-11-19 21:41 |
def remove(self,item): ''''''''''''''''''''''''删除节点'''''''''''''''''''''''' cur = self._head pre = None while cur != None: ... 阅1 转0 评0 公众公开 22-11-17 21:48 |