From d482000a1197e8d72ddc7881b826614debb1bdfb Mon Sep 17 00:00:00 2001 From: shubhamc1200 <65861993+shubhamc1200@users.noreply.github.com> Date: Wed, 7 Oct 2020 10:22:23 +0530 Subject: [PATCH 1/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c8938b4..323e2a3 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,12 @@ The .js cfiles can be found in \src-javascript The .py cfiles can be found in \src-python +# Array +An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. # Stack Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). - # Linked List A linked list is a sequence of data structures, which are connected together via links. Linked List is a sequence of links which contains items. Each link contains a connection to another link. Linked list is the second most-used data structure after array. From 92fac2a3e88add43f52c8541e864ca0b165b65fc Mon Sep 17 00:00:00 2001 From: shubhamc1200 <65861993+shubhamc1200@users.noreply.github.com> Date: Wed, 7 Oct 2020 10:24:16 +0530 Subject: [PATCH 2/3] Updated Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 323e2a3..551326b 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The .py cfiles can be found in \src-python # Array -An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. +An array is a collection of items stored at contiguous memory locations. Its used to store multiple items of the same type together. # Stack Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). From 8ed08945fa3063f9e9a075b8047d19fb9eeca17c Mon Sep 17 00:00:00 2001 From: shubhamc1200 <65861993+shubhamc1200@users.noreply.github.com> Date: Wed, 7 Oct 2020 10:28:37 +0530 Subject: [PATCH 3/3] Created LinkedList.py --- src-python/LinkedList.py | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src-python/LinkedList.py diff --git a/src-python/LinkedList.py b/src-python/LinkedList.py new file mode 100644 index 0000000..65891ae --- /dev/null +++ b/src-python/LinkedList.py @@ -0,0 +1,42 @@ +# A simple Python program for traversal of a linked list + +# Node class +class Node: + + # Function to initialise the node object + def __init__(self, data): + self.data = data # Assign data + self.next = None # Initialize next as null + + +# Linked List class contains a Node object +class LinkedList: + + # Function to initialize head + def __init__(self): + self.head = None + + # This function prints contents of linked list + # starting from head + def printList(self): + temp = self.head + while (temp): + print (temp.data) + temp = temp.next + + +# Code execution starts here +if __name__=='__main__': + + # Start with the empty list + llist = LinkedList() + + llist.head = Node(1) + second = Node(2) + + third = Node(3) + + llist.head.next = second + second.next = third + + llist.printList()