how to swap two numbers in a linked list without exchanging
the data but only the links?
Answers were Sorted based on User's Feedback
Answer / sha
let q=20,r=10 and p be a node previous to q
sequence is p-q-r
temp is pointer of link list.
then
temp=p->next;
p->next=temp->next;
p->next->next=temp;
and temp next can be conected to p->next->next->next if
there is any
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / 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 |
Answer / siva
head points 20
head=head->link;
link->next;
link->head=head->next
Is This Answer Correct ? | 1 Yes | 3 No |
What are the different types of stl containers?
Difference between Structure and Class in C++?
How can you create a bulleted list, numbered list and an outline by using bullets and numbering command. Explain with the help of example.
if x<>=z then statement end what is the cyclomatic complexity
If P is the population on the first day of the year, B is the birth rate, and D is the death rate, the estimated population at the end of the year is given by the formula: The population growth rate is given by the formula: B – D Write a program that prompts the user to enter the starting population, birth and death rates, and n, the number of years. The program should then calculate and print the estimated population after n years. Your program must have at least the following functions: 1. growthRate: This function takes its parameters the birth and death rates, and it returns the population growth rate. 2. estimatedPopulation: This function takes its parameters the current population, population growth rate, and n, the number of years. It returns the estimated population after n years Your program should not accept a negative birth rate, negative death rate, or a population less than 2. please answer my question ....
Is there any error below, its a code to delete all entires from a map #include <map> #include iostream.h int main() { int i =0; map <int, char> TestMap; while(i<3) { TesMap.insert(TestMap::value_type(i,Test)); i++; } typedef map<int, char> :: iterator mapIter =TestMap.begin(); if(mapIter!=TestMap.end()) { TestMap.erase(mapItrer); ++mapIter; } return 0; }
Write a program in C/C++ to implement reader- writer problem
method overloading means what?
what are you now programming Languages C+
help me i need a c++ program which takes sequesnce of characters and outputed sequence of their token taypes, work same compiler in lexical analysis phase
What is a standard template library (stl)?
write a program to search and display the position of an element in a single-dimentional array using function.