Oracle Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

Adam and Eve are the only nodes in directed acyclic graph (DAG) with in-degree zero. Start from 'you' or Einstein, follow the child to parent pointers in a dfs like manner. Eventually you will find the special nodes 'Adam' and 'Eve'. Now run another dfs starting with 'Adam'/'Eve', this time following parent to child pointers. The first node for which one of it's child reports having you in it's sub-tree, and another child reports having Einstein in sub-tree, is "a" first common ancestor. This is where it gets complicated because of a lack of "first common ancestor" definition (partly because of possible weirdo relationships in the history). There could be multiple candidates in a DAG unlike trees.

- lasthope November 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

good approach, but do you really have to visit all the nodes up to Adan and Eve? I think It will be only if you fall in the worse case scenario.

What about alternately visit parents for You and Einstein until you get a visited node ?

What could be the special cases ( weirdo relationship in history) ?

- .·´¯`·.´¯`·.¸¸.·´¯`·.¸><(((º> November 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

I was thinking as if it was the "lowest" common ancestor problem, which is actually defined on trees. Since we need two parents to get a child, the graph becomes a dag, and most of what I said above is sort of like some observations, but not really a true solution :)

- lasthope November 19, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

First couple with a second child birth.

- varun sharma ( CEO of ms-amazon.blogspot.ca ) November 18, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I was thinking as if it was the "lowest" common ancestor problem, which is actually defined on trees. Since we need two parents to get a child, the graph becomes a dag, and most of what I said above is sort of like some observations, but not really a true solution :)

- lasthope November 19, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is this a Creationist model (Adam / Eve) or an Evolutionary model (First humans were descendants of apes)? :P

Either way, perhaps Iterative Deepening Search would be appropriate for this problem?
This would be done by having two independent searches (running in parallel or sequentially while alternating) marking each visited node and checking in each last level of every iteration whether there are any nodes marked, for such, you've discovered all the first common ancestors of two given nodes.

Interesting test cases would be:
- There is Inbreeding in the genealogy tree of one person.
- Two persons are actually the same one.
- Two persons have only one first common ancestor
- Two persons have multiple first common ancestors.
- One person is the first common ancestor of the other.
- There is no first common ancestor (in an Evolutionary model).

- donkey code January 22, 2014 | 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