Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 01-05-2009
Member
 
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.
Reply With Quote
  #2  
Old 01-05-2009
Member
 
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.
Reply With Quote
  #3  
Old 01-05-2009
Member
 
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?
Reply With Quote
  #4  
Old 01-05-2009
Member
 
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.
Reply With Quote
  #5  
Old 01-05-2009
Member
 
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;
};
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Dictionary with a binary tree"
Thread Thread Starter Forum Replies Last Post
What is the difference between binary tree sort and heap sort in data structure sRIPRIYA Software Development 3 04-01-2011 01:25 AM
Algorithm for counting number of nodes in a binary tree anithachacko Software Development 1 20-04-2010 01:20 PM
JAVA binary tree Daren Software Development 4 29-09-2009 12:17 AM
How to Count nodes in Binary Tree ? Harshini Software Development 4 23-04-2009 10:54 PM
Dictionary API for .NET Pratyush Software Development 3 24-02-2009 12:17 PM


All times are GMT +5.5. The time now is 10:22 PM.