11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

250 Chap. 7 Internal SortingInitial Input: Array A2791 1 97 17 23 84 28 72 5 67 25First pass values for Count.rtoi = 1.0 1 2 3 4 5 6 7 8 902 1 1 1 2 0 4 1 0Count array:Index positions for Array B.0 1 2 3 4 5 6 7 8 90 2 3 4 5 7 7 11 12 12End of Pass 1: Array A.91 1 72 23 84 5 25 27 97 17 67 280 1 2 3 4 5 6 7 8 9 10 11Second pass values for Count.rtoi = 10.021 2 3 4 5 6 7 8 91 4 0 001112Count array:Index positions for Array B.0 1 2 3 4 5 6 7 8 92 3 7 7 7 7 8 9 10 12End of Pass 2: Array A.1 5 17 23 25 27 28 67 72 84 91 970 1 2 3 4 5 6 7 8 9 10 11Figure 7.19 An example showing function radix applied to the input of Figure7.17. Row 1 shows the initial values within the input array. Row 2 shows thevalues for array cnt after counting the number of records for each bin. Row 3shows the index values stored in array cnt. For example, cnt[0] is 0, indic<strong>at</strong>ingno input values are in bin 0. Cnt[1] is 2, indic<strong>at</strong>ing th<strong>at</strong> array B positions 0<strong>and</strong> 1 will hold the values for bin 1. Cnt[2] is 3, indic<strong>at</strong>ing th<strong>at</strong> array B position2 will hold the (single) value for bin 2. Cnt[7] is 11, indic<strong>at</strong>ing th<strong>at</strong> array Bpositions 7 through 10 will hold the four values for bin 7. Row 4 shows the resultsof the first pass of the Radix Sort. Rows 5 through 7 show the equivalent steps forthe second pass.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!