The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Java Help
|
Binary search tree and Array ?
Discuss Binary search tree and Array ? in the Java Help forum on Dev Shed. Binary search tree and Array ? Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 6th, 2002, 07:08 AM
|
|
Junior Member
|
|
Join Date: Mar 2002
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Binary search tree and Array ?
Hi. I am trying to write a code which will read details from a file.
Than using a binary search tree, I will check whether the search item is on the list. lets say, i read a customer file which has customer details number,name,etc
cust no:1882
Mr Smith
los Angeles
cust no: 753
Ms Miriaz
new york
my understanding is, before i can do a binary search the data has to be on an array and sorted. Then i can add this to a tree and do the search. is this correct ? if so, seaching for, say, cust no is Ok, but where do i keep the data for the other details (name ,city)? In same binary tree or a seperate one ?
Thank you
|

May 6th, 2002, 11:48 AM
|
|
Member
|
|
Join Date: Mar 2002
Location: India
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
pls mention the prog. language ur goin to use...if ur using 'c' then u can for struct datatype...similarly if ur using c++ or java u can go for 'class' for storing all the values encapsulated in a single object....
|

May 6th, 2002, 05:23 PM
|
|
Junior Member
|
|
Join Date: Mar 2002
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Just to clarify, i am programming in Java.
Thank you
|

May 6th, 2002, 05:33 PM
|
|
Junior Member
|
|
Join Date: May 2002
Posts: 0
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
..if you are using a BST the last thing you want to do is sort the data unless you are sorting it randomly... sorry if this is not your question :P
Quote: | if so, seaching for, say, cust no is Ok, but where do i keep the data for the other details (name ,city)? In same binary tree or a seperate one ? |
it depends on the BST.. if you write one that stores your data type you could throw all the data in one tree but sort by the customer number.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|