Bloomberg LP Interview Question for Financial Software Developers






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

One example of external sorting is the external mergesort algorithm.[1][2] For example, for sorting 900 megabytes of data using only 100 megabytes of RAM:

   1. Read 100 MB of the data in main memory and sort by some conventional method, like quicksort.
   2. Write the sorted data to disk.
   3. Repeat steps 1 and 2 until all of the data is in sorted 100 MB chunks, which now need to be merged into one single output file. The idea of external sorting is divide and conquer.
   4. Read the first 10 MB of each sorted chunk into input buffers in main memory and allocate the remaining 10 MB for an output buffer. (In practice, it might provide better performance to make the output buffer larger and the input buffers slightly smaller.)
   5. Perform a 9-way merge and store the result in the output buffer. If the output buffer is full, write it to the final sorted file. If any of the 9 input buffers gets empty, fill it with the next 10 MB of its associated 100 MB sorted chunk until no more data from the chunk is available.

- Synonymous November 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

wiki rocks!!!

- prasad_usc March 05, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Right, and use radix sort as the "conventional method".

- igorfact July 11, 2014 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

As phone numbers are unique, we can use bitmap for representing them.

Assuming a phone number is of 10 digits, 10^10 numbers are possible (in fact many of these are invalid phone numbers. But, for simplicity, lets consider them too.)

So, we need, 10^10 bits to represent them. It's around 1 GB.

In first pass, we can set the corresponding bit to 1. And then in the second pass, read the array of bits and write them back to the file.

- Hari Prasad Perabattula October 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think you are right. External sorting is a good choice.

- Kevin February 06, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

10^10 is 10 GB so to represent them in a bitmap you would need a 10^10 bits but we have 100 mb that is 8.38*10^8 number of bits so this solution is not viable.

- deric February 09, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

external sort

- cac October 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Correct

- Ajay October 05, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

@cac.
Can you explain external sort more..

- Akshat October 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

External sort.
Also modified merge sort should work.

- vincent March 11, 2011 | Flag Reply


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