Princeton Algorithms: Part 1 [week 2:Elementary Sorts]

来源:互联网 发布:如何做好淘宝店推广 编辑:程序博客网 时间:2024/05/17 01:36

Exercises


Explanation:
The correct answer is: 17 34 50 51 81 94 98 80 78 96

Here is the array after each exchange:

94 98 96 50 81 17 34 80 78 51
1: 17 98 96 50 81 94 34 80 78 51
2: 17 34 96 50 81 94 98 80 78 51
3: 17 34 50 96 81 94 98 80 78 51
4: 17 34 50 51 81 94 98 80 78 96




Explanation:
The correct answer is: 0 3 2 1 2 3 1 4

0: Original input
3: Shellsort after 4-sorting
2: Selection sort after 8 iterations
1: Insertion sort after 8 iterations
2: Selection sort after 7 iterations
3: Shellsort after 13-sorting
1: Insertion sort after 5 iterations
4: Sorted



Job Interview Questions







0 0