Connecting Tech Pros Worldwide Help | Site Map

Binary tree search in text file entries

Andrew
Guest
 
Posts: n/a
#1: Jan 9 '06
Hi, im trying to create a small function which can create a binary tree
from the entries in a text file and after that we can perform all the
usual operations like search, insert and delete etc. Now i have entries
something like this

IPaddress Phone No
192.168.2.1 2223447689
192.168.2.2 3334449898
192.168.2.3 5667869089

Now a user gives a tuple like 192.168.2.2 3334449898 and the function
algortithm performs the binary search and returns the result (Found/not
found). I need to resolve two issues here

1. the criteria to instert a new tuple (IP Ph no) in to the binary
tree.
2.How to read the data from the text file, whether to read them all in
to the memory or there are some other method of performing the binary
search from the file itself . I dont know.

Can anyone give me some advice abt how to do it?? Thanks in advance..

Ben Pope
Guest
 
Posts: n/a
#2: Jan 9 '06

re: Binary tree search in text file entries


Andrew wrote:[color=blue]
> Hi, im trying to create a small function which can create a binary tree
> from the entries in a text file and after that we can perform all the
> usual operations like search, insert and delete etc. Now i have entries
> something like this
>
> IPaddress Phone No
> 192.168.2.1 2223447689
> 192.168.2.2 3334449898
> 192.168.2.3 5667869089
>
> Now a user gives a tuple like 192.168.2.2 3334449898 and the function
> algortithm performs the binary search and returns the result (Found/not
> found). I need to resolve two issues here
>
> 1. the criteria to instert a new tuple (IP Ph no) in to the binary
> tree.[/color]

Well, that's up to you. You've only described searching.
[color=blue]
> 2.How to read the data from the text file, whether to read them all in
> to the memory or there are some other method of performing the binary
> search from the file itself . I dont know.[/color]

Not unless you have some "meta data" about the file. You could store a
table somewhere in the file that in some way summarises what you have in
the file, and a "pointer" to the full data. For most homework, I would
suspect this is unnecessary, unless explicitly stated.
[color=blue]
> Can anyone give me some advice abt how to do it?? Thanks in advance..[/color]

I'm not really sure what you require.

Since your search is on the whole data and the result is either found or
not, this doesn't sound like a very interesting problem. Are you sure
you need to search for both bits of data and return only true / found?

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Closed Thread


Similar C / C++ bytes