Answered step by step
Verified Expert Solution
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){
..........
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started