from Datastructures.LinkedList.LinkedListConstruct import LinkedList, Node llist = LinkedList() llist.head = Node(1) second = Node(2) third = Node(3) fourth = Node(4) llist.head.next = second second.next = third third.next = fourth llist.printList() print("*" * 30) print(' ') llist.deletePosNode(2) llist.printList() print("*" * 30) print(' ')
from Datastructures.LinkedList.LinkedListConstruct import LinkedList, Node, commonListIntersectionTraversal listFirst = LinkedList() # creating an empty list listFirst.head = Node(1) second = Node(2) third = Node(3) fourth = Node(4) fifth = Node(5) listFirst.head.next = second second.next = third third.next = fourth fourth.next = fifth listSecond = LinkedList() # creating an empty list listSecond.head = Node(1) second = Node(2) third = Node(3) listSecond.head.next = second second.next = third list = commonListIntersectionTraversal(listFirst, listSecond) list = list.head.next while list != None: print(list.data) list = list.next
from Datastructures.LinkedList.LinkedListConstruct import Node, createdLinkedList list = createdLinkedList() data = list.iterativeSearch(Node(3)) if data > -1: print("Node is found at {}".format(data)) else: print("No such node is found!")
from Datastructures.LinkedList.LinkedListConstruct import LinkedList, Node, intersectionPointNodeCountDifferenceMethod common = Node(8) listFirst = LinkedList() # creating an empty list listFirst.head = Node(3) listFirst.head.next = Node(6) listFirst.head.next.next = Node(9) listFirst.head.next.next.next = common listFirst.head.next.next.next.next = Node(30) listSecond = LinkedList() listSecond.head = Node(10) listSecond.head.next = common listSecond.head.next.next = Node(100) intersectionPointNodeCountDifferenceMethod(listFirst, listSecond)
from Datastructures.LinkedList.LinkedListConstruct import Node, createdLinkedList, LinkedList # front-side insertion to linked list list = createdLinkedList() list.frontpush(Node(4)) list.printList() print("*" * 100) # between insertion llist = LinkedList() llist.head = Node(1) second = Node(2) llist.head.next = second third = Node(3) second.next = third llist.betweenInsertion(second, 4) llist.printList() print("*" * 100) # end insertion list.endInsertion(5) list.endInsertion(6) list.endInsertion(7) list.printList() print("*" * 100)