Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

please solve this (in c++) LAB EXERCISE: 1. Create a new project with the name Lab3_ LinkListProject. 2. Create a C++ file with name LinkedList

please solve this (in c++)
LAB EXERCISE:
1. Create a new project with the name Lab3_ LinkListProject.
2. Create a C++ file with name LinkedList and copy struct node class into it.
3. Addmainmethodandcompletethebalnkwithsuitablestatements
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
// 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:
Task1: a method named findLargest() which finds the largest value in the linked list and returns its data to the calling main() method.
Hint: Use following method header:
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:
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:
Task4: a method named deleteLastNode() which deletes last node in the existing linked list.
Hint: Use following method header:
int findLargest(node* head) {
..........
}
node* data2ndNode (node* head){
.......... }
node* data2ndLastNode (node* head ){
..........
}
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:
Output:
void odd2Even2Odd (node* head){
..........
}
image text in transcribed
image text in transcribed
image text in transcribed
CCS224 LAB 3: Linked List 1 LAB EXERCISE: 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 // 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; } CCCS224 LAB 3: Linked List 1 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 delete LastNode() which deletes last node in the existing linked list. Hint: Use following method header. void deleteLastNode (node* head) { CCCS224 LAB 3: Linked List 1 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) { } Output: the nodes have been constructed with values: 10 21 6 8 the largest value is: 21 second node ha 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

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_2

Step: 3

blur-text-image_3

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

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students explore these related Databases questions