Update Linked-list.md

new change
pull/615/head
Vinay Sagar 2024-05-26 14:13:10 +05:30 zatwierdzone przez GitHub
rodzic b2a1669105
commit d2a25f16cc
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 19 dodań i 20 usunięć

Wyświetl plik

@ -104,28 +104,27 @@ Lets complete the code and create a linked list.
Connect all the code.
if __name__ == '__main__':
llist = LinkedList()
# Insert words at the beginning
llist.insertAtBeginning(4) # <4>
llist.insertAtBeginning(3) # <3> 4
llist.insertAtBeginning(2) # <2> 3 4
llist.insertAtBeginning(1) # <1> 2 3 4
# Insert a word at the end
llist.insertAtEnd(10) # 1 2 3 4 <10>
llist.insertAtEnd(7) # 1 2 3 4 10 <7>
#Insert at a random position
llist.insertAtPosition(9,4) ## 1 2 3 <9> 4 10 7
# Print the list
llist.printList()
if __name__ == '__main__':
llist = LinkedList()
# Insert words at the beginning
llist.insertAtBeginning(4) # <4>
llist.insertAtBeginning(3) # <3> 4
llist.insertAtBeginning(2) # <2> 3 4
llist.insertAtBeginning(1) # <1> 2 3 4
# Insert a word at the end
llist.insertAtEnd(10) # 1 2 3 4 <10>
llist.insertAtEnd(7) # 1 2 3 4 10 <7>
#Insert at a random position
llist.insertAtPosition(9,4) ## 1 2 3 <9> 4 10 7
# Print the list
llist.printList()
output:
1 2 3 9 4 10 7
## output:
1 2 3 9 4 10 7
### Deleting a node from the beginning of a linked list