What is a Linked List?
💡 Concept Name
Linked List – A collection of elements, called nodes, where each node stores data and a link (or reference) to the next node in the chain. In .NET, this is implemented as LinkedList<T>
.
📘 Quick Intro
Linked lists are flexible data structures that make it easy to add or remove elements on the fly. Instead of keeping everything packed in a row like an array, each value (node) points to the next—so the list can grow or shrink as needed, with no wasted space or awkward shifting.
🧠 Analogy / Short Story
Imagine a relay race, where each runner hands the baton to the next person. You don’t need to know how many runners are in the race; you just follow the baton from one to another. That’s a linked list—each “runner” (node) knows who comes next, making it easy to add, remove, or rearrange people mid-race.
🔧 Technical Explanation
- 🔗 Each node contains data and a reference to the next node (and optionally, the previous one in a doubly linked list).
- 📏 No fixed size—linked lists grow and shrink dynamically, one node at a time.
- ⚡ Insertion and removal (especially at the start or end) are fast—no shifting large blocks of data.
- ⛔ Direct access by index is not supported; you must walk from the start to find an element (linear time).
- 🔁 You can use singly linked lists (next pointer only), doubly linked lists (next and previous pointers), or even circular lists.
🎯 Purpose & Use Case
- ✅ When your program needs to frequently add or remove items from anywhere in the list.
- ✅ Great for building stacks, queues, or graph adjacency lists.
- ✅ Perfect when the total number of elements isn't known in advance and can change at any time.
💻 Real Code Example
// Using LinkedList in C#
var shoppingList = new LinkedList<string>();
shoppingList.AddLast("Eggs");
shoppingList.AddLast("Milk");
shoppingList.AddFirst("Bread");
// Print out each item in the shopping list:
foreach (string item in shoppingList)
{
Console.WriteLine(item);
}
// Output: Bread, Eggs, Milk

❓ Interview Q&A
Q1: What makes a linked list different from an array?
A: Linked lists connect elements with pointers, not indexes—making them dynamic and flexible.
Q2: Which types of linked lists exist?
A: Singly linked, doubly linked, and circular linked lists.
Q3: Can you jump straight to the 5th element in a linked list?
A: No, you must walk through each node in sequence.
Q4: How fast is inserting at the head of a linked list?
A: O(1)—instant!
Q5: When is a linked list better than an array or list?
A: When you need lots of inserts/removals, not random access.
Q6: What’s the memory overhead for linked lists?
A: Each node stores both the value and a pointer (reference), which takes extra memory.
Q7: How do you use linked lists in .NET?
A: With the LinkedList<T>
class.
Q8: How fast is traversal in a linked list?
A: O(n)—you must visit each node to find what you want.
Q9: Is LinkedList<T>
in .NET generic?
A: Yes—it’s type-safe and works with any type.
Q10: Is memory usage higher than arrays?
A: Yes, because each node stores an extra reference or two.
📝 MCQs
Q1. What is a linked list?
- A sequence of nodes with pointers
- An indexed array
- A table of rows
- A stack
Q2. Which operation is fast in a linked list?
- Search
- Index lookup
- Insertion/deletion
- Sorting
Q3. What is the time complexity to insert at head?
- O(n)
- O(log n)
- O(1)
- O(n^2)
Q4. Which has more memory overhead?
- Array
- Linked list
- Both equal
- Depends
Q5. What is a node?
- A class
- A data cell
- An element with data and pointer
- An index
Q6. Can LinkedList<T> be iterated with foreach?
- No
- Yes
- Only via index
- Only in arrays
Q7. What type of memory does a linked list use?
- Stack
- Heap
- Global
- Cache
Q8. What is LinkedList<T> in .NET?
- Stack implementation
- Array list
- Generic linked list class
- List adapter
Q9. Can you add at both ends in LinkedList<T>?
- No
- Yes
- Only at front
- Only at end
Q10. Is indexing supported directly?
- Yes
- No
- With extension method
- Only in C++
💡 Bonus Insight
Use LinkedList<T>
when your app is all about quick insertions and deletions, not speed-searching for a random element. For everyday programming, though, List<T>
is usually the faster and lighter choice.
📄 PDF Download
Need a handy summary for your notes? Download this topic as a PDF!