Question

# a) Name three differences between vectors and linked list? b) Given a doubly linked list with...

a) Name three differences between vectors and linked list?

b) Given a doubly linked list with five nodes, explain how can you remove the node in the middle and replace it with new node?

/*If you have any query do comment in the comment section else like the solution*/

a)

1. Values are stored in contigous memory in vector but not in linked list

2. Due to subscript in vector random value access is allowed but not in linked list

3. Deletion of a value in vector is costlier than that of linked list.

b)

You can iterate to node number three by keeping a count variable and a prev node, at each iteration prev node will be updated wiht the value of current node. Once reached at node number three perform below steps

node tmp = new node();
tmp->next = curr->next;
tmp->prev = curr->prev;
curr->prev->next = tmp;
curr->next->prev = tmp;
delete(curr);

#### Earn Coins

Coins can be redeemed for fabulous gifts.