ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  STL
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
how to swap two numbers in a linked list without exchanging 
the data but only the links?
 Question Submitted By :: Bharghavi
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how to swap two numbers in a linked list without exchanging the data but only the links?
Answer
# 1
Suppose List contains 3 no. 10, 20, 30
try to exchange 10 and 20.
head points to 10.

temp = head;
head = head -> next;
temp -> next = head - next;
head -> next = temp;

I think it works..
 
Is This Answer Correct ?    0 Yes 0 No
Pavny
 
  Re: how to swap two numbers in a linked list without exchanging the data but only the links?
Answer
# 2
head points 20
head=head->link;
link->next;
link->head=head->next
 
Is This Answer Correct ?    0 Yes 0 No
Siva
 
 
 

 
 
 
Other STL Interview Questions
 
  Question Asked @ Answers
 
what's the difference between function overloading and function overiding?  2
Assume I have a linked list contains all of the alphabets from "A" to "Z?" I want to find the letter "Q" in the list, how does you perform the search to find the "Q?"  2
How Find, Replace and Go To commands ca be used to substitute one character string for another? Explain with the heIp of an example.  1
What is the STL? HP2
What is the disadvantage of templates ? Symphony2
what is use of for loop? Wipro7
what is a template? BITS2
Give the output of the following program main() {char *p='a'; int *i=100/*p; } what will be the value of *i= 1 Sun-Microsystems3
Define the terms: field, record, table and database  1
how to swap two numbers in a linked list without exchanging the data but only the links? Wipro2
c# support late binding or early binding.  3
if 4-5 year old brother is standing on d roof with me and watching d moon, suddenly moon coverd by cloud then how will i explain d hiding of moon to my brother. MBT6
how to overload << and >> operator in c++ Wipro3
Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fork(); if(!ret) printf("sun"); else printf("solaris"); Sun-Microsystems4
Find the error in the following program struct point {struct point *next; int data; } x; main() {int...data; } x; main() {int i; for(x=p;x!=0;) x=x->next,x++; freelist(x); } freelist(x) {free(x); return } Sun-Microsystems1
what is an algorithm in terms of STL? Wipro1
Explain how to insert a hyperlink in to an Excel worksheet and save a Word document as a Web page.  1
write a piece of c++ code which allocate memory to the 50 object of type CObj  2
Waht is inheritance  4
what's the difference between abstract class and concreate class? what's the meaning of standard template library(STL)?  3
 
For more STL Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com