vishal
BAN USER- 0of 0 votes
Answersgiven a file with each line containing information <country name,state name,city name,no_of_people visited> the user want to know the no of hits of the site from the no of people visited but the request may change frequently e.g sometime it may be asked 2 find hits according to cities,sometime it may be according 2 state,might be according 2 country or around the world.design the algorithm clearly mentioning the data structure 2 b used in the algorithm
- vishal in India| Report Duplicate | Flag | PURGE
Microsoft SDE1 Algorithm
1)use a queue and enqueue 1 in it and intialize a counter as 0.
2)do this step while q is not empty and counter<n
2.a)dequeue the front element and print it.
2.b)append 0 and 1 to the popped element and enqueue it back to the queue.
finally all the element will be printed in binary in o(1)...
here is my soln... while extracting the elemnts of maxheap,use another maxheap and insert the -(element) in it finally the root will be -(min element)..
- vishal July 22, 2014