Hitesh Sahu
Hitesh SahuHitesh Sahu
  1. Home
  2. ›
  3. posts
  4. ›
  5. …

  6. ›
  7. 3 DBMS

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🍯 Honey never spoils — archaeologists found 3,000-year-old jars still edible.

🍪 This website uses cookies

No personal data is stored on our servers however third party tools Google Analytics cookies to measure traffic and improve your website experience. Learn more

Loading ⏳
Fetching content, this won’t take long…


💡 Did you know?

🦥 Sloths can hold their breath longer than dolphins 🐬.
Cover Image for 📘 Data Structures, Algorithms & DBMS

📘 Data Structures, Algorithms & DBMS

Comprehensive notes on Data Structures, Algorithms, and Database Systems — covering time complexity, Big O notations, sorting algorithms, and database comparisons for quick revision.

Hitesh Sahu
Written by Hitesh Sahu, a passionate developer and blogger.

Thu Oct 30 2025

Share This on

Data Structures & Algorithms (DSA) & Database Management System (DBMS)

🧱 Data Structures

Linear Data Structures

#Data StructureAccessInsertionDeletionSearching
1️⃣🧮 Array⚡ O(1)⏳ At 0 Index: O(n)⏳ At 0 Index: O(n)🔍 Linear: O(n)
Binary (Sorted): O(log n)
2️⃣🔗 Linked List⏳ O(n)⚡ O(1)⚡ O(1)🔍 O(n)
3️⃣📚 Stack⏳ O(n)⚡ O(1)⚡ O(1)🔍 O(n)
4️⃣🚶 Queue⏳ O(n)⚡ O(1)⚡ O(1)🔍 O(n)

🌲 Non-Linear Data Structures

#Data StructureAccessInsertionDeletionSearchingSpace
1️⃣🌿 AVL Tree⚡ O(log n)⚡ O(log n)⚡ O(log n)⚡ O(log n)💾 O(n)
2️⃣🌳 Binary Search Tree (BST)🐢 O(n)🐢 O(n)🐢 O(n)🐢 O(n)💾 O(n)
3️⃣🌴 B-Tree⚡ O(log n)⚡ O(log n)⚡ O(log n)⚡ O(log n)💾 O(n)
4️⃣📐 Cartesian TreeN/A⏳ O(n)⏳ O(n)⏳ O(n)💾 O(n)
5️⃣📊 KD Tree⚡ O(log n)⚡ O(log n)⚡ O(log n)⚡ O(log n)💾 O(n)
6️⃣🔴 Red-Black Tree⚡ O(log n)⚡ O(log n)⚡ O(log n)⚡ O(log n)💾 O(n)
7️⃣🪜 Skip List / Skip Tree⚡ O(log n)⚡ O(log n)⚡ O(log n)⚡ O(log n)💾 O(n)
8️⃣🌀 Splay Tree⚖️ Amortized O(log n)⚖️ Amortized O(log n)⚖️ Amortized O(log n)⚖️ Amortized O(log n)💾 O(n)
9️⃣⛰️ Binary Heap⏳ O(log n)⚡ O(log n)⏳ O(log n)🔍 O(n)💾 O(n)
🔟🧩 Hash Table❌ N/A⚡ O(1)⚡ O(1)⚡ O(1)💾 O(n)

Note:

H = log n for self-balancing BSTs such as AVL, Red-Black, and Splay Trees — they maintain a logarithmic height.

🧠 Other Advanced Structures

#Data StructureAccessInsertionDeletionSearchingSpace
1️⃣🕸️ GraphO(1) (Adj. Matrix)
O(V + E) (Adj. List)
⚡ O(1)⏳ O(V + E)🔍 O(V + E)💾 O(V + E)
2️⃣🔤 Trie⏳ O(L)⏳ O(L)⏳ O(L)⏳ O(L)💾 O(ALPHABET_SIZE × n)
3️⃣📏 Segment Tree⚡ O(log n)⚡ O(log n)⚡ O(log n)⚡ O(log n)💾 O(n)
4️⃣🧬 Suffix Tree⚡ O(n)⚡ O(n)⚡ O(n)⚡ O(m)💾 O(n)

📈 Asymptotic Notations / Landau Notation (Edmund Landau)

Measures the order of growth of an algorithm with respect to the number of inputs n.

Big O

Represents the worst-case scenario, where the loop runs till the last element.

  • Simplified Worst case when loop runs till the last elements:
    • Fastest growing expression determine over all complexity.
    • Remove Constant & Remove non-dominant terms

Example.

f(n) = An+B
= O(n)

f(n) = n3+n2+7n
= O(n3)

Common used big O notation

accessibility text
ComplexityVisual GrowthDescription
O(1)🟢Constant — fastest, independent of n
O(log n)🟢🟢Logarithmic — grows slowly, e.g., Binary Search
O(n)🟡🟡🟡Linear — grows proportionally to input size
O(n log n)🟡🟡🟡🟡Polylogarithmic — e.g., Merge Sort, Quick Sort (average)
O(n²)🔴🔴🔴🔴Quadratic — nested loops, e.g., Bubble Sort
O(n³)🔴🔴🔴🔴🔴Cubic — triple nested loops
O(cⁿ)🔴🔥Exponential — runtime doubles/triples with each input
O(n!)🔥🔥🔥Factorial — extremely fast growth, e.g., brute-force permutations

🟢 1. Optimized (Lower Growth Order)

O(1) - Constant time

  • Single R/W
  • Single statement of code
  • No loops
  • A loop which run in fix number of time

O(log(n)) - Logarithmic

  • Loop divided by constant number eg Binary Serach
  • Divide & conqure

