Question: Describe the tournament sort using pseudocode. The tournament sort is a sorting algorithm that works by building an ordered binary tree. We represent the elements

Describe the tournament sort using pseudocode.
The tournament sort is a sorting algorithm that works by building an ordered binary tree. We represent the elements to be sorted by vertices that will become the leaves. We build up the tree one level at a time as we would construct the tree representing the winners of matches in a tournament. Working left to right, we compare pairs of consecutive elements, adding a parent vertex labeled with the larger of the two elements under comparison. We make similar comparisons between labels of vertices at each level until we reach the root of the tree that is labeled with the largest element. The tree constructed by the tournament sort of 22, 8, 14, 17, 3, 9, 27, 11 is illustrated in part (a) of the figure. Once the largest element has been determined, the leaf with this label is relabeled by ˆ’ˆž, which is defined to be less than every element. The labels of all vertices on the path from this vertex up to the root of the tree are recalculated, as shown in part (b) of the figure. This produces the second largest element. This process continues until the entire list has been sorted.
(a)
Describe the tournament sort using pseudocode.
The tournament sort is a

(b)

Describe the tournament sort using pseudocode.
The tournament sort is a

27) 27 is largest element 27 17 27 22 8 14 17 3927 11 22) 22 is second largest element 17 814 17 39

Step by Step Solution

3.46 Rating (169 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The heart of the matter is how to do the comparisons to work our way up the tree We assume a data st... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

923-M-C-M-S (2468).docx

120 KBs Word File

Students Have Also Explored These Related Statistics Questions!