You would use the output of your tree traverse function and construct the tree next time with your corresponding constructor from same traversal order. Also you could name the nodes and list the children of each node and identify the top node (say the first one in the list). This is generally considered more practical way for trees than actual concreate linked structure (in addition of the adjacency matrix, which you also can use to save, but it is highly redundant and sparse).
Now, how can i save the binary tree onto the hard disk, and how can i rebuild it from the hard disk ?
Well, obviously you need to devise some kind of format, but the easiest method is with record ordering. You can treat serialization as an extension of copying, where a pre-order traversal is the way to go:
How does the method described by you handle the case when the binary tree is not complete
As long as the original tree is a valid binary search tree, the restored tree will be an exact copy. The down side of this method is reconstructing the tree is O(N log N) because it reuses the insert operation. There are ways around that, but it's not as concise.
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...