class Node: def __init__(self, e, n): self.element = e self.next = n class LinkedList: def __init__(self, a): # Design the constructor based on data type of a. If 'a' is built in python list then # Creates a linked list using the values from the given array. head will refer # to the Node that contains the element from a[0] # Else Sets the value of head. head will refer # to the given LinkedList # Hint: Use the type() function to determine the data type of a self.head = None # To Do # Count the number of nodes in the list def countNode(self): # To Do # Print elements in the list def printList(self): # To Do # returns the reference of the Node at the given index. For invalid index return None. def nodeAt(self, idx): # To Do
class Node:
def __init__(self, e, n):
self.element = e
self.next = n
class LinkedList:
def __init__(self, a):
# Design the constructor based on data type of a. If 'a' is built in python list then
# Creates a linked list using the values from the given array. head will refer
# to the Node that contains the element from a[0]
# Else Sets the value of head. head will refer
# to the given LinkedList
# Hint: Use the type() function to determine the data type of a
self.head = None
# To Do
# Count the number of nodes in the list
def countNode(self):
# To Do
# Print elements in the list
def printList(self):
# To Do
# returns the reference of the Node at the given index. For invalid index return None.
def nodeAt(self, idx):
# To Do
Step by step
Solved in 2 steps with 20 images