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?

Homework Answers

Answer #1

/*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);

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C PROGRAMMING Doubly Linked List For this program you’ll implement a doubly linked list of strings....
C PROGRAMMING Doubly Linked List For this program you’ll implement a doubly linked list of strings. You must base your code on the doubly linked list implementation given in my Week 8 slides. Change the code so that instead of an ‘int’ each node stores a string (choose a suitable size). Each node should also have a next node pointer, and previous node pointer. Then write functions to implement the following linked list operations: • A printList function that prints...
Consider a “Remove” operation from a doubly linked list other than front and end. Explain the...
Consider a “Remove” operation from a doubly linked list other than front and end. Explain the implementation of “Remove” operation using a drawing by showing appropriate links. Using the explanation of (a) write the statements to implement the “Remove” operation. Using (b) show that the complexity of “Remove” operation is O(1).
List three differences between the T cell receptor and the B cell receptor (for example, think...
List three differences between the T cell receptor and the B cell receptor (for example, think structure and antigen recognition). Name three toll-like receptor ligands.
In this code, I build a single-linked list using a node class that has been created....
In this code, I build a single-linked list using a node class that has been created. How could I change this code to take data of type T, rather than int. (PS: ignore the fact that IOHelper.getInt won't work for the type T... ie second half of main). Here's my code right now: public class SLList { public SLNode head = null; public SLNode tail = null; public void add(int a) {// add() method present for testing purposes SLNode newNode...
Implement a singly linked list having all unique elements with the following operations.I 0 x –...
Implement a singly linked list having all unique elements with the following operations.I 0 x – Inserts element x at the end. I 1 y x – If the element y exists, then insert element x after the element y, else insert element y before the existing element x. Assuming either the element x or the element y exists. I 2 z y x – Inserts element x in the middle of the elements z and y. The element z...
Name the exocrine glands and explain the differences between their secretions. Write as much as detail...
Name the exocrine glands and explain the differences between their secretions. Write as much as detail you can, plz type the answer, i can't read the hand writing, Thank you.
Explain the primary reason ICD10 has been implemented, list three major differences between ICD9 and ICD10.
Explain the primary reason ICD10 has been implemented, list three major differences between ICD9 and ICD10.
Describe the differences between traditional outsourcing and enterprise partnership outsourcing. List three characteristics of each and...
Describe the differences between traditional outsourcing and enterprise partnership outsourcing. List three characteristics of each and briefly describe for each characteristic you identify how the two sourcing approaches differ. Give a practical example for each one.
LANGUAGE IS C++ 1- A link based getEntry method requires how many steps to access the...
LANGUAGE IS C++ 1- A link based getEntry method requires how many steps to access the nth item in the list? a)n b)n+1 c)n^2 d)n-1 2- When calling the insert or remove methods, what is an disadvantage for the link-based implementation of the ADT List? a)harder to understand b)must shift data c)searching for that position is slower d)takes more memory 3-What is the last step in the insertion process for a linked implementation of the ADT List? a)Connect the new...
Data Structures using C++ Searching a Linked List Here are the declarations for a simple unsorted...
Data Structures using C++ Searching a Linked List Here are the declarations for a simple unsorted linked list of ints that ends in a null pointer. //=============================================================== class Cell { friend class UList; private: int data; Cell* next; Cell( int dt, Cell* nx=nullptr ) : data(dt), next(nx) {} }; //=============================================================== class UList { private: Cell* head = nullptr;    // stationary head pointer. Cell* scan = nullptr;          // for walking down the List. Cell* follow = nullptr; public: void find( int...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT