Add cpp codes for the chapter

computational complexity, sorting, searching.
This commit is contained in:
Yudong Jin
2022-11-27 04:20:30 +08:00
parent 431a0f6caf
commit 19a4ccd86a
32 changed files with 1362 additions and 52 deletions

View File

@ -47,10 +47,10 @@ public class bubble_sort {
public static void main(String[] args) {
int[] nums = { 4, 1, 3, 1, 5, 2 };
bubbleSort(nums);
System.out.println("排序后数组 nums = " + Arrays.toString(nums));
System.out.println("冒泡排序完成后 nums = " + Arrays.toString(nums));
int[] nums1 = { 4, 1, 3, 1, 5, 2 };
bubbleSortWithFlag(nums1);
System.out.println("排序后数组 nums1 = " + Arrays.toString(nums));
System.out.println("冒泡排序完成后 nums1 = " + Arrays.toString(nums));
}
}

View File

@ -26,6 +26,6 @@ public class insertion_sort {
public static void main(String[] args) {
int[] nums = { 4, 1, 3, 1, 5, 2 };
insertionSort(nums);
System.out.println("排序后数组 nums = " + Arrays.toString(nums));
System.out.println("插入排序完成后 nums = " + Arrays.toString(nums));
}
}

View File

@ -51,7 +51,7 @@ public class merge_sort {
public static void main(String[] args) {
/* 归并排序 */
int[] nums = { 2, 4, 1, 0, 3, 5 };
int[] nums = { 7, 3, 2, 6, 0, 1, 5, 4 };
mergeSort(nums, 0, nums.length - 1);
System.out.println("归并排序完成后 nums = " + Arrays.toString(nums));
}