Quote:
What language? Are you allowed to use the sorting library of that language?
Sorry, c++, we can use anything available as long as we keep the main data structure the AVL tree (our own version). So, I can add members to my AVL class. And, it is OK to use any temp data structure.
Quote:
Are the sort fields fixed, or can the user change them between queries to the tree?
If I understand you correctly, the user makes a query and a sub-tree is returned, but not printed yet (or, maybe report that x number of records have been found). The user then decides which fields to display and which field is the primary sort field and which field is the secondary sort field. The results are printed. The user then can choose to edit a record or search the sub-tree to narrow the results further, or start over. A search on the sub-tree may produce another sub-tree. Then, again, the user chooses which fields to print and which to sort by. As long as there are records in the sub-tree, the user can repeat the process. So, the sort fields are not fixed, yeah?
Quote:
I'd keep this simple. Read the tree into a vector, sort it by the user-chosen fields and print it out. When a user updates a record, update it in the AVL tree only, throw away the vector when you're done.
I've been thinking about this idea as well. I'm having a hard time visualizing how, when a record in the vector is updated, that is reflected in the tree as well. Also, if I go this route I'm going to need to define 15 different sorting functions to handle all the cases. Seems like there should be a better way. I'm just worried that better way is over my head.