You have learned about Tree data structure. Now, you will be guessing that there are various tree available, what is the benefit of one on other, which tree is fast on the given data set. Well, this project will answer all of your confusions. We will be talking about the three famous trees:
- Binary Search Tree (BST)
- AVl Tree
- Btree
Just compile everything using javac *.java
. Now run the file TreeProfiler.java.
As you can see there are two modes, I ma going to explain both don't worry mate. If you are worrying about entering some invalid data or choosing invalid option, then, my code will help you. I have done Exception handling to a very far extent.
In this mode you can control the program flow, get what you need whenever you need. I am using BST by default in the interactive mode, but you can change it easily in the code. Interactive mode looks like this:
As the name says, if you want to built a tree you have to use this option. This further gives you two more options:
Stock data means the data inside the data.txt file. This data actually reflects an account data and is in this format:
Ticker, Date, Open, High, Low, Close and Volume
If you want to play with the input data, you have to change the AccountData.java file and data reading code in TreeProfiler.java
Lets say you have loaded a tree and made some changes into the tree, afterwards you saved the tree. If you want to use that saved tree you can use this option.
If you want to find a specific key in the tree, you can make use of this option. Isn't this all trees about ? Save, retrieve huh ?
Want to insert a new value in the tree? Well you can using this option.
Let's check whether the value got inserted or not. It's inserted!
Want to delete that unwanted node, go with this option.
Check whether "ABC123" got deleted or program is messing with us. Well, it's deleted !
Here comes the main feature, you want to know how good your tree performed? and want to save the result in a text file for later contrast and comparison?
- How much time it took to build the tree?
- What is the size of you tree?
- What is the height of your tree?
- How much percent your tree is balanced?
Wait no more... Just want to remind that as we are using BST in interactive mode, which is an unbalanced tree. Hence, the balance % will be 0.
This is how BST_stats.txt
After making some great changes to the tree, you want to save it for later use. Well, you have this option also. The tree object will be saved as a serialized object.
Mastered Tree data structure in java and want to quit? This option is for you then.
In this mode you can compare the performance of a tree automatically, results will be stored in a text file for comparison if user wants. You have to specify the input data filename and tree type as a command line argument.
Similarly, you can compare the performance by using different tree and data structure. The "AVL_stats.txt" will look like this:
I would like to thank my teacher Sir Nadeem Ghafoor Chuadhary, for every impact he had in my life, let it be "Programming", "Ideological", "Personal" many more.