Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the implementation of the Linked list class, implement the following functions as part of the class: index(item) returns the position of item in the

Consider the implementation of the Linked list class, implement the following functions as part of the class:

index(item) returns the position of item in the list. It needs the item and returns the index. Assume the item is in the list. ?

pop() removes and returns the last item in the list. It needs nothing and returns an item. Assume the list has at least one item. ?

pop_pos(pos) removes and returns the item at position pos. It needs the position and returns the item. Assume the item is in the list. ?

a function that counts the number of times an item occurs in the linked list

a function that would delete the replicate items in the linked list (i.e. leave one occurrence only of each item in the linked list)

Your main function should do the following:

Generate 15 random integer numbers in the range from 1 to 5.

Insert each number (Item in a node) in the appropriate position in a linked list, so you will have a sorted linked list in ascending order.

Display the generated linked list items.

Call the index(item), pop() and pop_pos(pos) functions to test them.

Display the linked list items

Display the number of occurrences of each item.

Delete the replicate items in the linked list (i.e. leave one occurrence only of each item in the linked list)

Display the final linked list items that should be unique and sorted.

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

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

How flying airoplane?

Answered: 1 week ago