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

What is the most common mistake on c++ and oo projects?

0 Answers  


Is c++ a float?

0 Answers  


What can c++ be used for?

0 Answers  


Which software is used for c++ programming?

0 Answers  


What is an undefined behavior and sequence points

0 Answers  


What is else if syntax?

0 Answers  


"How will you merge these two arrays? Write the program Array: A 1 18 22 43 Array: B 3 4 6 20 34 46 55 Output Array: C 1 3 4 6 18 20 22 34 43 46 55"

9 Answers   College School Exams Tests, HCL,


What will strcmp("Astring", "Astring"); return a) A positive value b) A negative value c) Zero

0 Answers  


Assume studentNames and studentIDs are two parallel arrays of size N that hold student data. Write a pseudocode algorithm that sorts studentIDs array in ascending ID number order such that the two arrays remain parallel.

0 Answers  


iam a fresher to Qt(GUI a c++ based framework software). i need to develop the basic applications on designer by drag and dropping mechanism...so pls send me the procedure to design applications?

1 Answers  


Can we make copy constructor private in c++?

0 Answers  


Describe private, protected and public – the differences and give examples.

0 Answers  


Categories