TGViewer
Coding Interview Resources Coding Interview Resources @crackingthecodinginterview · 52.2K subscribers
Post #2766 1.51K
✅ Coding Interview Questions with Answers Part-2 🧠💻

11. What is a hash table? How hashing works
A hash table stores key-value pairs. It uses a hash function to map keys to an index.
• Key goes into hash function
• Hash function returns index
• Value stores at that index
Why interviewers like it:
• Average lookup time is O(1)
• Used in caching and indexing
Real examples:
• Python dict
• Java HashMap

12. What are collisions in hashing? How to handle them
Collision happens when two keys map to the same index.
Common handling methods:
• Chaining: Each index holds a linked list
• Open addressing: Find next empty slot
Types of open addressing:
• Linear probing
• Quadratic probing
• Double hashing
Interview tip:
• Chaining is easier to explain
• Worst case becomes O(n)

13. Difference between HashMap and HashSet
HashMap:
• Stores key and value
• Keys are unique
• Values duplicate allowed
HashSet:
• Stores only keys
• No duplicates
• Internally uses HashMap
Use cases:
• HashMap for lookup with data
• HashSet for uniqueness checks

14. What is a binary tree
A binary tree is a tree where each node has at most two children: left child and right child.
Common types:
• Full binary tree
• Complete binary tree
• Perfect binary tree
Uses:
• Hierarchical data
• Expression trees

15. What is a binary search tree
A binary search tree follows ordering rules.
Rules:
• Left child < root
• Right child > root
Operations:
• Search, insert, delete in O(log n) average
• Worst case O(n) if unbalanced
Interview focus:
• Inorder traversal gives sorted output

16. Difference between BFS and DFS
BFS:
• Level by level
• Uses queue
• Finds shortest path
DFS:
• Goes deep first
• Uses stack or recursion
• Uses less memory
When to use:
• BFS for shortest path
• DFS for traversal problems

17. What is a balanced tree
A balanced tree keeps height minimal.
Why it matters:
• Operations stay O(log n)
• Prevents skewed structure
Examples:
• AVL tree
• Red-Black tree
Interview note:
• Balance improves performance

18. What is heap data structure
Heap is a complete binary tree. It follows heap property.
Properties:
• Complete tree
• Parent follows order rule
Common use:
• Priority queues
• Scheduling tasks
Time complexity:
• Insert and delete take O(log n)

19. Difference between min heap and max heap
Min heap:
• Root holds smallest value
• Used when smallest priority wins
Max heap:
• Root holds largest value
• Used when highest priority wins
Example:
• Job scheduling
• Top K problems

20. What is a graph? Directed vs undirected
Graph contains nodes and edges.
Directed graph:
• Edges have direction
• One-way relationship
Undirected graph:
• No direction
• Two-way relationship
Real examples:
• Directed: Twitter follow
• Undirected: Facebook friends

Double Tap ♥️ For Part-3
  • ❤ 10
More from @crackingthecodinginterview
  1. Oct 8, 2026🎓 𝗠𝗶𝗰𝗿𝗼𝘀𝗼𝗳𝘁 𝗙𝗥𝗘𝗘 𝗖𝗼𝘂𝗿𝘀𝗲𝘀 𝘄𝗶𝘁𝗵 𝗖𝗲𝗿𝘁𝗶𝗳𝗶𝗰𝗮𝘁𝗲𝘀! 🚀🔥 Upgr…
  2. Oct 7, 2026🚀 DSA Topics Every Programmer Should Know 💻🔥 📦 1. Arrays ✔ Traversal ✔ Searching ✔ Sor…
  3. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  4. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  5. Sep 29, 2026✅ Daily Coding Habits That Make You a Better Developer 🧠💻✨ 1️⃣ Code Every Day (Even 30 M…
  6. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →