NonComparisionSorts

N 1 0 ri 1 ri 1 1 1 bucket sort using b0n

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: o-code Assume element Assume n-element array r[0..n – 1], 0 ≤ r[i] 1], r[i] 1, 1] < 1, bucket sort using B[0..n – 1] of linked linked lists (buckets) for for i ← 0 to n – 1 to insert r[i] into list B[n*r[i]] for for i ← 0 to n – 1 to sort sort list B[i] with insertion sort Concatenate Concatenate the lists B[0], B[1], … , B[n – 1] together in order 5 Bucket Bucket Sort: example Input Input array: 3 1 6 3 2 Generate Generate five Place data buckets: into buckets: 0-1 1 2-3 3 3 5 4 5 5 6-7 4 2 4-5 5 6 7-8 6 Bucket Bucket Sort: example Sorting data with in buckets results: 0-1 1 2-3 2 3 3 4-5 4 5 5 6-7 6 7-8 Sorted Sorted array: 1 Link Link data from buckets… 2 3 3 4 5 5 6 7 Bucket So...
View Full Document

This document was uploaded on 03/06/2014 for the course ECE 368 at Purdue.

Ask a homework question - tutors are online