Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
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: )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

a neglect of quality in relationship to international competitors;

Answered: 1 week ago

Question

Discuss about training and development in India?

Answered: 1 week ago

Question

Explain the various techniques of training and development.

Answered: 1 week ago

Question

Explain the various techniques of Management Development.

Answered: 1 week ago