#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0

    Unhappy 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
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    India
    Posts
    7
    Rep 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....
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    0
    Rep Power
    0
    Just to clarify, i am programming in Java.

    Thank you
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2002
    Posts
    0
    Rep 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

    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.

IMN logo majestic logo threadwatch logo seochat tools logo