I have a bit of a problem! I need to insert keys from a text input file (string tokens) into a red-black tree, however, I don't know how many keys there will be in the input file. I was thinking of creating an array of node objects to hold things such as (element_key, colour, parent, left_branch, right_branch) but I don't know how many objects to create in order to hold all of the keys.
I have attached a sample input file (the keys will be plucked right out of the file).
Is there any way that I can read through the file and determine how many tokens, and hence how many objects will need to be created?
Question
asmit
I have a bit of a problem! I need to insert keys from a text input file (string tokens) into a red-black tree, however, I don't know how many keys there will be in the input file. I was thinking of creating an array of node objects to hold things such as (element_key, colour, parent, left_branch, right_branch) but I don't know how many objects to create in order to hold all of the keys.
I have attached a sample input file (the keys will be plucked right out of the file).
Is there any way that I can read through the file and determine how many tokens, and hence how many objects will need to be created?
BTW: The assignment has to be written in Java
Thanks!
Link to comment
Share on other sites
8 answers to this question
Recommended Posts