Hi5 student Interview Question for Students


Country: India




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

i have some doubts abt this problem

if u want that there should exists a path from

Node A to Node B i say its color a
Node B to Node C i say its color b
Node C to Node A i say its color c

if (a == red || b ==red || c ==red) then (A,B,C) is triplet...

if u look a closed walk of size 3 then i think its cannot be tree....trees not have closed path......

i think it can be a graph....

if i take it as graph

then Make all cominations of tree element out of N elements

for each combination check there exists a closed path from a to b , b to c , c to a

if closed paths exists && 1 red edge also then print that combination

plz check is it a tree or graph...i post solution once its confirmed

- Kavita June 19, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

its a tree

- praveend806 June 19, 2014 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

I share CodeWithMe 's doubts about this being a graph rather than a tree. Regarding the solution - you mention triplets like (2,3,5) as possible solutions to this problem. In this particular triplet, 2 to 3 is a direct path, but there is no direct path between 3 and 5, instead, one has to go from 3 to 4 and then 4 to 5. If this is a valid answer, then this problem becomes relatively straightforward, just take combinations of ends of a red edge with all the other vertices present and repeat this procedure for all the red edges. Am I missing something here?

- Utopia June 19, 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