O(n(log(n)) - PolyLogarithmic

  • Loop divided & multiplied by constant number

🔴 2. Not Optimized (Higher Growth Order)

ComplexityTypeDescription
O(n)LinearLoop increases/decreases by constant number
O(nᶜ)PolynomialC nested loops
O(n²)Quadratic2 nested loops
O(n³)Cubic3 nested loops
O(cⁿ)ExponentialFor each element run C nested loops
O(n!)FactorialAdds a loop for every element

Notes:

  • O(cⁿ) grow faster than O(nᶜ). If O(nᶜ) grow faster than O(cⁿ) than it is called superpolynomial & in that case O( cⁿ) called subexponential

⚡ Sorting Algorithm Complexity

Legend

  • Ω (Omega) → Best case
  • Θ (Theta) → Average case
  • O (Big O) → Worst case
  • Stable? ✅ Yes / ❌ No
#Algorithm⏱️ Best⚖️ Average🔻 Worst💾 Space⚙️ Stability
1️⃣⚡ Quick SortΩ(n log n)Θ(n log n)O(n²)O(log n)❌ No
2️⃣🧩 Merge SortΩ(n log n)Θ(n log n)O(n log n)O(n)✅ Yes
3️⃣🚀 TimsortΩ(n)Θ(n log n)O(n log n)O(n)✅ Yes
4️⃣⛰️ Heap SortΩ(n log n)Θ(n log n)O(n log n)O(1)❌ No
5️⃣💧 Bubble SortΩ(n)Θ(n²)O(n²)O(1)✅ Yes
6️⃣✍️ Insertion SortΩ(n)Θ(n²)O(n²)O(1)✅ Yes
7️⃣🪞 Selection SortΩ(n²)Θ(n²)O(n²)O(1)❌ No
8️⃣🌲 Tree SortΩ(n log n)Θ(n log n)O(n²)O(n)✅ Yes
9️⃣🐚 Shell SortΩ(n log n)Θ(n (log n)²)O(n (log n)²)O(1)❌ No
🔟🪣 Bucket SortΩ(n + k)Θ(n + k)O(n²)O(n)✅ Yes
1️⃣1️⃣🔢 Radix SortΩ(n k)Θ(n k)O(n k)O(n + k)✅ Yes
1️⃣2️⃣🧮 Counting SortΩ(n + k)Θ(n + k)O(n + k)O(k)✅ Yes
1️⃣3️⃣🧊 Cube SortΩ(n)Θ(n log n)O(n log n)O(n)✅ Yes


🔎 Searching Algorithm Complexity

#Algorithm⏱️ Best⚖️ Average🔻 Worst💾 Space⚙️ Stability
1️⃣🚶‍♂️ Linear SearchO(1)O(n)O(n)O(1)✅ Yes
2️⃣🎯 Binary SearchO(1)O(log n)O(log n)O(1)✅ Yes
3️⃣🪜 Jump SearchO(1)O(√n)O(√n)O(1)✅ Yes
4️⃣🧩 Interpolation SearchO(1)O(log log n)O(n)O(1)✅ Yes
5️⃣⚡ Exponential SearchO(1)O(log n)O(log n)O(1)✅ Yes
6️⃣🧮 Fibonacci SearchO(1)O(log n)O(log n)O(1)✅ Yes
7️⃣🔢 Hashing SearchO(1)O(1)O(n)O(n)✅ Yes
8️⃣🌳 Binary Search Tree (BST)O(1)O(log n)O(n)O(n)✅ Yes
9️⃣🌲 Balanced BST (AVL, Red-Black)O(1)O(log n)O(log n)O(n)✅ Yes

Notes

  • Binary Search requires sorted data.
  • Hashing gives average constant-time lookup but degrades to O(n) on collisions.
  • Balanced Trees ensure logarithmic performance by maintaining structure.
  • Jump and Interpolation searches are useful for uniformly distributed data.

🗄️ Database Comparison

DBParadigmKey FeaturesUse Case / Space / Notes
Redis🔑 Key-ValueIn-Memory, PUB/SUB, CachingLeaderboards, Session Storage 🟢
Cassandra🟩 Wide ColumnSchema-less, No JoinsHigh write throughput, Time Series ⏱️
HBase🟩 Wide ColumnSchema-less, No JoinsLarge-scale storage, Batch Processing 🟡
MongoDB / Firebase / CouchDB / Dynamo📄 Document-OrientedSchema-less, No JoinsIOT, Games, Fast Reads & Writes 🎮
MySQL (Oracle) / PostgreSQL🗂️ RelationalSchema, Join, ACIDBanking, Enterprise Applications 🏦
Neo4J🌐 GraphRelationships, Graph QueriesKnowledge Graphs, Recommendations 🌐
Solr / Algolia / Elasticsearch🔎 Search IndexIndexing, Full-text SearchSearch Engines 🔍
Fauna / GraphQL⚡ Multi-ModelFlexible, Multi-paradigmModern APIs, Not restricted to one model ⚡
Programming/3-DBMS
Let's work together
+49 176-2019-2523
hiteshkrsahu@gmail.com
WhatsApp
Skype
Munich 🥨, Germany 🇩🇪, EU
Playstore
Hitesh Sahu's apps on Google Play Store
Need Help?
Let's Connect
Navigation
  Home/About
  Skills
  Work/Projects
  Lab/Experiments
  Contribution
  Awards
  Art/Sketches
  Thoughts
  Contact
Links
  Sitemap
  Legal Notice
  Privacy Policy

Made with

NextJS logo

NextJS by

hitesh Sahu

| © 2026 All rights reserved.