Google Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

stackoverflow . com/questions/12886036/deep-copying-a-graph-structure

- hirajhil January 26, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Not sure about the question. But i will answer some of the specific points in the question.
How to differentiate between different nodes with same data and encountering the same node? A: use the address of the node to differentiate
also how do you make sure you don't run into loops for the exact node? A: as its done in DFS.

- kr.neerav January 19, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I believe we can do a BFS and use a hashtable to keep track which node has been processed to avoid running into a loop. But it sounds like a solution to directed graph. What if it's a undirected graph? Is there any difference?

- Guy January 19, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Actually this problem can be formed as serialization problem. We need some function to check object identity. We can use Java identityHashCode and put all node of graph to map. Where key if this identityHash.

- glebstepanov1992 January 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

BFS - for accessing all vertex and edges and handling cycles with love.

for every vertex you take out from queue, clone it. store in hashmap <orinigal,clone>.

if adjacent is found for first time,
clone vertex store in hashmap <orinigal,clone> and add edge in clone adjacency.
else
take out the visited node for hashmap, add edge, put it back.

vertex and edges need to be objects. you can have 2 vertex with same value.

- AlgoAlgae April 24, 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