Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Prompt Engineering  ›  Capstone Project

Chain of Thought and Tree of Thought

Chain of Thought (CoT) 15 minChain of thought has the model write intermediate steps before answering, and tree of thought explores and prunes several candidate paths, both trading extra tokens for better reasoning.

Chain of Thought and Tree of Thought

Asha asks: "Two sleeper tickets are ₹1,180 each, plus a ₹35 booking fee per ticket. Is that under my ₹2,500 limit?" Answering in one breath, a model might say "Yes, ₹2,360" and forget the fees. Given room to work it through, it gets ₹2,430 — still yes, but now for the right reason. How a model is allowed to think changes what it gets right.

The rule

Let the model think in steps — one line of steps, or several branches compared.

Chain of thought (CoT) asks the model to write out intermediate reasoning before the final answer. Because the model produces one token at a time, the steps it has already written become part of its context, so later steps build on them instead of leaping:

Tickets: 2 × ₹1,180 = ₹2,360
Fees:    2 × ₹35    = ₹70
Total:   ₹2,360 + ₹70 = ₹2,430
₹2,430 ≤ ₹2,500 → within budget, ₹70 to spare.

You can trigger this with an instruction ("work through the calculation step by step, then give the answer on the last line") or with examples that show worked steps. Some models, often called reasoning models, are trained to do this kind of thinking on their own before answering.

Tree of thought (ToT) goes further for problems with several possible routes. Instead of one chain, it:

  1. Branches — proposes a few different partial approaches.
  2. Evaluates — scores each one against the goal.
  3. Prunes and expands — drops weak branches and develops the promising ones.

It is usually built as a loop in your program, calling the model several times, rather than as a single prompt.

The shortcut

Match the method to the shape of the problem. One path with several steps → chain. Several paths worth comparing → tree. A simple lookup → neither; extra thinking there only adds tokens and delay.

Tree of thought for getting to JaipurStep 1 of 4
  1. Branch

    Three ideas: a direct train Thursday night; Pune to Mumbai, then an overnight train; a bus to Ahmedabad, then a train.

The trap is paying for deep reasoning everywhere. Chains and trees make answers longer, slower and costlier. Use them where a wrong quick answer is likely; skip them for "what is the weather in Jaipur?".

Drills

Answer fast — trust the rule.

quick drill

Why does chain-of-thought prompting often improve multi-step answers?

quick drill

Which task best suits tree of thought?

quick drill

Three tickets cost ₹700 each with a ₹40 fee per ticket. What total should a careful chain reach?

quick drill

What is the main cost of using chain of thought on every request?

Remember

  • Let the model think in steps: a chain for one path, a tree for several paths to compare.
  • Shortcut: one path → chain; many paths → tree; a lookup → neither.
  • Trap: paying for deep reasoning on simple questions.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainChain, tree or neither?

For each Tripmate request, say whether you would use chain of thought, tree of thought or neither, and explain why: (a) "What's the weather in Jaipur tomorrow?" (b) "Is 3 tickets at 950 rupees plus a 5% fee under 3,000?" (c) "Plan the best route to visit Jaipur, Udaipur and Jodhpur in five days."