##Contiguous vs Linked Data Structures Data Structures can be classified as either Contiguous or linked, depending on whether they use arrays or pointers.
Contiguous Data Structures are allocated using a single slice of memory. Contiguous data structures include arrays, heaps, and hash tables.
Linked data structures are constructed using distinct chunks of memory and are tied together using pointers. These include trees, graphs, and linked lists.
##Linked Lists There are several different types of linked lists such as:
Circularly Linked Lists have a tail that has a pointer pointing back to the first node. Useful for things like Round-Robin Queues.
Circularly Linked lists are sometimes convenient for certain problems
Linked Lists have Constant insertion time at the head "index", while dynamic arrays must resize
Linked Lists can be used to implement queues / stacks more efficiently
When You don't need to access an index of the list
When you might want to insert items in the middle of the list
You don't need random access to any elements
You don't know the size of your dataset
You need random access to elements
You need constant time access to indexed elements
You need speed when iterating through elements. Linked Lists are slower in iteration because arrays use pointer arithmetic
Memory is a concern: Arrays are more memory efficient than linked lists. Each Node in a linked list requires data and a pointer.
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node def print_list(head):
while(head != None):
print head.data
head = head.next def Insert(head, data):
if(head == None):
return Node(data,None)
else:
pointer = head
while(head.next != None):
head = head.next
head.next = Node(data, None)
return pointerThere are many problems where after conducting a manipulation, you have to return the entire linked list. This implies that you have to keep track of the head node. Make sure you keep a copy of the head node to return at the end of the problem.
Given a linked list, how do you figure out if it has a cycle?
Instantiate a slow and fast pointer

Increment both pointers at different speeds

If they meet, you know that there is a cycle!

Iterate through a linked list
Get value of node N in linked list
Reverse a linked list
Insert Node at head of linked list
Insert Node at tail of linked list
Insert Node at Nth position of linked list
delete node at Nth position of linked list
Merge two sorted linked lists
Delete duplicate values in linked list
Detect cycle in linked list
Find whether or not two linked lists merge
Given two merged linked lists, find the merge node


