Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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).


# 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.
Expand Down
42 changes: 42 additions & 0 deletions src-python/LinkedList.py
Original file line number Diff line number Diff line change
@@ -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()