Cisco Systems Interview Question for Software Engineer / Developers






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

{
Node * ReverseList(Node *head)
{
Node *prev=NULL;
Node *curr=head;
while (curr)
{
curr=curr->next;
head->next=prev;
prev=head;
head=curr;
}
return prev;
}

- rayden November 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Reverse

//!Function reverses an input list
void reverseList(Node*& head){
	Node* curr = head;
	Node* nxt  = head->next;
	curr->next = NULL;
	while(true){
			head	   = nxt;
			if(head->next==NULL){
				head->next = curr;
				break;
			}
			nxt	   = nxt->next;
			head->next = curr;
			curr	   = head;
	}
}

2. Check if the current value is less for every node and insert

- chennavarri November 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Func division(...) may also include a test if denominator = 2, than whole operation will be just a shift: numerator >>= denominator;

- Anonymous November 09, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

ooops, posted in wrong topic

- Anonymous November 09, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

void Reverse(Node& head)
{
Node* curr = &head;
Node* nxt = curr->next;
Node* nenxt;

curr -> next = NULL;
do{
nenxt = nxt -> next;

nxt -> next = curr;
curr = nxt;
nxt = nenxt;
}while(curr->next!=NULL);

}

- Anonymous November 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void Reverse(Node* head)
{
Node* curr = head;
Node* nxt = curr->next;
Node* nenxt;

curr -> next = NULL;
do{
nenxt = nxt -> next;

nxt -> next = curr;
curr = nxt;
nxt = nenxt;
}while(curr->next!=NULL);

head=curr;
}

- vin.bitr November 12, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote
{{{ Void insert(Node** head, Node* newNode) { Node* curr = *head; if(*head == null || (*head)->data==newNode->data) { newNode->next = (*head); *head = newNode; } while(curr->next!=null && curr->next->data<newNode->data) curr=crr->next; newNode->next = curr->next; curr->next = newNode; } - Srividhya November 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Void insert(Node** head, Node* newNode)
{
Node* curr = *head;
if(*head == null || (*head)->data==newNode->data)
{
newNode->next = (*head);
*head = newNode;
}
while(curr->next!=null && curr->next->data<newNode->data)
curr=crr->next;
newNode->next = curr->next;
curr->next = newNode;
}

- Srividhya November 15, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Awesome answer Srividhya!

- Radhika November 15, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

very elegant.

- Anonymous August 17, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

ur answer doesnot work if u insert 6 and then 4

// Uses special case code for the head end
void SortedInsert(struct node** headRef, struct node* newNode) {
// Special case for the head end
if (*headRef == NULL || (*headRef)->data >= newNode->data) {
newNode->next = *headRef;
*headRef = newNode;
}
else {
// Locate the node before the point of insertion
struct node* current = *headRef;
while (current->next!=NULL && current->next->data<newNode->data) {
current = current->next;
}
newNode->next = current->next;
current->next = newNode;
}
}

- Anonymous December 01, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

<pre lang="" line="1" title="CodeMonkey86557" class="run-this">void RecursiveReverse(struct node** headRef) {
struct node* first;
struct node* rest;
if (*headRef == NULL) return;
first = *headRef;
rest = first->next;
if (rest == NULL) return;
RecursiveReverse(&rest);

first->next->next = first;
first->next = NULL;
*headRef = rest;
}</pre><pre title="CodeMonkey86557" input="yes">
</pre>

- Anonymous June 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public Node reverseList(Node head)
{
if(head==null)
return null;
else
{
Node temp1,temp2,temp3;
temp1=head;
temp2=head.next;
while(temp2!=null)
{
temp3=temp2.next;
temp2.next=temp1;
temp1=temp2;
temp2=temp3;
}
Head.next=null;
temp2.next=temp1;
return temp2;
// this is not be the best OOdesign.. but answerisnearly the same..since head is a instance variable in a List class, u can say Head= temp2 instead of having a return value.

- anaon-java August 17, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void Reverse(Node *header){
     if(Header == null || Header ->Next == Null)
          return;
     Node* Last = Header;
     Node* Curr = Header->Next;
     //Reverse the Header Node
     Header -> Next = null;
     while(Curr != null){
          Node* Temp = Curr -> Next;
          Curr -> Next = Last;
          Last = Curr;
          Curr = Temp;
      }
}

- Tech September 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

bool reverse(Node **head)
{
if(*head==NULL) return false;
if(*head->next==NULL) return true;
if(*head->next->next==NULL) {Node *p=*head; *head=*head->next; *head->next=p; return true;}
Node *p1,*p2,*p3;
p1=*head; p2=p1->next; p3=p2->next;
*head->next = NULL;
while(p3)
{
p2->next=p1; p1=p2; p2=p3; p3=p2->next;
}
p2->next=p1; *head = p2;
return true;
}

- biostanley October 24, 2011 | 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