By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,543 Members | 2,037 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,543 IT Pros & Developers. It's quick & easy.

Binary tree search in text file entries

P: n/a
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..

Jan 9 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Andrew wrote:
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
--
I'm not just a number. To many, I'm known as a string...
Jan 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.