b) search_loop is a function to search a singly linked list. Its
expected results are illustrated below. Write a function that
implement the same effect in a recursive algorithm.
def search_loop(list_head, item):
cur = list_head
found = False
while cur != None and not found:
if cur.getData()
== item:
found
= True
else:
cur
= cur.getNext()
return found
my_list = UnorderedList()
for num in [5, 7, 3, 9, 1]:
my_list.add(num)
search_loop(my_list.head, 3) # returns True
search_loop(my_list.head, 2) # returns False
b) search_loop is a function to search a singly linked list. Its expected results are illustrated below. Write a functio
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
b) search_loop is a function to search a singly linked list. Its expected results are illustrated below. Write a functio
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!