Starting from:
$30

$24

Lab 24 Solution

Objectives:




Implement basic functionalities using Linked Lists



Question:




Download Lab24.cpp. Write a menu-driven C++ program to implement the bellow Linked Lists operations. Start your code by reading the file input.txt (download from blackboard). Insert all the values one by one to the end of the list.




void insertPos(node *head)



Precondition: Takes the header node and prompts the user to enter two integer numbers. First number is the number that needs to be inserted. Second number is the number after which the first number will be inserted.




Post-condition: Insert the first number next to the position where the second number is located. If the second number is not found in the list, a message will be showed.




void deleteLast(node *head)



Precondition: Takes the header node.




Post-condition: Deletes the last number from the list. Displays a message if the list is already empty.




void frequency(node *head)



Precondition: Takes the header node and prompts the user to enter the integer number that needs to be counted. Post-condition: Shows the frequency of that number.




void sort(node *head);



Precondition: Takes the header node.




Post-condition: Sort the nodes based on the numbers in ascending order using insertion sort or bubble sort.




void printList(node *head)



Post-condition: Prints the numbers of the list from beginning to the end. It shows a message if the list is empty.




Submit one cpp file.

More products