Binary tree search in text file entries

A

Andrew

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..
 
B

Ben Pope

Andrew said:
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.

Well, that's up to you. You've only described searching.
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.

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.
Can anyone give me some advice abt how to do it?? Thanks in advance..

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top