Data Structures: Linked List

a guide into data structures and the most known related algorithms

Definition

Usage

Types

Pros and Cons

Time Complexity

Linked Lists in different programming languages

JAVA

LinkedList<String> cars = new LinkedList<String>();
cars.add("Volvo");
cars.add("BMW");
cars.add("Ford");

C#

// Create the link list. 
string[] words = { “the”, “fox”, “jumps”, “over”, “the”, “dog” }; LinkedList<string> sentence = new LinkedList<string>(words);

Ruby/Python/JavaScript

# A simple Python program to introduce 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 objectclass LinkedList:
# Function to initialize head
def __init__(self):
self.head = None
# Code execution starts hereif __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

Popular programming patterns

Fast and Slow pointers

In-place reversal of linked list

Conclusion

Software Engineer, Problem solving oriented and new technologies enthusiast.