From a1dd770b20179f859dc669fdda163bc7c01a96a2 Mon Sep 17 00:00:00 2001 From: Vinay Sagar <64737008+vinay-sagar123@users.noreply.github.com> Date: Sun, 26 May 2024 14:24:19 +0530 Subject: [PATCH 1/2] Update Linked-list.md chnage3 --- contrib/ds-algorithms/Linked-list.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/ds-algorithms/Linked-list.md b/contrib/ds-algorithms/Linked-list.md index 147527b..541410c 100644 --- a/contrib/ds-algorithms/Linked-list.md +++ b/contrib/ds-algorithms/Linked-list.md @@ -25,12 +25,12 @@ Let's code something The smallest Unit: Node - ```python +```python class Node: def __init__(self, data): self.data = data # Assigns the given data to the node self.next = None # Initialize the next attribute to null - ``` +``` Now, we will see the types of linked list. @@ -46,20 +46,20 @@ There are mainly four types of linked list, Simply think it is a chain of nodes in which each node remember(contains) the addresses of it next node. ### Creating a linked list class - ```python +```python class LinkedList: def __init__(self): self.head = None # Initialize head as None - ``` +``` ### Inserting a new node at the beginning of a linked list - ```python +```python def insertAtBeginning(self, new_data): new_node = Node(new_data) # Create a new node new_node.next = self.head # Next for new node becomes the current head self.head = new_node # Head now points to the new node - ``` +``` ### Inserting a new node at the end of a linked list From beba33d28736209440c9d9cb4784426a9d38ce9b Mon Sep 17 00:00:00 2001 From: Vinay Sagar <64737008+vinay-sagar123@users.noreply.github.com> Date: Sun, 26 May 2024 14:24:51 +0530 Subject: [PATCH 2/2] Update Linked-list.md change4 --- contrib/ds-algorithms/Linked-list.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/contrib/ds-algorithms/Linked-list.md b/contrib/ds-algorithms/Linked-list.md index 541410c..9e51ab5 100644 --- a/contrib/ds-algorithms/Linked-list.md +++ b/contrib/ds-algorithms/Linked-list.md @@ -171,21 +171,3 @@ check the list is empty otherwise shift the head to next node. current = current.next position += 1 return f"Value '{value}' not found in the list" - - - - - - - - - - - - - - - - - -