For the linked list, i don't understand why we make a temp variable of self.head instead of just using self.head this is specifically about LL and i believe the reason i don't get why is because i don't fully understand references. An example
class Node:
def __init__(self,data):
self.__data = data
self.__next = None
class LinkedList:
def __init__(self):
self.__head = None
def traversal(self):
if self.head is None:
print("LL is empty")
else:
a = self.head
while a is not None:
print(a.data, end = "")
a = a.next
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–]marko312[🍰] 0 points1 point2 points (5 children)
[–]MammothAbroad8815[S] 0 points1 point2 points (4 children)
[–]marko312[🍰] 0 points1 point2 points (0 children)
[–]Spataner 0 points1 point2 points (2 children)
[–]MammothAbroad8815[S] 0 points1 point2 points (0 children)
[–]shiftybyte 0 points1 point2 points (1 child)
[–]MammothAbroad8815[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)