Search Linked List
The following class schema describes the Node
and SLinkedList
classes.
class Node:
def __init__(self, dataval:):
self.dataval = dataval # Type: Union(int|None)
self.nextval = None # Type: Union(int|None)
class SLinkedList:
def __init__(self):
self.headval = None # Type: Union(Node|None)
Write a function, search_list
, that returns a boolean indicating if a value
is in the linked_list
.
Example:
Input:
target = 2
# diagram of linked_list
3 -> 2 -> 5 -> 6 -> 8 -> None
Output:
search_list(linked_list, target) -> True
Next question: Combinational Dice Rolls.....
Loading editor