In: Computer Science
According to the problem statement above,
I have coded the function using PYTHON which finds the index of the lookup in that linkedlist.
NOTE: YOU HAVE TO WRITE YOUR CODE ACCORDING TO YOUR PROGRAM.
TREAT THIS METHOD ARE ALGORITHM
Below is the Snippet:
Code Snippet:
Code in Text format:
def find(head: Node, value: int) -> bool: # method to find the index of lookup element
node = head
# head pointer
counter = 0
# counter to store index
value
while node is not None:
# looping
starts here to find the index of lookup
if node.value ==
value:
# if first
node is our lookup then counter will be returned 0
return counter
# returning the counter value
counter = counter +
1
# else
counter will increment
node =
node.next_node
# moving
to next node from current
return False # if node is null, then searching is not possible so we will return FALSE
I hope the above snippets, explanations, and information will help you out!
Thank you!