TGViewer
Coding Interview Resources Coding Interview Resources @crackingthecodinginterview ยท 52.2K subscribers
Post #2952 1.2K
๐Ÿš€ 7. How do you handle collisions in a hash table?
A collision happens when two keys generate the same index.

๐Ÿ”น Example:
hash("abc") = 5
hash("xyz") = 5
Both want index 5.

๐Ÿ”น Collision Handling Techniques

1๏ธโƒฃ Chaining
Store multiple values in a linked list.
Index 5: abc โ†’ xyz

2๏ธโƒฃ Open Addressing
Find another empty slot.
Methods: Linear probing, Quadratic probing, Double hashing

๐Ÿ”น Linear Probing Example
Index occupied? Move to next slot.

๐Ÿ”น Interview Tip
Most interviewers expect Chaining and Linear probing to be explained clearly.

๐Ÿš€ 8. What is a binary tree and a binary search tree (BST)?

๐Ÿ”น Binary Tree
A tree where each node has at most 2 children.
10
/ \
5 20

๐Ÿ”น Binary Search Tree (BST)
Special binary tree where: Left < Root < Right
10
/ \
5 20

๐Ÿ”น BST Advantages
Fast searching, Sorted traversal, Efficient insert/delete

๐Ÿ”น Complexity
Operation | Average
Search | O(log n)
Insert | O(log n)
Delete | O(log n)

Worst case: O(n)

๐Ÿ”น Interview Tip
BST questions are among the most asked DSA interview topics.

๐Ÿš€ 9. How do you traverse a tree (inorder, preorder, postorder)?
Tree traversal means visiting all nodes.

๐Ÿ”น Inorder Traversal
Left โ†’ Root โ†’ Right
def inorder(root):
if root:
inorder(root.left)
print(root.val)
inorder(root.right)

โžก๏ธ Used in BST to get sorted order.

๐Ÿ”น Preorder Traversal
Root โ†’ Left โ†’ Right
Used for: Tree copying, Serialization

๐Ÿ”น Postorder Traversal
Left โ†’ Right โ†’ Root
Used for: Deletion, Bottom-up processing

๐Ÿ”น Complexity
All traversals: Time O(n), Space O(h)

๐Ÿš€ 10. What is recursion and when is it useful?
Recursion is when a function calls itself.

๐Ÿ”น Example:
def factorial(n):
if n == 0:
return 1
return n * factorial(n - 1)

๐Ÿ”น Recursive Flow
factorial(4) = 4 ร— factorial(3) = 4 ร— 3 ร— factorial(2)...

๐Ÿ”น Key Components
1. Base case
2. Recursive case

๐Ÿ”น Where Recursion is Useful
Trees, Graphs, DFS, Backtracking, Divide & Conquer

๐Ÿ”น Interview Tip
Always explain: Base condition, Stack usage, Time complexity

๐Ÿ”น Common Mistake
Missing base case causes: Stack Overflow Error

๐Ÿ”ฅ Double Tap โค๏ธ For Part-2
  • โค 5
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 โ†’