Adobe Interview Question


Country: United States




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

If we have something like a1 > a2, a2 > a3, a3 > a1, we know that there is no ascneding order. So we can create a graph based on the comparisons. Create nodes for each element. and then if element x > element y, direct the graph from node y to x. Run some sort of graph algorithm like DFS with cycle detection. If we detect a cycle, we know that we can not order in ascending order.

- SK July 09, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what if there is no relationship established between any two of them. say a1>a2,a2>a3,a4>a3 . There would be no cycle but you cannot sort them as you dont know the relation between a4 and a1 or a2. You need to make sure that the graph is complete graph first and then check for a cycle. If not reject it straight away

- Anonymous July 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

a

- Anonymous July 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

a

- a July 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think this can be done by topology sort , if a1 > a2 then draw an edge from a2 to a1, using this way to setup a graph, then do a topology sort for the problem

- Scott July 09, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sort in ascending order of the first elements using quick sort. Then try to find the location of the second element in the sorted list using binary search on the right hand side of its greater number.

You may also sort the second part and then do one time merge. In any of these methods the running time will be O(n log n), because you have n/2 items that you don't know their order.

- nooreddin July 09, 2015 | 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