Linked Lists

Go to Problems

Arrays vs Linked Lists

Arrays and Linked Lists both are linear data structures, but they both have some advantages and disadvantages over each other.

One advantage of the linked list is that elements can be added to it indefinitely, while an array will eventually get filled or have to be resized (a costly operation that isn't always possible). 

Elements are also easily removed from a linked list whereas removing elements from an array leaves empty spaces that are a waste of computer memory.

 

Insertion in Array and Linked List

 

However, unlike arrays which allow random access to the elements contained within them, a link list only allows sequential access to its elements. Linked lists also use more storage space in a computer's memory as each node in the list contains both a data item and a reference to the next node.

It follows that linked lists should be used for large lists of data where the total number of items in the list is changing. Arrays, on the other hand, are better suited to small lists, where the maximum number of items that could be on the list is known.

 

Serious about Learning Programming ?

Learn this and a lot more with Scaler Academy's industry vetted curriculum which covers Data Structures & Algorithms in depth.

Linked Lists Problems

List sort
Problem Score Companies Time Status
Sort Binary Linked List 200 33:21
Partition List 275
49:36
Insertion Sort List 300
49:25
Sort List 350 59:53
Pointer move
Problem Score Companies Time Status
K reverse linked list 200 60:30
Even Reverse 200 45:39
Swap List Nodes in pairs 350 33:34
Rotate List 350 33:58
List trick
Problem Score Companies Time Status
Kth Node From Middle 200 30:11
Reverse Alternate K Nodes 300 53:49
Reverse Link List II 450 57:24
Reorder List 600 57:10
List math
Problem Score Companies Time Status
Add Two Numbers as Lists 250 43:07
List Cycle 600 39:15
lock
Topic Bonus
Bonus will be unlocked after solving min. 1 problem from each bucket