Question: klass Node: def __init__(self, data=None, next=..None): self.data = data self.next = next defmprint to screen Cheadli if head != None: print(head.data, end= ) print_to_screen(head.next) else:


klass Node: def __init__(self, data=None, next=..None): self.data = data self.next = next defmprint to screen Cheadli if head != None: print(head.data, end=" ") print_to_screen(head.next) else: print("") defuget size Cheadli return 0 =defmreverse_list (head): return head defpalindrome.Cheadli return True o o O O . O 40% SLL Recursion (10%) get_size(head) Takes in the head of a list as a parameter Returns the size of the list (15%) reverse_list(head) Takes in the head of a list as a parameter returns a node, the head of a list that has the same items as the previous list, but in reverse order. (15%) palindrome(head) Takes in the head of a list as a parameter Returns True if the list is a palindrome A list is a palindrome if it is the same reading it forwards and backwards. Example: abba, level and radar are palindromes While adba not a palindrome Since we are using lists instead of strings imagine that every node in the list holds a single character Otherwise returns False This can be done with more than one separate recursive calls that may initialize new instances of Node, or move data around. As long as all runs through the list/lists are recursive, and the original list sent in is not broken in any way, full marks will be given. O 1 o o klass Node: def __init__(self, data=None, next=..None): self.data = data self.next = next defmprint to screen Cheadli if head != None: print(head.data, end=" ") print_to_screen(head.next) else: print("") defuget size Cheadli return 0 =defmreverse_list (head): return head defpalindrome.Cheadli return True o o O O . O 40% SLL Recursion (10%) get_size(head) Takes in the head of a list as a parameter Returns the size of the list (15%) reverse_list(head) Takes in the head of a list as a parameter returns a node, the head of a list that has the same items as the previous list, but in reverse order. (15%) palindrome(head) Takes in the head of a list as a parameter Returns True if the list is a palindrome A list is a palindrome if it is the same reading it forwards and backwards. Example: abba, level and radar are palindromes While adba not a palindrome Since we are using lists instead of strings imagine that every node in the list holds a single character Otherwise returns False This can be done with more than one separate recursive calls that may initialize new instances of Node, or move data around. As long as all runs through the list/lists are recursive, and the original list sent in is not broken in any way, full marks will be given. O 1 o o
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
