Adobe Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
0
of 0 vote

External sorting with merge sort.

- S September 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

lets suppose memory has M blocks and you want to sort B blocks. Then you can pull M blocks into memory and sort them and write output to disk. This will take B/M steps.

Now pick the first block of each of (B/M) blocks written previously and merge them and write them to disk. If B/M > M, then you will need to repeat the process to till all the blocks are sorted. Now merge the sorted blocks and repeat.

Visualize like a tree structure.

- Messi September 20, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

but while merging wont we require >M blocks of memory?

- Rashi September 29, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

wont merging two blocks require >M blocks of memory..?

- Rashi September 29, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

No you wont require M blocks of memory for merging. All you have to do is read from say 2 blocks like a stream and write the output to the disk immediately. You continue this until there is no data left in blocks to read further.

- Ravi October 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

suppose its a 900 mb file and our ram is 100 mb... i.e. 9 blocks
1. bring each block in ram and sort (O(nlogn)) and then put back
2. now we have 9 consecutively sorted blocks.
3. maintain an input buffer of 90 mb and output of 10mb
4. get 10 mb each from start of each block i.e. toal 90mb in input buffer.
5. perform 9-way merge into 10mb output buffer.
6. whenever o/p buffer is filled, write it to disk and erase from ram
7. whenver either of 9 chunks are all read, copy futer 10 mb from the corresponding 100mb block until it exhausts the 100mb
8. do this until all chunks are processed.

source:wiki

- fabregas February 11, 2011 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More