The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 3 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Assignment 4 Full Name:____________________________________________ Please write clearly and use extra sheets of paper as needed. Scans or good quality pictures of handwritten solutions are absolutely fine. 1- Give the state of the array after each pass when the following numbers (1 to 8) are sorted using the given algorithm. 5 4 7 2 8 3 1 6 The first pass has been done for you to get you started. The last pass should have the array in sorted order. a) Selection sort 1 4 7 2 8 3 5 6 // pass 1 b) Insertion sort 4 5 7 2 8 3 1 6 // pass 1 2- We are using merge sort to sort the following numbers (1 to 16) 13 9 11 2 7 15 10 4 16 5 1 8 12 6 3 14 This diagram from Wikipedia http://en.wikipedia.org/wiki/File:Merge_sort_algorithm_diagram.svg gives a good idea of the algorithm, but it might give the wrong impression of the order the merge operations happen as the recursion progresses since it might seem the merges happen in parallel. Provide below the merges in the correct order together with the state of the array. The last merge should have the whole array sorted. The first two have been given below to get you started. 9 13 11 2 7 15 10 4 16 5 1 8 12 6 3 14 // merge 1 9 13 2 11 7 15 10 4 16 5 1 8 12 6 3 14 // merge 2 3- We are using quicksort to sort the following numbers (1 to 16) 14 9 11 2 7 15 10 4 16 5 1 8 12 6 3 13 Using as a pivot the first element of the subarray the first partition has been done below which puts element 14 in its final position. 6 9 11 2 7 13 10 4 3 5 1 8 12 14 16 15 a) Perform the next partition (the left subarray (elements 6 to 12) pivoting around the first element (6)) and show below the state of the whole array when that partition is complete. Circle the two elements that are now in their final position. One line here showing the state of the array with 2 elements circled: ____________________________________________________________ b) Given another array as below, perform the first partition around the first element. 9 11 2 7 15 10 4 16 5 14 1 8 12 6 3 13 One line here showing the state of the array with 1 element circled: ____________________________________________________________
Attachments:
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly