VMWare Inc Interview Question for Software Engineer / Developers






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

Hi can u plz send that code

- Amit February 28, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

next reply

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

I finaly figured out three solutions to this:
1. if you are allowed to use only one temp pointer
keep swaping elements i.e. 1 and 2 , then 2 and 3 , then 3 and 4...sna so on...till 1st elemet reaches nth position.
againuse the same funda for swap but this time swap only n-1 times.
This method is little slower.

2. Conventional way.
static void Reverse(struct node** headRef) {
struct node* result = NULL;
struct node* current = *headRef;
struct node* next;
while (current != NULL) {
next = current->next; // tricky: note the next node
current->next = result; // move the node onto the result
result = current;
current = next;
}
*headRef = result;
}
3. Use Stacks or recursive functions.
you can use recursive rutines here..same as stack as recursive functions internally uses stacks
void RecursiveReverse(struct node** headRef) {
struct node* first;
struct node* rest;
if (*headRef == NULL) return; // empty list base case
first = *headRef; // suppose first = {1, 2, 3}
rest = first->next; // rest = {2, 3}
if (rest == NULL) return; // empty rest base case
RecursiveReverse(&rest); // Recursively reverse the smaller {2, 3} case
// after: rest = {3, 2}
first->next->next = first; // put the first elem on the end of the list
first->next = NULL; // (tricky step -- make a drawing)
*headRef = rest; // fix the head pointer
}

- Vishal Goswami March 04, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void reverse()
{
struct node* temp = p;
struct node *q, *r;
q = temp->next;
temp->next = NULL;
while(q != NULL)
{
r = q->next;
q->next = temp;
temp = q;
q = r;
}
p = temp;
}

- mukul March 26, 2007 | 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