1 / 21

Data Structures and Algorithms

Data Structures and Algorithms. Semester Project – Fall 2010 Faizan Kazi Comparison of Binary Search Tree and custom Hash Tree data structures. Project Description. This project uses: Hash + Tree structures Tree Structures Efficient Searching and Sorting and Shuffling

Download Presentation

Data Structures and Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Structures and Algorithms Semester Project – Fall 2010 FaizanKazi Comparison of Binary Search Tree and custom Hash Tree data structures

  2. Project Description • This project uses: • Hash + Tree structures • Tree Structures • Efficient Searching and Sorting and Shuffling • Speech and manual search to locate terms • It is based on Microsoft’s .Net Framework 4 • The code was written in C# on Visual Studio 2010

  3. Goal • Prove that Tree and Hash Structures are efficient • Use Speech for searching

  4. Issues Encountered • Inserting data into the two data structures • Shuffling sorted Data • Speech API provided by Microsoft is subject to restrictions

  5. Hash Tree • One of the problems with Hash Structures • Collisions • Solution: • Chaining • Embed Binary Search Trees into each Key Value Pair. All Colliding Elements can be inserted into a BST. Retrieval: O(1) best case , O(log(n)) worst case Insertion: O(1) best case , O(log(n)) worst case

  6. Binary Search Tree • Does not allow duplicate items Retrieval: O(log(n)) average case Insertion: O(log(n)) average case

  7. Shuffling – Page 1 • Problem: all dictionary words being inserted into the data structures were sorted! • This will make the Tree linear: O(n) Example: try inserting a,b,c,d into a tree

  8. Shuffling – Page 2 • Initial Solution: do a recursive insert into the binary search tree by calculating the optimal node and left and right child strings from the string array. • Problem: this will produce a near optimal tree but could be at a disadvantage to the hash tree. Eg: 1 2 3 4 5 6 7 Root = 4, LC = 2, RC = 6

  9. Shuffling – Page 3 • Solution: Fisher-Yates shuffle • For a count of 0 to N, choose random indexes into the string array and swap the items • This is O(n) and produces a good mix. • The fact is, O(n) is completely under our control, and does not have to depend on the size of the data. If you want a very small shuffle, run the technique n/4 times. If you want to make sure it is extremely shuffled call it 2n times.

  10. The Demo Program • The Demo program is written in C# (most similar to Java) and designed to run on the Microsoft .Net Framework 4 (you may have to download this or it may ask you if it can automatically download it). • It will demonstrate, through manual, random or speech directed searching just how efficient these data structures are.

  11. The Demo Program – Step 1 Click “Next” to begin

  12. Step 2 – Initializating Data Structures Select the list, modify the selected size, and click “Go!”

  13. Step 3 – Test Configuration Select the Number of iterations for each search term (small numbers will probably give you 0 millisecond results, they’re that fast!

  14. Step 4 – Search Method 1 – Manual Type a word from the list into the search box and click “Search!”

  15. Step 4 – Search Method 2 – Random Click “Random”

  16. Step 4 – Search Method 3 – Voice Just select a word from the list and say “Search (word)” for example, “Search action”. Troubleshooting: Make sure that Microsoft’s Speech engine is running on your pc. There should be a speech icon in the taskbar or at the top of your screen (once your click “Go!”). Check to make sure it is “On” and not in “Sleep Mode” or “Off”. Make sure your laptop’s built in mic works, or that your mic is properly plugged in. Access Recording Devices from the Volume Control in the taskbar to check if your mic works and is enabled.

  17. Step 5 – Search Results Search results show up on the lower right and speech results show up on the top right

  18. Step 6 – Data Structure Visualization Check out the graphical representations of the HashTree and BSTree. Check out the difference in depths

  19. Hash Tree Visualization Every index in the Hash Table has its own Binary Search Tree

  20. Binary Search Tree Visualization Somewhere down there The Binary Search Tree has one root, and for every node, one left and one right child

  21. Conclusion • That’s it! • I hope you find the program useful and informative about these two datastructures. • If you have any questions you may contact me at: • +92-300-254-1119 • faizan@faizan-kazi.com

More Related