Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The link list values will be input from the user, the program with C++ language 1. Create a new project with the name Lab3_LinkList Project.

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
The link list values will be input from the user,
the program with C++ language
image text in transcribed
image text in transcribed
1. Create a new project with the name Lab3_LinkList Project. 2. Create a C++ file with name LinkedList and copy struct node class into it. 3. Add main method and complete the balnk with suitable statements int main() { // construct four linked list nodes and add their values( see output) // display the nodes values using printAllNodes() // print the largest value in the linked list // print the value of the second node // print the value of the second last node Il delete the last node // display the nodes values using printAllNodes() // modify the nodes values by using odd2Even2Odd method // display the nodes values using printAllNodes() return 0; } 4. Add the following methods to the file: Taskl: a method named find Largest() which finds the largest value in the linked list and returns its data to the calling main() method. Hint: Use following method header: int findLargest (node* head) { Task2: a method named data2ndNode() which returns the data of second node in the linked list, to the calling main() method. Hint: Use following method header: node* data2ndNode (node* head) { Task3: a method named data2ndLastNode() which returns the data of second last node in the linked list, to the calling main() method. Hint: Use following method header: node* data2ndLastNode (node* head ) { Task4: a method named deleteLastNode() which deletes last node in the existing linked list. Hint: Use following method header: void deleteLastNode (node* head) { } Task5: a method named odd2Even2Odd() which changes all odd value nodes into even by subtracting 1 from every odd node and all even value nodes into odd by adding 1 into every even node. Hint: Use following method header: void odd2Even20dd (node* head) { 3 Output: the nodes have been constructed with values: 10 21 6 8 the largest value is: 21 second node has the value: 21 second last node has the value: 6 last node with value 8 has been deleted!! The list after deleting a node: 10 21 6 The list after modifing the nodes values 11 20 7 ... Program finished with exit code o press ENTER to exit console. This is the class that is used to define a node: struct node { int data; node *next; }; Code for printAllNodes() Method //This method is called from main() and it visits each and every node of linked list and displays the value stored in data field. void printAllNodes (node *head) { node *helpPtr = new node (); helpPtr= head; while (helpPtr != NULL) { Print the data value of the node coutdata next; ) }

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

Students also viewed these Databases questions

Question

What is meant by decentralisation of authority ?

Answered: 1 week ago

Question

Briefly explain the qualities of an able supervisor

Answered: 1 week ago

Question

Define policy making?

Answered: 1 week ago

Question

Define co-ordination?

Answered: 1 week ago

Question

What are the role of supervisors ?

Answered: 1 week ago

Question

Understand how to design effective service guarantees.

Answered: 1 week ago