Binary search tree: traverse: Difference between revisions

From Algowiki
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:


== Genaral Information ==
== Genaral Information ==
'''Algorithmic problem:''' [[Sorted sequence|Sorted sequence: traverse]]
'''Type of algorithm:''' loop
'''Auxiliary data:'''
# A [[stack]] '''''S''''' whose elements are pairs consisting of
## a natural number '''''seenChildren''''' in the range <math>\{0,1,2\}</math> and
## a binary search tree node '''''node'''''.
# Pointers '''''elem''''' and '''''elem'''''' to stack elements.


== Abstract View ==
== Abstract View ==

Revision as of 20:11, 25 September 2014


Genaral Information

Algorithmic problem: Sorted sequence: traverse

Type of algorithm: loop

Auxiliary data:

  1. A stack S whose elements are pairs consisting of
    1. a natural number seenChildren in the range [math]\displaystyle{ \{0,1,2\} }[/math] and
    2. a binary search tree node node.
  2. Pointers elem and elem' to stack elements.

Abstract View

Induction Basis

Induction Step

Complexity

Pseudocode

INORDER-TREE-WALK(x)
if x ≠ NULL
INORDER-TREE-WALK(left[x])
print key[x]
INORDER-TREE-WALK(right[x])