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
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 |
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 |
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 |
Answer / pradeep
its possible only if it is a doubly linked list.
Is This Answer Correct ? | 3 Yes | 6 No |
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 |
Which is best c++ or java?
What does new return if there is insufficient memory to make your new object?
Explain the volatile and mutable keywords.
What is the difference between structures and unions?
Which programming language is best?
check whether a no is prime or not.
What is the meaning of c++?
class A { public: void f(); protected: A() {} A(const A&){} }; Examine the class declaration shown above. Why are the default and copy constructors declared as protected? 1. To ensure that A cannot be created via new by a more derived class 2. To ensure that A cannot be copied 3. To ensure that A cannot be used as a base class except when public inheritance has been used 4. To ensure that A cannot be created/copied outside the inheritance chain 5. To ensure that A cannot be instantiated as a static variable
What are the important differences between c++ and java?
List the merits and demerits of declaring a nested class in C++?
Can comments be longer than one line?
Does c++ have a hash table?