Binary Search Trees

This is a discussion on Binary Search Trees within the C Programming forums, part of the General Programming Boards category; Hey, Can anyone help me create a binary search tree with the C language. I am quite new to this ...

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

    Binary Search Trees

    Hey,

    Can anyone help me create a binary search tree with the C language. I am quite new to this language and am finding it difficult to create functions : how to create a binary tree and insert a new node in the tree.

    thanks in advance for your help

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,801
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    29

    Talking I'm having a go at this.

    Quote Originally Posted by lorannex View Post
    Hey,

    Can anyone help me create a binary search tree with the C language. I am quite new to this language and am finding it difficult to create functions : how to create a binary tree and insert a new node in the tree.

    thanks in advance for your help
    I think that what you want to do is think like a tree-pruner (as in a real "Tree"). who wants to keep the tree intact, but get rid of the excess shrub around the outside. Start with thee leaves, then the branches, and well, in a binary tree, once a leaf is cut off the next node up is, guess what, a leaf! Don't cut off anything that is still a branch, wait until it becomes a leaf. So if you have nodes a, b, and c, where b and c are leaves of a, and you have leaf d who branches from node b, then you can either start by deleting c, or d, but not b before d, and of course a should be last. Got it?

    - Edward



    "When am I gonna start getting paid for this?"

  4. #4
    Registered User
    Join Date
    Apr 2009
    Posts
    2
    I understood the concept but my problem is how to implement such concept in actual code (C language) which works hehe....all examples over d net explain in detail but i did not find a piece of code which actually creates and inserts...

    thanks for your reply ..i really appreciate

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with binary search.
    By StateofMind in forum C Programming
    Replies: 6
    Last Post: 05-06-2009, 02:14 PM
  2. Performance issue!
    By maven in forum C Programming
    Replies: 42
    Last Post: 03-23-2009, 11:57 AM
  3. Binary Trees
    By wvu2005 in forum C Programming
    Replies: 7
    Last Post: 10-15-2005, 04:59 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM

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