Cisco Systems Interview Question for Software Engineer / Developers


Team: Switching Softwares
Country: United States
Interview Type: Phone Interview




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

say ptr1 points to start of linked list,

if(ptr1==null) return false;

node * ptr2;
ptr2=ptr1->next;
if(ptr1->data==number){
ptr1=ptr2;
return true;
}

while(ptr2){
if(ptr2->data==number){
ptr1->next=ptr2->next;
return true;
}
ptr1=ptr2;
ptr2=ptr2->next;
}
return false;

- sp!de? March 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Recursive version

bool DeleteNode(Linklist p,int a)
{
	static Linklist head=NULL;
	if(head==NULL)
	{
		head=p;
		if(head->data==a)
		{
			return 1;
		}
	}
	if(p==NULL) return 0;
	if(p->next==0) return 0;
	if(a!=p->next->data)
	{
		return DeleteNode(p->next,a);
	}
	else
	{
     Linklist q=p->next;
	 p->next=q->next;
	 free(q);
	 return 1;
	}
}

- Charles December 28, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

node* deleteNode (node* head, int val ) {
    node *ptr1, *ptr2 ;
    if ( head == NULL )
      return head ;
    else if ( head->data == val ) {
      head = head->next ;
      return head ;
    }
    ptr1 = head ;
    ptr2 = head->next ;
    while ( ptr2 ) {
      if ( ptr2->data == val ) {
        ptr1->next = ptr2->next ;
        return head ;
      }
      ptr1 = ptr2 ;
    }
    return head ;
  }

- Psycho May 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

no free()?

- wenlei.apply March 15, 2013 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

node* deleteNode (node* head, int val ) {
    node *ptr1, *ptr2 ;
    if ( head == NULL )
      return head ;
    else if ( head->data == val ) {
      head = head->next ;
      return head ;
    }
    ptr1 = head ;
    ptr2 = head->next ;
    while ( ptr2 ) {
      if ( ptr2->data == val ) {
        ptr1->next = ptr2->next ;
        return head ;
      }
      ptr1 = ptr2 ;
    }
    return head ;
  }

- Psycho May 07, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

wrong

- xyz July 09, 2015 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

struct SLNode {
    SLNode *next;
    int data;
};
void SL_delete_node(SLNode *head, int value)
{   
    SLNode *prev = NULL;
    
    while (head){
        if (head->data) { // found
            if (NULL == prev) { // this is the only node
                printf("The value is in head of SLL\n");
                return;            
            }
            else { // we have a previous node
                prev->next = head->next;
                //Delete the current node
                delete head;
                break;
            }
        }
        prev = head;
        head = head->next;
    }

}

- ashot madatyan May 11, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

// Function returns pointer to first node of updated list 
Node* RemoveNode(Node* pFirstNode, int nValue){	
	if(nullptr == pFirstNode){
		return pFirstNode;	
	}

	if(pFirstNode->i == nValue){
		Node* pReturn = pFirstNode->next;
		free(pFirstNode);
		return pReturn;
	}
	
	Node *pCurrent = pFirstNode;
	while((nullptr != pCurrent) && (nullptr != pCurrent->next)){		
		if(pCurrent->next->i == nValue){
			Node* pTemp = pCurrent->next;
			pCurrent->next = pCurrent->next->next;
			free(pTemp);
		}
		pCurrent = pCurrent->next;
	}

	return pFirstNode;
}

- RR March 22, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

/* Returns pointer to the deleted node.
 * Adjust head if needed.
 */
node*
del_node(node **head, int number) {
  node* c, p; #current and previous node
  for (c = *head, p = NULL; c != NULL; c = c->next, p = c)
    if (c->data == number)
      if (p != NULL)
        p->next = c->next;
      else
        *head = c->next;
      break;
  return c;
}

- david.rebatto@gmail.com March 30, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

searcAndDelete(char* input)
{
LinkedList *temp;
LinkedList *cur = list;

while (cur)
{
if (cur -> data == input)
{
cur = temp;
temp = temp -> next;
cur -> next = temp -> next;
delete temp;
return;
}
temp = cur;
cur = cur -> next;

}
cout << " Item is not in the list" << endl;
}

- shahid March 30, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void List::mQuestion2(int aValue)
{
	class Node *lTemp = mHead;

	if(lTemp == NULL)
		return;

	if(lTemp->mData == aValue)
	{
		mHead = lTemp->mNext;
		lTemp->mNext = NULL;
		//delete lTemp
		mNoOfElements--;
	}
	else
	{
		while(lTemp->mNext !=NULL && lTemp->mNext->mData != aValue)
		{
			lTemp = lTemp->mNext;
		}

		if(lTemp->mNext == NULL)
		{
			cout << "Element not found" <<endl;
			return;
		}
		
		class Node *lTemp2 = lTemp->mNext;
		lTemp->mNext = lTemp->mNext->mNext;
		lTemp2->mNext = NULL;
		//delete lTemp2;
		mNoOfElements--;
	}
}

- Vignesh May 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Cisco gives hike once in 2-3 years.

New-Joinees only get hike after 2-3 years, so take 100% hike at the time of joining .. . otherwise don't cry after joining. :)

- Simple April 25, 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