how to swap two numbers in a linked list without exchanging
the data but only the links?

Answer Posted / pavny

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 ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is stl open source?

719


What is the use of stl?

727


How is stl different from c++ standard library?

845


What are stl algorithms?

709


Name the different types of stl containers.

789






how can u do connectivity in c++ language? plz send me connectivity code in c++ ?

1995


draw a flowchart that accepts two numbers and checks if the first is divisible by the second.

2959


how to use C++?

2154


Is string part of stl?

781


How connect plc and pc through software

2032


write a program that will accept a number and print.its equivalent in words the maximum input number is 9999

2595


Describe how to safeguard a system through acquisition of an antivirus Program and systematic backup.

1733


Can we use stl in coding interviews?

1389


Who created stl?

742


Why should a c++ programmer be interested in stl?

722