1 / 1

Radix Sort Using Queues (Taken from Udi Manber’s Algorithms textbook, section 6.4.1)

Radix Sort Using Queues (Taken from Udi Manber’s Algorithms textbook, section 6.4.1) Algorithm Straight_Radix ( X, n, k ) ; Input: X ( an array of integers, each with k digits, in the range 1 to n) Output: X (the array in sorted order) begin

nani
Download Presentation

Radix Sort Using Queues (Taken from Udi Manber’s Algorithms textbook, section 6.4.1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Radix Sort Using Queues (Taken from Udi Manber’s Algorithms textbook, section 6.4.1) Algorithm Straight_Radix ( X, n, k ) ; Input: X ( an array of integers, each with k digits, in the range 1 to n) Output: X (the array in sorted order) begin We assume that all elements are initially in a global queue GQ ; { We use GQ for simplicity; it can be implemented through X } for i := 1 to d do {d is the number of possible digit values; d = 10 in case of decimal numbers} initialize queue Q[i] to be empty ; for i := k downto 1 do while GQ is not empty do dequeue x from GQ ; d := the ith digit of x; insert x into Q[d]; for t := 1 to d do insert Q[t] into GQ; for i := 1 to n do dequeue X[i] from GQ end

More Related