Yahoo Interview Question for Software Engineer / Developers






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

Recursion will use the internal stack space .. you can do following::

First traverse the link list and reverse it 
then traverse it and print it 
 
If there is any constraint that list should be as it is then reverse it again

- Aditya October 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

good one!!

- Anonymous December 12, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

While reversing, arent you usinga temporary variable which is again extra space?

- Prashant July 11, 2011 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

@Prashant : Are you an idiot? Do you even know what extra space means?

- wtF August 09, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Yo

- Anonymous October 20, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

This can be done via recursion.

function printLinkedLits(Node head)
{
while(head->next!null)
printLinkedList(head->next);

printf(head);
}

- Ajay September 28, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I'd rather put if instead of while..

- Igor S. October 05, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

As Igor pointed out, putting 'while' is wrong. It should be 'if'

- mkt April 17, 2012 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

recursion!!!...are you not using function's internal stack as extra space at each level of recursion to store the node???

- Anonymous October 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

void reverse(node *head)
{
if(head==NULL)
return;
else
{
reverse(head->next);
printf("%d ",head->data);
return;
}
}

- Ashwini Karappa August 12, 2012 | 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