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

AI · Theory

Greedy Best-First Search

← All stacks

Theory

85/215

Greedy Best-First Search

Greedy best-first expands the node that looks closest to the goal (smallest h only). Fast, not guaranteed optimal. Can walk into a dead alley. A* adds g so you don’t ignore cost already paid.

Greedy Best-First Search — output — three exam lines. Graph on paper first.

Diagram
start
    ├── BFS  queue
    ├── DFS  stack
    └── A*   g+h
    │
    ▼
   goal
Exam tip

Greedy vs A*: h vs g+h.

Example

# Greedy Best-First Search
print("draw 6 nodes")
print("name the DS: queue / stack / priority")
print("say if the path is optimal")

Greedy Best-First Search — output: three exam lines. Graph on paper first.

Short notes

  • DefUses only h(n). Not always optimal.

Questions

1

Explain Greedy Best-First Search as if you are teaching a junior — definition, then one example.

2

What does the example print, and what does that prove?

3

What mistake do freshers make with Greedy Best-First Search?

Previous← Companies Working on Artificial IntelligenceNextFuture Ideas →
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.