Doggy Sort

A large group of dogs have their collars removed before they enter a dog facility. Except for their sizes, the collars are indistinguishable. When they exit the facility they will all need their collars back. Your task is to assign every dog to their corresponding collar. The catch is that you are not able to compare collar to collar or dog to dog. You can only compare a dog to a collar and see if it is too small, too big or if it fits. You want to minimize the comparisons you make. The best way of solving this problem requires a modification of one of the following sorting algorithms. Which one is it?

Bubble Sort Merge Sort Heap Sort Radix Sort Quick Sort Counting Sort Insertion Sort

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Hasmik Garyaka
Sep 16, 2017

In quicksort we use a pivot. Any collar can be used as a pivot, if we compare all dogs with it.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...