随笔分类 -  算法学习

摘要:新加坡国立大学 洛杉矶大学计算机院 阅读全文
posted @ 2020-02-18 11:32 yixiu868 阅读(219) 评论(0) 推荐(0)
摘要:https://www.cnblogs.com/xiao-apple36/p/8607835.html 阅读全文
posted @ 2019-12-12 21:34 yixiu868 阅读(90) 评论(0) 推荐(0)
摘要:1 import random 2 import time 3 4 # 插入排序 5 def insertion_sort(arr, step): 6 for i in range(step, len(arr)): 7 for j in range(i, step - 1, -step): 8 if arr[j] < arr[j-step]: 9 arr[j], arr[j-step] = arr 阅读全文
posted @ 2019-11-01 17:41 yixiu868 阅读(121) 评论(0) 推荐(0)
摘要:1 import random 2 3 # 二分查找--递归实现 4 def binary_search(arr, left, right, num): 5 if left > right: 6 return -1 7 mid = (left + right) // 2 8 if arr[mid] < num: 9 left = mid + 1 10 elif arr[mid] > num: 11 阅读全文
posted @ 2019-10-30 10:43 yixiu868 阅读(139) 评论(0) 推荐(0)
只有注册用户登录后才能阅读该文。
posted @ 2019-10-29 00:08 yixiu868 阅读(1) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/noaman_wgs/article/category/6322770 阅读全文
posted @ 2019-10-25 23:04 yixiu868 阅读(68) 评论(0) 推荐(0)
摘要:1 import random 2 3 def insert_sort(nums): 4 # 排序趟数 5 for i in range(1, len(nums)): 6 current = nums[i] 7 pre_index = i - 1 8 while pre_index >= 0 and nums[pr... 阅读全文
posted @ 2019-10-25 09:31 yixiu868 阅读(155) 评论(0) 推荐(0)
摘要:1 import random 2 3 4 def quick_sort(nums, start, end): 5 if start >= end: 6 return 7 low = start 8 mid = nums[low] 9 high = end 10 while low < high: 11 while low < high and mid <= nums[high]: 12 high 阅读全文
posted @ 2019-10-24 10:06 yixiu868 阅读(106) 评论(0) 推荐(0)
摘要:1 import random 2 3 4 # 原始冒泡排序 5 def bubble_sort(nums): 6 counter = 0 7 for i in range(len(nums) - 1): # 这个循环负责设置冒泡排序的趟数 8 for j in range(len(nums) - i - 1): # 这个是每趟比较的次数,每次从0开始,底部是已有序 9 if nums[j] > 阅读全文
posted @ 2019-10-24 09:59 yixiu868 阅读(215) 评论(0) 推荐(0)
摘要:Java数据结构和算法(十一)——红黑树 详细图解红黑树 美团技术团队--红黑树深入剖析及Java实现 阅读全文
posted @ 2019-08-21 00:41 yixiu868 阅读(226) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-06-28 17:49 yixiu868 阅读(119) 评论(0) 推荐(0)
摘要:/** * 数组必须是已排序 * @param key 查找key * @param array 数组 * @return */ public static int rank(int key, int[] array) { int low = 0; int high = array.length - 1; while (low array[mid])... 阅读全文
posted @ 2019-03-04 13:07 yixiu868 阅读(100) 评论(0) 推荐(0)
摘要:1 static void sort(int[] a) 2 { 3 for (int i = 0; i < a.Length; i++) 4 { 5 for (int j = i; j < a.Length; j++) 6 { 7 if (a[i] > a[j]) 8 { 9 int temp = 阅读全文
posted @ 2017-03-15 09:50 yixiu868 阅读(153) 评论(0) 推荐(0)
摘要:1 public static void insertion_sort(int[] a){ 2 for(int i = 1; i < a.length; i++) { 3 if(a[i-1] > a[i]) { 4 int temp = a[i]; 5 int j = i; 6 while(j > 阅读全文
posted @ 2017-03-15 09:39 yixiu868 阅读(173) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2017-03-15 09:28 yixiu868 阅读(168) 评论(0) 推荐(0)
摘要:1 public class QuickSort { 2 public static void sort(int[] a, int lo, int hi) { 3 int start = lo; 4 int end = hi; 5 int key = a[lo]; 6 7 while(start < 阅读全文
posted @ 2017-03-15 00:05 yixiu868 阅读(176) 评论(0) 推荐(0)