data-structures-and-algorithms-java

Hashtables

A data structure that implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function to compute an index, also called a hash code, into an array of buckets or slots, from which the desired value can be found.

Challenge

Implement a Hashtable Class with the following methods:

Approach & Efficiency

Big O space/time: O(1)

API

have an add function to added the value in the array

have a contain to check if the key is available or not

have a get function to get the value of index

have a hash function to return the place of key for index size

Challenge 31: Repeated Words

Write a function called repeated word that finds the first word to occur more than once in a string

Whiteboard Process

repeatedWords

Approach & Efficiency

Time & Space Complexity: O(n)

Solution

Challenge 32: Tree Intersection

Write a function called tree_intersection that takes two binary trees as parameters, Using your Hashmap implementation , return a set of values found in both trees.

Whiteboard Process

cc32

Approach & Efficiency

Time & Space Complexity: O(n)

Solution

Hashmap LEFT JOIN

LEFT JOIN , returns all records from the left (first) table and the matched records from the right (second) table. If there is no match for a specific record, you’ll get NULLs in the corresponding columns of the right table.

Challenge

Write a function that LEFT JOINs two hashmaps into a single data structure.

Approach & Efficiency

Time & Space Complexity: O(n)

Solution

cc33