








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









This is a fact-checked, 15-page reference guide — every time complexity entry is explained with the reasoning behind it, not just stated as a bare label. Ideal as a single revision sheet that ties together everything taught across separate Array and Linked List chapters.
The Question Every DSA Interview Eventually Asks
Every time an engineer picks a data structure for a real system, this exact comparison is happening in the background. A web browser choosing how to store tab history, a music app choosing how to manage a playlist queue, a game engine choosing how to cycle through players' turns — all of these decisions come down to the same four questions this document answers: How fast is access? How fast is search? How fast is insertion? How fast is deletion?
Arrays are unbeatable when you need to jump straight to the 500th element instantly — but painfully slow if you're constantly inserting at the front. Linked lists flip this completely: inserting at the front is instant, but reaching the 500th element means walking through all 499 before it. Doubly and Circular variants each solve one more specific pain point on top of this — and by the end of this document, you'll be able to justify, with reasoning (not guesswork), exactly which structure fits which situation.
Keep this core trade-off in mind as you go through the detailed breakdown ahead — every table and diagram in this guide is really just this one idea, examined operation by operation.
1. Quick Recap: The Four Structures at a Glance
1.1 Array
Elements stored in contiguous memory, accessed directly by index using Base Address + (index × element size).
1.2 Singly Linked List
Nodes scattered in memory, each storing data and a single next pointer; traversal is forward-only, ending at NULL.
1.3 Doubly Linked List
Each node stores data plus both a next and a prev pointer, enabling traversal in both directions.
1.4 Circular Linked List (Singly variant shown)
10
20
30
40
The last node's next points back to the first node instead of NULL — the list has no true end. (A Circular Doubly variant also exists, combining this wrap-around with bidirectional pointers.)
2. Access Time Comparison
"Access" means reaching the element at a given position (e.g., the 5th element) directly.
Structure Access Time Reason
Array O(1) Direct address calculation: Base + index × element size
Singly Linked List O(n) Must traverse from HEAD, one node at a time, to reach the position
Doubly Linked List O(n) Same as singly — no direct index formula exists for linked nodes
Circular Linked List (Singly/Doubly) O(n) Same traversal limitation as their linear counterparts
Key takeaway: Array is the clear winner for access time — this is its single biggest structural advantage, and it holds true across all linked list variants because none of them support a direct address formula.
3. Search Time Comparison
"Search" means finding whether a given value exists in the structure (using Linear Search, since none of these structures are inherently sorted).
Structure Search Time Reason
Array O(n) Unsorted linear search checks each element one by one
Singly Linked List O(n) Traverse node by node from HEAD until a match or NULL
Doubly Linked List O(n) Same as singly for forward search; backward search from TAIL is also O(n)
Circular Linked List O(n) Must traverse and explicitly detect the loop back to HEAD to stop
Key takeaway: Search time is O(n) across the board for unsorted data in every structure discussed here — none has a built-in advantage. (Sorted arrays are the one exception, where Binary Search brings this down to O(log n) — but that requires the data to be sorted first.)
5. Deletion Time Comparison (Beginning, End, Middle)
Structure At Beginning At End At Middle
Array O(n) O(1) O(n)
Singly Linked List O(1) O(n) O(n)
Doubly Linked List O(1) O(n)† O(n)
Circular Singly LL O(n)‡ O(n)‡ O(n)
Circular Doubly LL O(1)§ O(1)§ O(n)
† O(n) because reaching the second-last node requires traversal; becomes O(1) if TAIL is maintained (since TAIL->prev gives the second-last node directly). ‡ O(n) because the last node must be located in order to update its pointer, whether deleting the first or last element. § O(1) because both the last node and second-last node are instantly reachable via prev pointers.
Key takeaway: Linked lists dominate at the beginning (O(1) for Singly/Doubly), while arrays dominate at the end (O(1) for both insertion and deletion, assuming space is available). Middle operations remain O(n) for every structure discussed here, since locating the position always requires either shifting (array) or traversal (linked list).
6. Master Comparison Table — All Structures, All
Operations
Operation Array Singly LL Doubly LL Circular Singly Circular Doubly
Access by position O(1) O(n) O(n) O(n) O(n)
Search (unsorted) O(n) O(n) O(n) O(n) O(n)
Insert at Beginning O(n) O(1) O(1) O(n) O(1)
Insert at End O(1)* O(n) O(n) O(n) O(1)
Insert at Middle O(n) O(n) O(n) O(n) O(n)
Delete at Beginning O(n) O(1) O(1) O(n) O(1)
Delete at End O(1) O(n) O(n) O(n) O(1)
Delete at Middle O(n) O(n) O(n) O(n) O(n)
Traversal direction Either (indexed) Forward only Both Forward only (loops) Both (loops)
Extra NULL/loop handling None Ends at NULL Ends at NULL Must detect HEAD Must detect HEAD
9. Pros and Cons of Each Structure
9.1 Array
9.2 Singly Linked List
9.3 Doubly Linked List
9.4 Circular Linked List (Singly and Doubly)
10. Solved Examples
Problem: A logging system needs to add 50,000 new log entries at the front of a list (most recent first) and rarely accesses entries by position. Which structure is best?
Reasoning:
Problem: An application needs to delete arbitrary nodes frequently, and at the time of deletion, a direct pointer to the node (not its position) is already available. Which structure minimizes the cost of deletion?
Reasoning:
Final Answer: A Doubly Linked List is better suited, since it avoids the O(n) predecessor search entirely.
Problem: A program needs to repeatedly access the 750th element of a 1,000-element collection, with insertions/deletions happening rarely. Which structure fits best?
Reasoning:
Final Answer: An Array is clearly best here, since access is the dominant, frequent operation and insertions/deletions are rare.
Problem: A game engine must cycle through 8 players' turns repeatedly, indefinitely, with no fixed 'last' player. Which structure naturally fits this requirement?
Reasoning:
Final Answer: A Circular Linked List (Singly, since only forward turn order is needed) is the natural fit.
Problem: A design tool needs an Undo/Redo history where the user can move backward through past actions and then forward again if they change their mind. Which structure fits, and why not a Singly Linked List?
Reasoning:
Problem: An embedded system with very limited memory needs to store a fixed-size list of sensor readings and mainly reads them by position (index). Insertions/deletions are rare. Which structure minimizes memory usage?
Reasoning:
Final Answer: An Array is the best fit — it is both the most memory-efficient option and the fastest for the dominant access-by-position operation.
Problem: For a list of 1,000 elements, compare the worst-case number of pointer/element operations needed to delete the last element in: (a) an Array with a maintained size counter, (b) a Singly Linked List with no TAIL pointer, and (c) a Doubly Linked List with no TAIL pointer.
Step-by-step reasoning:
Final Answer: Array is O(1); Singly and Doubly Linked Lists are both O(n) without a TAIL pointer — but only the Doubly Linked List can be brought down to O(1) simply by adding a TAIL pointer, since a Singly Linked List still cannot look backward from TAIL.
11. Common Mistakes to Avoid
Quick Revision Box
Array: best for access (O(1)) and end operations; worst for beginning/middle insertion-deletion (O(n)). Singly LL: best for beginning insertion/deletion (O(1)); worst for access (O(n)). Doubly LL: adds O(1) deletion-when-node-known and backward traversal, at the cost of extra pointer memory. Circular Singly LL: useful for cyclical problems, but beginning operations cost O(n) unless a TAIL pointer is kept. Circular Doubly LL: combines cyclical wrap-around with O(1) operations at both ends, at the highest memory cost of the five.
— End of Notes —