Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!