Compare and Contrast Hash Map to Binary Search Tree.
Memory, Time Efficiency for Operations for Retrieving Singular Values, Maintaining relationships between data.
Please be sure to use your own words.
To begin with definition, HashMap is a datastructure for storing key value pairs while Binary Search Tree is used for saving data in ordered manner. HashMap uses hashtable for storing data while Binary Search Tree uses a Binary Tree to store the data.
Memory:
Hashmap - O(n) as hashtable will be atmost of size 2*n.
Binary Search Tree - O(n) as For every data point we have single node and every node takes constant space so order of n.
Retreiving Singular Values/Search:
Hashmap - O(1) Asumming reasonably good hash function is used we can assume that search can be done in constant time.
Binary Search Tree - O(log n). Assuming BST is balanced we can retrieve values in atmost log n time.
Maintaining relationships between data:
Hashmap natively provides support for storing key value pairs i.e. related data.
For BST we need to implement custom node class and define their comparator to be able to maintain relationship between data while maintaining BST structure.
Compare and Contrast Hash Map to Binary Search Tree. Memory, Time Efficiency for Operations for Retrieving Singular Valu...
JAVA DATA STRUCTURES: Reading a Text file of words into two different data structures 1. Use a Binary search tree and then 2.Use a Hash Map. *USE BOTH BINARY & HASH MAP* * Get the file name as a user input.* Present a menu to the user with the below options: 1) Delete the first occurrence of a given word. 2) Delete all the occurrences of a given word.
Question 23 Not yet graded /0 pts Given a Binary Search Tree that is populated with numerical data, write an algorithm that will determine the sum, average, least and greatest of the values maintained in the tree. Express your algorithm in Java-like pseudodode. You may use any of the operations supported by the Binary Search Tree implementation used for Programming Project #5. Your solution must be developed at the application level. Your Answer For the next two questions you must...
Short answer in your own word: 1. Describe the role of a “Back-End” computer engineer in creating software. Give examples of decisions back end engineers make. Use the relationship between long-term and short-term memory as context for decision examples. 2. Identify Stack or Heap storage in RAM. a) Hash Map with static array as underlying storage b) Doubly Linked LIst - Stack Implementation c) Binary Search Tree with 10,000 Nodes d) Static Array - Stack Implementation c) Doubly Linked List...
In C++ Given a pointer to the root of a binary search tree (has left, right, and parent pointers as well as a data section ) write a function (or functions) which will return an STL list (you should not define this class, it’s already included) with all of the values from the tree in sorted order. Your code should run in theta(N) time. for the second part,.given a pointer to the first node of a linked list, you are...
Using C Please comment Part 1: BST Create a link based Binary Search tree composed of a Node and a Tree struct. You should have a header file, BST.h, with the following: o Node struct containing left, right, and parent pointers, in addition to holding an Data struct value Tree struct containing a pointer to the root of the tree A function declaration for a function that allocates a tree, and initializes the root to NULL o o o A...
8:08 33. Examine the following binary search tree and answer the question. The numbers on the circles labels so that we can talk about the nodes, they are NOT values in the key members of the binary tree. (a). If an item is to be inserted into the tree whose key data member is less than the key data member in node 1 but greater than the key data member in node 5, where would it be inserted? (b) If...
Binary Tree Template Write your own version of a class template that will create a binary tree that can hold values of any data type. Demonstrate the class with a driver program. Place your binary tree template in it's own header file, Btree.h. Include methods for the following: inserting new values into the tree removing nodes from the tree searching the tree returning the number of nodes in the tree displaying the contents of the tree using preorder traversal Your...
I need help in C++ implementing binary search tree. I have the .h file for the binary search tree class. I have 4 classic texts, and 2 different dictionaries. Classic Texts: Alice In Wonderland.txt A Tale of Two Cities.txt Pride And Prejudice.txt War and Peace.txt 2 different dictionaries: Dictionary.txt Dictionary-brit.txt The data structures from the standard template library can not be used.The main program should open the text file, read in the words, remove the punctuation and change all the...
(20 points) Suppose you are given a binary search tree T of n nodes (as discussed in class. each node v has v.left, v.right, and v.key). We assume that no two keys in T are equal. Given a value x, the rank operation rank() is to return the rank of x in T, which is defined to be one plus the number of keys of T smaller than 2. For example, if T has 3 keys smaller than r, then...
I will rate your answers so please make sure the answers are accurate. Please answer the following questions with fully explanations: 1) Of the following, which has the most impact on the efficiency of searching for an item in a hash table? a) the number of non-key fields b) the size of the table c) the density of the table d) whether the size of the table is a prime number e) the difficulty of computing the inverse of the...