bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_2 / algorithms / algo_044.md

algo_044.md (520B)


      1 # algo_044
      2 
      3 ### Problem Statement
      4 
      5 > Write a non-recursive algorithm for inorder traversal of a binary tree.
      6 
      7 ## Algorithm
      8 ```
      9 procedure inorder(T)
     10 begin
     11     ptr ← T;
     12     flag ← 1;
     13     while (flag) do
     14         while (ptr ≠ NULL) do
     15             push(stack, ptr);
     16             ptr ← LC(ptr);
     17         endwhile
     18         if (!isEmpty(stack)) then
     19             ptr ← pop(stack);
     20             write(INFO(ptr));
     21             ptr ← RC(ptr);
     22         else
     23             flag ← 0;
     24         endif
     25     endwhile
     26 end procedure
     27 ```
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror