I have 1 million queries on disk to sort, my local memory/cache can store
up to 1 thousand queries, how can I perform sort?
This is a google interview question. Can someone help me find the answer?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You load 1000 queries in memory and sort them using quicksort, writing them to a file. In the end you’ll have 1000 such files.
You then go on to merging the files using, you guessed it, mergesort.
That’s how I’d do it. By no means the most optimal solution.