Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a python program you need to add more methods defined in the UnorderedList ADT (append, index, insert, and printList) as described below: - Implement

In a python program you need to add more methods defined in the UnorderedList ADT (append, index, insert, and printList) as described below:

- Implement the append method to add a new item to the end of the list. It needs the item and returns nothing.

- Implement the index method to return the position of the item in the list. It needs the item and returns the index of the item. You can assume the item is in the list.

- Implement the insert method that inserts a new item to the list at position pos. It needs the position pos and the item, and returns nothing.

- Implement the printList method to print out all items in the list

Sample Output:

54 26 93 17 77 31 89

7

True

3

54 26 15 93 17 77 31 89

54 26 15 17 77 31 89

Test File:

myList = UnorderedList() myList.add(31) myList.add(77) myList.add(17) myList.add(93) myList.add(26) myList.add(54) myList.append(89) myList.printList() print() print(myList.size()) print(myList.search(17)) print(myList.index(17)) myList.insert(2, 15) myList.printList() print() myList.remove(93) myList.remove(22) myList.printList()

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago