Question: C++ Question Create 10 random numbers of value 100-150 as elements of a doubly linked list and circular linked list. Perform the following tasks (write
C++ Question

- Create 10 random numbers of value 100-150 as elements of a doubly linked list and circular linked list. Perform the following tasks (write functions and calling them in main())
- Create both lists by insert begin and print each of them.
- Insert 1000 at the beginning of the circular list and print. Draw a picture as how will perform the task. Print the list.
- Insert 3000 at the 5th position of the doubly linked list. Draw a picture to show how insertion happened. Print the list.
- Delete 4th element from the circular list. Draw a picture to show how deletion happened. Print the list.
- Convert the doubly linked list to a doubly linked circular list. How will you confirm this list is circular?
- Create a sorted doubly linked list by inserting the generated random numbers one by one in an ascending order.
Doubly Linked List first class Node { last private: int data; Node* next; Node* previous; public: Node(); int getNextData()const; int getPreviousData()const; Node* getNextLink()const; Node* getPreviousLink()const; void setNextData(int); void setPreviousData(int); void setNextLink(Node); void setPreviousLink(Node); }; class DoublyList { private: Node* head; Node* tail; public: DoublyList(); ~DoublyList(); DoublyList(const DoublyList&); const DoublyList& operator=(const DoublyList&); void clear(); }; node Type* insertBegin(node Type *start, int num){ Circularly Linked List -Insert Begin node Type *current, *newNode; if (start == NULL) { start = new node Type; start->data = num; start->link = start; void print(nodeType *start){ } node Type *current; current = start; cout data link; while (current != start){ else { current = start; while (current->link != start) current = current->link; newNode = new node Type; newNode->data = num; newNode->link = start; start = newNode; cout data link; } } current->link = start; } return start; } Doubly Linked List first class Node { last private: int data; Node* next; Node* previous; public: Node(); int getNextData()const; int getPreviousData()const; Node* getNextLink()const; Node* getPreviousLink()const; void setNextData(int); void setPreviousData(int); void setNextLink(Node); void setPreviousLink(Node); }; class DoublyList { private: Node* head; Node* tail; public: DoublyList(); ~DoublyList(); DoublyList(const DoublyList&); const DoublyList& operator=(const DoublyList&); void clear(); }; node Type* insertBegin(node Type *start, int num){ Circularly Linked List -Insert Begin node Type *current, *newNode; if (start == NULL) { start = new node Type; start->data = num; start->link = start; void print(nodeType *start){ } node Type *current; current = start; cout data link; while (current != start){ else { current = start; while (current->link != start) current = current->link; newNode = new node Type; newNode->data = num; newNode->link = start; start = newNode; cout data link; } } current->link = start; } return start; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
