PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

DSA · Theory

Searching in BST

← All stacks

Theory

89/810

Searching in BST

Don’t start Searching in BST with jargon. Start with folder on disk. That is the whole point.

For Searching in BST, Big-O is in play. Don’t blame it until you have traced folder on disk.

Without Searching in BST, a file explorer gets messy and folder on disk is hard to trust.

Neha ships Searching in BST in a file explorer. That is the use case worth saying.

Don’t do this with Searching in BST — unbalanced BST becoming a list. Interviewers spot it in ten seconds.

After Searching in BST, Neha should still remember unbalanced BST becoming a list.

Close Searching in BST with — “If I skip it, folder on disk goes wrong like this: unbalanced BST becoming a list.”

Diagram
      8
     / \
    3   10
   / \
  1   6
Exam tip

Say Searching in BST in one breath, then left < root < right, then unbalanced BST becoming a list.

Example

class Node:
    def __init__(self, val):
        self.val = val
        self.left = None
        self.right = None

def insert(root, val):
    if root is None:
        return Node(val)
    if val < root.val:
        root.left = insert(root.left, val)
    elif val > root.val:
        root.right = insert(root.right, val)
    return root

root = None
for v in [5, 2, 7, 1]:
    root = insert(root, v)
print(root.val, root.left.val, root.right.val)

Searching in BST — bST invariant: left < node < right — enables log-time search when balanced.

Short notes

  • DefSearching in BST — Neha uses it for folder on disk in a file explorer.
  • RuleSearching in BST → left < root < right.
  • RememberSearching in BST + Big-O (a file explorer).
  • UseSearching in BST in a file explorer (folder on disk).
  • TrapSearching in BST — unbalanced BST becoming a list.
  • ExSearching in BST → folder on disk.

Questions

1

In one breath: what does Searching in BST do for Neha?

2

If you skip Searching in BST, what breaks in a file explorer?

3

How do you catch unbalanced BST becoming a list?

4

Write the smallest Searching in BST step on folder on disk. What happens?

Previous← Post-order TraversalNextInsertion in BST →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.