Can we remove an element in a single linked list without
traversing?
Lets suppose the link list is like this
1 2 3 4 5 6

We need to remove 4 from this list (without traversing from
beginning) and the final link list shud be 1 2 3 5 6

only thing we know is the pointer to element "4". How can
we remove "4" and link "3" to "5"?

Answers were Sorted based on User's Feedback



Can we remove an element in a single linked list without traversing? Lets suppose the link list i..

Answer / mpoleg

1) copy content of element 5 to element 4
2) link element 4(which already contains number 5) to
element 6
3) delete element 5

Is This Answer Correct ?    10 Yes 1 No

Can we remove an element in a single linked list without traversing? Lets suppose the link list i..

Answer / santosh patil

just copy elements from 5th to 4th den 6th to 5th n so
on.....at last delete the last node r set it to null

Is This Answer Correct ?    0 Yes 0 No

Can we remove an element in a single linked list without traversing? Lets suppose the link list i..

Answer / codeg

it is not possible in Single AND double linked list without
traversing from first and not knowing addr of 4..
its possible in circular doubly linked list only........

Is This Answer Correct ?    0 Yes 0 No

Can we remove an element in a single linked list without traversing? Lets suppose the link list i..

Answer / vishal jagani

yes u can it link list(doubly),....

Is This Answer Correct ?    2 Yes 3 No

Can we remove an element in a single linked list without traversing? Lets suppose the link list i..

Answer / pradeep

its possible only if it is a doubly linked list.

Is This Answer Correct ?    3 Yes 6 No

Can we remove an element in a single linked list without traversing? Lets suppose the link list i..

Answer / truong nguyen

Memory address of all elements in a linked list are not
continuous. So if we only know the memory address of the
element "4", we cannot know memory address of element "3"
and "5" without traversing. And we cannot remove it from the
linked list.

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More C++ General Interview Questions

How do you remove an element from a set in c++?

0 Answers  


Write a program to find the reverse Fibonacci series starting from N.

0 Answers   Huawei,


How the memory management in vectors are being done. What happens when the heap memory is full, and how do you handle it ?

0 Answers   Yahoo,


Difference between static global and global?

16 Answers   Microsoft, Symphony, Wipro,


Q1 On the screen how do you write the following words? she sells seashells by the seashore (a) all in one line (b) in three lines Q2 Write a program that asks interactively the user’s name and age and responds with Hello name, next year you will be next_age. where next_age is age + 1 Q3 For the different values of n, what is the output? printf(“%x %c %o %d”,n,n,n,n); (a) n = 67 (b) n = 20 (c) n = 128 (d) n = 255 (e) n = 100 Q4 What will be the output of the following program? int main() { char a,b,c; scanf(“%c %c %c”,&a,&b,&c); printf(“a=%c b=%c c=%c”,a,b,c); return 0; } [Note: The user input is:ABC DEF GHI]

1 Answers  






Can we delete this pointer in c++?

0 Answers  


Do class declarations end with a semicolon?

0 Answers  


write a program that takes 5 digit no and calculate 2 power that no and print it.

3 Answers  


Does c++ have a hash table?

0 Answers  


What size is allocated to the union variable?

0 Answers  


Who created c++?

0 Answers  


What is time h in c++?

0 Answers  


Categories