4. The following figure shows an iterative-Mergsort algorithm. a₁. az, a, is the set of numbers needed to be sorted. Ini

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

4. The following figure shows an iterative-Mergsort algorithm. a₁. az, a, is the set of numbers needed to be sorted. Ini

Post by answerhappygod »

4 The Following Figure Shows An Iterative Mergsort Algorithm A Az A Is The Set Of Numbers Needed To Be Sorted Ini 1
4 The Following Figure Shows An Iterative Mergsort Algorithm A Az A Is The Set Of Numbers Needed To Be Sorted Ini 1 (58.91 KiB) Viewed 30 times
4. The following figure shows an iterative-Mergsort algorithm. a₁. az, a, is the set of numbers needed to be sorted. Initially, each element of a, a, a, is considered as an array separately and each array is added to the queue Q. Then, removing two arrays from the front of the queue, merging them, and putting the result array at the end of the queue. The process is iteratively done until there is only one array in the queue. When merging two arrays (merge), they are done recursively and the first numbers of all arrays are compared and the smaller one is removed every time. The operation inject adds an element to the end of the queue while eject removes and returns the element at the front of the queue. Let the unsorted array contains 30, 78, 16, 47, 20, 15, 6, 12, 82. Please show states of the Q at each step, in other words, show the changes of Q (12¹). function iterative-mergesort (a[1...n]) Input: elements a1,02,....an to be sorted Q=[] (empty queue) for i=1 to n: inject(Q.[a]) while Q> 1: inject(Q, merge(eject(Q), eject(Q))) return eject(Q)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply