COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
no
|
|
yes
|
|
Either A or B
|
|
None of the above
|
Detailed explanation-1: -Insertion on a Doubly Linked List. Pushing a node to a doubly-linked list is similar to pushing a node to a linked list, but extra work is required to handle the pointer to the previous node. We can insert elements at 3 different positions of a doubly-linked list: Insertion at the beginning.
Detailed explanation-2: -Which of the following is false about a doubly linked list? Explanation: A doubly linked list has two pointers ‘left’ and ‘right’ which enable it to traverse in either direction. Compared to singly liked list which has only a ‘next’ pointer, doubly linked list requires extra space to store this extra pointer.
Detailed explanation-3: -Deletion in doubly linked list at the beginning is the simplest operation. We just need to copy the head pointer to pointer ptr and shift the head pointer to its next.
Detailed explanation-4: -Once you arrive at the ith node, inserting/deleting only takes O(1) time since it’s just a rearrangement of pointers, no shifting. As to why linked lists are preferred when there are many inserts/deletions, I would say that one reason is that with linked lists you don’t need to know how big it has to be ahead of time.