Expedia Interview Question for Software Engineer / Developers






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

void reverse(struct nodes *head)
{
	struct nodes *prev, *now, *future;
	prev = head;
	now = prev->next;
	while(now)
	{
		future = now->next;
		now->next = prev;
		prev = now;
		now = future;
	}
	head->next = NULL;
	head = prev;
	display_list(head);
}

- gauravk.18 February 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The lists is just the items linked for one. Directions does not matter!

So easy: found the items with items->next = NULL to be at end of such lists. Then this are the beginnings of the reverse list!

^_^

- Trooper April 12, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For a single list, it can be solved by using three pointers in O(n).

- eelshcn April 13, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Singly linked list...

Item* reverseList(Item* firstItem)
{
Item* previous = NULL;
Item* current = firstItem;
Item* next = current->getNext();

do
{
current->setNext(previous);
previous = current;
current = next;
next = current->getNext();
} while (next != NULL)

return current;
}

- Anonymous May 23, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void displayReversedLinkedList(Link currNode)
{
Link pCurrent = currNode;

if (pCurrent.pNext != null)
{
displayReversedLinkedList(pCurrent.pNext);
}
pCurrent.displayLink();
}

public class Link
{
public int iData; //data item
public double dData; //data item
public Link pNext; //ptr to next link in list

//-------------------------------------------------------------
public Link(int id, double dd)
{
iData = id;
dData = dd;
pNext = null;
}

//-------------------------------------------------------------
public void displayLink()
{
Console.WriteLine("iData = " + dData);
}
//-------------------------------------------------------------
}

- zhan October 13, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

struct node* ReverseList(struct node** head)
{
struct node* curr= *head;
struct node* next;
struct node* newList=NULL;

while(curr != 0)
{
next= curr->next;
curr->next= newList;
newList = curr;
curr = next;
}
*head=newList;

return *head;
}

- S May 20, 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