Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3333 Data Structures Sorting Exercises

Similar presentations


Presentation on theme: "CSCI 3333 Data Structures Sorting Exercises"— Presentation transcript:

1 CSCI 3333 Data Structures Sorting Exercises
by Dr. Bun Yue Professor of Computer Science

2 General Sorting Algorithm
Linda claims to have an sorting algorithm to sort an array S into a sorted array T. Give an O(n) algorithm isSorted to check whether T is sorted. Explain why isSorted is not sufficient to prove that a particular output T is a sorting of S. Describe what additional information Linda’s algorithm could output so that her algorithm’s correctness could be established on any given S and T in O(n) time. With the additional information from (3), construct an O(n) algorithm to check whether T is a sorting of S.

3 Shell Sort Shown the evolution of Shell Sort using a gap sequence of (5,3,1) with the array {29, 11, 18, 50, 20, 33, 13, 80, 79, 61, 11, 54, 77, 68, 22, 60, 56}. Show each recursive call and the action involved.

4 QuickSort Use the C++ implementation in the lecture:

5 QuickSort

6 QuickSort Show the evolution of sorting the array [10, 7, 3, 22, 90, 33, 21, 4, 90, 68, 50] by showing each recursive calls and their actions.

7 Questions and Comments?


Download ppt "CSCI 3333 Data Structures Sorting Exercises"

Similar presentations


Ads by Google