Weekly Task 2 CSC 307(class 2087) Submit a.cpp file in the assignment folder and doc (you can also draw, take a picture, and paste in the word file) file as appropriate. 1. 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() 2. Create both lists by Insert begin and print each of them. 3. Insert 1000 at the beginning of the circular list and print. Draw a picture as how will perform the task. Print the list. 4. Insert 3000 at the 5th position of the doubly linked list. Draw a picture to show how insertion happened. Print the list. 5. Delete 4th element from the circular list. Draw a picture to show how deletion happened. Print the list. 6. Corwert the doubly linked list to a doubly linked circular list. How will you confirm this list is circular? 7. Create a sorted doubly linked list by inserting the generated random numbers one by one in an ascending order. #include
using namespace std; templatesclass 1 struct node { T data: node prev: node" next; template class T> node head, podesta tait. T num): templatesclass T> void printList (nodeT>>" head): templatesclass >> void destroylist(nodect head); template class T> void printBackward (node> head); ant main() node createlist(oder head, nodeT> tail, num) node newlode; /int SENTINNEL W/tail NULL; int count 0 //cin>> nu while (count) CAN>>num newlode new node newlode-data-num new Node prevNULL; new node-next NULL if (head == NULL) { head = new Node; tail = new Node; else { tail->next newNode newNode->prev - tail; tail = newNode; //cin >> num; count++; return head; ) template class T> void printLast(node head) node* current current = head; while (current NULL) cout data" current current next 3 templatesclass T> void destroyList (node) bead) nodeT> current; current-head: while (current NULL) current - head; while (current . NULL) { cout data": current current->next; > ) templatesclass T> void destroylist (node head) node current current head; while (current NULL) head head>next; head-prev NULL: delete current current = NULL ) templateclass void print Backward(nodec head) node current current - head while (current-next NULL) current current->next; while (current - NULL) cout current-data" current current prev: ) Weekly Task 2 CSC 307(class 2087) Submit a.cpp file in the assignment folder and doc (you can also draw, take a picture, and paste in the word file) file as appropriate. 1. 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() 2. Create both lists by Insert begin and print each of them. 3. Insert 1000 at the beginning of the circular list and print. Draw a picture as how will perform the task. Print the list. 4. Insert 3000 at the 5th position of the doubly linked list. Draw a picture to show how insertion happened. Print the list. 5. Delete 4th element from the circular list. Draw a picture to show how deletion happened. Print the list. 6. Corwert the doubly linked list to a doubly linked circular list. How will you confirm this list is circular? 7. Create a sorted doubly linked list by inserting the generated random numbers one by one in an ascending order. #include using namespace std; templatesclass 1 struct node { T data: node prev: node" next; template class T> node head, podesta tait. T num): templatesclass T> void printList (nodeT>>" head): templatesclass >> void destroylist(nodect head); template class T> void printBackward (node> head); ant main() node createlist(oder head, nodeT> tail, num) node newlode; /int SENTINNEL W/tail NULL; int count 0 //cin>> nu while (count) CAN>>num newlode new node newlode-data-num new Node prevNULL; new node-next NULL if (head == NULL) { head = new Node; tail = new Node; else { tail->next newNode newNode->prev - tail; tail = newNode; //cin >> num; count++; return head; ) template class T> void printLast(node head) node* current current = head; while (current NULL) cout data" current current next 3 templatesclass T> void destroyList (node) bead) nodeT> current; current-head: while (current NULL) current - head; while (current . NULL) { cout data": current current->next; > ) templatesclass T> void destroylist (node head) node current current head; while (current NULL) head head>next; head-prev NULL: delete current current = NULL ) templateclass void print Backward(nodec head) node current current - head while (current-next NULL) current current->next; while (current - NULL) cout current-data" current current prev: )