[algogeeks] Don't Sort

2010-12-25 Thread punnu
There are N students in a class. They got marks in a certain test. Teacher decides to give prize1 to top log(n) students and the next sqrt(n) students be given prize2. However, he has stipulated that we cannot sort the student roll list according to marks (which would take O(nlog(n)) time) but

Re: [algogeeks] Don't Sort

2010-12-25 Thread mohit ranjan
how about bucket sort ? with may be bucket size=100 //if max marks=100 Mohit On Sat, Dec 25, 2010 at 6:59 PM, punnu punnu.gino...@gmail.com wrote: There are N students in a class. They got marks in a certain test. Teacher decides to give prize1 to top log(n) students and the next sqrt(n)