in Algorithms
318 views
2 votes
2 votes

A delivery boy at an online e-commerce company is charged with the task of rearranging a number of large crates in order of the time they are to be shipped out. Thus, the cost of compares is very low (just look at the labels of the items ) relative to the cost of exchanges (move the crates). The warehouse is nearly full: there is extra space sufficient to hold any one of the crates, but not two. Which sorting method should the boy use?

  1. heap sort
  2. quick sort
  3. selection sort
  4. randomized quick sort
     
in Algorithms
by
318 views

1 Answer

4 votes
4 votes
Best answer
"The cost of compares is very low (just look at the labels of the items ) relative to the cost of exchanges (move the crates)."
So we will use selection sort because no of exchange (which is costelier in this case) in selection sort is O(n) only.
selected by

4 Comments

Why we need to move O(n) elements at each iteration in selection sort?
0
0
Sorry Arjun. My bad. Got it
1
1
messed with insertion sort :D
0
0
Answer:

Related questions