binary tree but iterative, not recursive!

This is a discussion on binary tree but iterative, not recursive! within the C Programming forums, part of the General Programming Boards category; I realise that a binary tree is by definition a recursive data structure but I would like to do it ...

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    74

    binary tree but iterative, not recursive!

    I realise that a binary tree is by definition a recursive data structure but I would like to do it iteratively. Well at least Insert, Search and Delete. Has anybody done this?

    I did it in Pascal but I am having trouble converting the code into C.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,832
    As in

    while ( p ) p = p->left;

    and variations on ->left and ->right for traversing the tree.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    74
    Yes, that's it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 0
    Last Post: 11-04-2006, 11:07 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  3. Tutorial review
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 03-22-2004, 09:40 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. BST/Red and Black Tree
    By ghettoman in forum C++ Programming
    Replies: 0
    Last Post: 10-24-2001, 11:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21