node6 = Node(2) node7 = Node(1) node1.next = node2 node2.next = node3 node4.next = node5 node5.next = node6 node6.next = node7 # Creating 1st Linkedlist l1 = LinkedList(node1) # Creating 2nd Linkedlist l2 = LinkedList(node4) print("Digits store in reverse order") l1.printElements() print('+') l2.printElements() sumNode = sumList(l1.head, l2.head, 0) ll = LinkedList(sumNode) print('=') ll.printElements() print("\nDigits store in forward order") l1.printElements() print('+') l2.printElements() sumNode1 = sumListFwd(l1.head, l2.head) ll1 = LinkedList(sumNode1) print('=') ll1.printElements()
if __name__ == "__main__": # Creating nodes node1 = Node(3) node2 = Node(5) node3 = Node(89) node4 = Node(17) node5 = Node(13) node6 = Node(215) node7 = Node(17) node8 = Node(23) node9 = Node(825) node10 = Node(27) node1.next = node2 node2.next = node3 node3.next = node4 node4.next = node5 node5.next = node6 node6.next = node7 node7.next = node8 node8.next = node9 node9.next = node10 # Creating Linkedlist ll = LinkedList(node1) ll.printElements() partition(ll, 23) print("##") ll.printElements()