Everything2
Near Matches
Ignore Exact
Full Text
Everything2

inorder traversal

created by nbaldwin

(idea) by ariels (1.1 d) (print)   ?   (I like it!) Fri Jun 02 2000 at 10:40:54

Inorder traversal is a method for visiting all nodes of a binary tree. It's not depth-first (that would be postorder traversal), and it's not breadth-first either.

Inorder traversal visits the left subtree first (with inorder traversal, naturally), then the root, then the right subtree. The naïve implementation uses recursion; more efficient ways include various "tree threading" techniques or pointer reversal.

Note that this method applies only to binary trees, not even to trees! Every child must be either a "left child" or a "right child" of its parent, or we won't know whether to traverse it before or after its parent.

In a binary tree which is the parse tree of an arithmetical expression, in-order traversal corresponds (if brackets are added either everywhere or appropriately) to the regular infix notation.


(idea) by ClockworkGrue (8.6 mon) (print)   ?   (I like it!) Thu Aug 30 2001 at 22:25:04

Preorder Traversal | Postorder Traversal | Inorder Traversal

  1. Traverse the left subtree.
  2. Visit the root.
  3. Traverse the right subtree.
For those of us who are visual learners, the inorder traversal of a binary tree would look like this.

           C     depth = 0
          / \
         B   E   depth = 1
        /   / \
       A   D   F depth = 2

printable version
chaos

postorder traversal preorder traversal reverse Polish notation binary tree
depth-first search binary search tree Select WindowMaker
Y'know, if you log in, you can write something here, or contact authors directly on the site. Create a New User if you don't already have an account.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Things you could have written:
Multiple Sclerosis
Metaphor is not disposable
Kun and San
Just a collection of ones and zeroes
Young Virgin Auto-Sodomized by Her Own Chastity
Film noir
Brian Downing
It's always a good idea to tell people you love them if you do
George Grosz
Things inside the fort in Minnesota
How Our Bodies Are Used--and Our Minds
public sector
If you could see what your cars are made of, people, you'd shoot yourselves.
New Writeups
Meezzio
Gotlandssnus(thing)
argv
Astral Plane(idea)
Madara
One Winged Angel(fiction)
Tom Rook
Talk is cheap(poetry)
shaogo
Adelle Davis(person)
Aerobe
race car g sfjsgsd(poetry)
Binah
Dream Log: July 5, 2008(dream)
StrawberryFrog
Forgotten things in space(idea)
antigravpussy
velvet revolution fairy tale(idea)
Heitah
Nerve agent VX(thing)
Pavlovna
shite(idea)
wonton
Days and nights come together in a slow falling down(fiction)
Pavlovna
wee(idea)
katherine
root log: July 2008(log)
Madara
There’s nothing like a trail of blood to find your way back home(fiction)
This page courtesy of The Everything Development Company