eski hw sol.

# eski hw sol. - Trace the following sorting algorithm for...

This preview shows pages 1–3. Sign up to view the full content.

Trace the following sorting algorithm for sorting the array 7 1 9 2 3 5 into ascending order. Use the array implementation as described in the textbook/lectures. Insertion sort 7 1 9 2 3 5 1 7 9 2 3 5 1 7 9 2 3 5 1 2 7 9 3 5 1 2 3 7 9 5 1 2 3 5 7 9 Selection sort 7 1 9 2 3 5 | 7 1 5 2 3 | 9 3 1 5 2 | 7 9 3 1 2 | 5 7 9 2 1 | 3 5 7 9 1 | 2 3 5 7 9 | 1 2 3 5 7 9 Bubble sort First pass: 7 1 9 2 3 5 → 1 7 9 2 3 5 1 7 9 2 3 5 → 1 7 9 2 3 5 1 7 9 2 3 5 → 1 7 2 9 3 5 1 7 2 9 3 5 → 1 7 2 3 9 5 1 7 2 3 9 5 → 1 7 2 3 5 9 Second pass: 1 7 2 3 5 | 9 → 1 7 2 3 5 | 9 1 7 2 3 5 | 9 → 1 2 7 3 5 | 9 1 2 7 3 5 | 9 → 1 2 3 7 5 | 9 1 2 3 7 5 | 9 → 1 2 3 5 7 | 9 Third pass: 1 2 3 5 | 7 9 → 1 2 3 5 | 7 9 1 2 3 5 | 7 9 → 1 2 3 5 | 7 9 1 2 3 5 | 7 9 → 1 2 3 5 | 7 9 ( sorted )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Mergesort List of calls: mergesort(theArray, 0, 5) mergesort(theArray, 0, 2) mergesort(theArray, 0, 1) mergesort(theArray, 0, 0) mergesort(theArray, 1, 1) merge(theArray, 0, 0, 1) mergesort(theArray, 2, 2)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

eski hw sol. - Trace the following sorting algorithm for...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online