Results 1 to 5 of 5

Thread: Dictionary with a binary tree

  1. #1
    Join Date
    Jan 2009
    Posts
    150

    Dictionary with a binary tree

    I do not know too well the C programming language but I wanted to know if anyone can help me to set a dictionary with a binary tree.

    I have a text file that contains all the words in the dictionary and I wanted to know if I can insert into a binary tree. I know that normally we should have a piece of code to start but then I have no idea how do I do.

  2. #2
    Join Date
    May 2008
    Posts
    685

    Re: Dictionary with a binary tree

    Read the file with the help of fopen + fgets + fclose, and insert the data into a binary tree which is nothing other than a special linked list. I hope that helps.

  3. #3
    Join Date
    Jan 2009
    Posts
    150

    Re: Dictionary with a binary tree

    Thanks for that reply

    But I do not know how to make the binary tree. Can you show me some way may be with the help of some sample code to make the binary tree?

  4. #4
    Join Date
    May 2008
    Posts
    685

    Re: Dictionary with a binary tree

    In computer science, a binary tree is a tree data structure in which each node has at most two children. Typically the child nodes are called left and right. A binary tree is a connected acyclic graph such that the degree of each vertex is no more than 3. It can be shown that in any binary tree, there are exactly two more nodes of degree one than there are of degree three, but there can be any number of nodes of degree two.With the root thus chosen, each vertex will have a uniquely defined parent, and up to two children.

    Binary trees can be constructed from programming language primitives in several ways. Binary trees can also be stored as an implicit data structure in arrays, and if the tree is a complete binary tree, this method wastes no space.

    Source: wikipedia

    For the rest, I said: it's almost like a linked list.

  5. #5
    Join Date
    Feb 2008
    Posts
    194

    Re: Dictionary with a binary tree

    A binary tree is a tree-like structure that is rooted and in which each vertex has at most two children and each child of a vertex is designated as its left or right child

    Because binary trees have log (base 2) n layers, the average search time for a binary tree is log (base 2) n. To fill an entire binary tree, sorted, takes roughly log (base 2) n * n. First, it is necessary to have a struct, or class, defined as a node. Simple example would be:

    struct node
    {
    int key_value;
    node *left;
    node *right;
    };

Similar Threads

  1. Replies: 3
    Last Post: 04-01-2011, 01:25 AM
  2. Algorithm for counting number of nodes in a binary tree
    By anithachacko in forum Software Development
    Replies: 1
    Last Post: 20-04-2010, 01:20 PM
  3. JAVA binary tree
    By Daren in forum Software Development
    Replies: 4
    Last Post: 29-09-2009, 12:17 AM
  4. How to Count nodes in Binary Tree ?
    By Harshini in forum Software Development
    Replies: 4
    Last Post: 23-04-2009, 10:54 PM
  5. Dictionary API for .NET
    By Pratyush in forum Software Development
    Replies: 3
    Last Post: 24-02-2009, 12:17 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,125,188.03937 seconds with 17 queries