Interview Question: Sorting Data

Sample Question #197 (case question on algorithms)

Even though you don’t have any programming background and don’t know any computer language, I want to give you a question to see how you think logically. Don’t worry about getting the "right" answer. I just want to see how you work through a problem. Okay?

When you are given a large series of data, say, the market capitalization of every stock in the world expressed in dollar terms, how do you rank the observations using a computer? In other words, how do you sort the data? You can draw a flowchart if you want.

When you find the solution, please also discuss how much time you think the sorting process will take on a typical PC.

(Comment: folks who have studied algorithms should know the answer! But for those who haven’t, this is an excellent case question to test your problem-solving skills.)

Advertisements
This entry was posted in Sample Qs. Bookmark the permalink.

One Response to Interview Question: Sorting Data

  1. Brett says:

    ANSWER
     
    How do you rank a series of numbers? The most straightforward way — the "brute force" method — is to scan through the entire series and find the largest number. Then scan through the series again to find the second largest number. And so on.
     
    Of course, this is very slow, as it takes N-1 passes, where N is the number of data points, to achieve the final result. But at least it gets the work done. There’re many ways to improve upon this basic method. If you’re interested, you should read up on "quick sort," which provides very fast sorting for large data sets.
     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s