Data Structures Brett Bernstein

Size: px
Start display at page:

Download "Data Structures Brett Bernstein"

Transcription

1 Data Structures Brett Bernstein Lecture 8: Iterators, Maps, and Hashtables Exercises 1. Show how to print out the elements of a doubly linked list in reverse order. 2. What are the Java API classes that correspond to dynamic arrays, doubly linked lists, and circular arrays? 3. Solve the following: (a) Give an operation where a circular array clearly outperforms an ordinary dynamic array. (b) Give an operation where a dynamic array clearly outperforms a doubly linked list. (c) Give an operation where a doubly linked list clearly outperforms both a circular array and an ordinary dynamic array. (d) Give an operation that a doubly linked list has that a singly linked list does not. 4. ( ) Famous Interview Problem: Suppose you have a head reference to a singly linked list whose last node is pointed at one of the earlier nodes in the list (instead of at null). You have no direct access to the last node of the list. Determine which node the last node is pointing at with Θ(1) memory and Θ(n) runtime. [Hint: First try to find some node of the list that is in the loop.] 5. ( ) Give an example of an operation you can perform on our doubly linked list (from the homework) that could corrupt the list. How could you fix this? [Hint: Suppose we have two lists.] Solutions 1. Using the DoublyLinkedList class from Homework 3 we could use the following code: public static void printreverse(doublylinkedlist<?> dll) for (DoublyLinkedList.Node<?> curr = dll.getlast(); curr!= dll.getsentinel(); curr = curr.getprev()) System.out.println(curr.getValue()); The Java API also has a doubly linked list called LinkedList, and we will show how to iterate through it in a moment. 1

2 2. ArrayLists are dynamic arrays, LinkedLists are doubly linked lists, and ArrayDeques are circular arrays. 3. (a) Removing the first element. Adding the first element is also usually faster. (b) Getting the ith element. (c) Deleting a node (somewhere in the middle of the list) that you have a reference to. Inserting a node before or after a node in the middle of the list that you have a reference to. (d) Remove last element. Add before a node you have a reference to (singly linked list only allows add after). Delete a node you have a reference to (singly linked list requires a reference to the node before you must delete). 4. We will break the answer into 3 parts: (a) Find a node in the loop: To do this we employ the Tortoise and the Hare strategy. Make 2 node references pointed at the first node of the list called Tortoise and Hare. Each iteration we will advance the Tortoise by 2 steps and the Hare by 1 step. When the Tortoise and the Hare cross paths again, they will both be in the loop. (b) Find the length of the loop: Once the Tortoise and the Hare meet at some node, stop the Hare and let the Tortoise keep stepping until it rejoins the Hare. Count how many steps this takes. (c) Find the node the last node points at: Start two new Tortoises at the beginning of the list. Give one Tortoise a head start that is the length of the loop. Then advance each Tortoise one step at a time. When they meet they will be at the answer. 5. Suppose we get a node from one list and then use addafter, addbefore, or removenode with it, but on the other list. This will break the size field, and can corrupt the list further. To protect against this we could store a reference to the DoublyLinkedList in the Node object. If someone tries to use a node on the wrong list, we can check this in the method and throw an exception. We will handle this in a different way in a moment using iterators. Iterators and For Each The code we have used thus far to iterate over dynamic arrays and linked lists have been very different. For linked lists we must obtain a node and keep getting the next element until we hit the end (sentinel in the doubly linked case, null in the singly linked case). For dynamic arrays we can simply loop over the indices. Furthermore, we must have access to the Node to perform the Θ(1) mid-list insertions and removals. As we saw above, this can either lead to corrupt lists, or force us to store extra information in each Node. In order to 2

3 make collection access more uniform and safer (by restricting access to the nodes), we will use iterators. An iterator is an object that acts like a fancy reference to your list. Below are the essential parts of the Iterator interface in Java: public interface Iterator<T> //Returns the next element or throws NoSuchElementException T next(); //Returns if calling next will return an element boolean hasnext(); //If supported, removes the last element returned by next default void remove() throw new UnsupportedOperationException("remove"); There is also an Iterable interface that many collections support. Here is the important part of Iterable: public interface Iterable<T> Iterator<T> iterator(); Thus any collection (such as ArrayList, LinkedList, ArrayDeque) that implements Iterable will allow the following code: for (Iterator<T> it = col.iterator(); it.hasnext();) T t = it.next(); //do stuff To make the above code even cleaner looking, Java supports the for-each loop: for (T t : col) //do stuff For convenience, you can also use an array of type T[] in the for-each loop above (or a descendent of T[]) instead of a collection implementing Iterable. This for-each notation is nice, but doesn t give you access to the iterator in case you wanted to remove a value. Lists in the Java API also have another type of iterator called a ListIterator that will let you go backwards, go forwards, add and set elements, along with knowing your current index in the list. To learn more you can lookup java.util.listiterator. Below we show a few ways to implement the reverse printing method we had earlier: import java.util.iterator; import java.util.linkedlist; import java.util.listiterator; ReversePrinting.java 3

4 public class ReversePrinting static void printforwards(linkedlist<integer> list) for (Iterator<Integer> it = list.iterator(); it.hasnext();) System.out.print(it.next()+" "); System.out.println(); static void printforwards2(linkedlist<integer> list) for (int i : list) System.out.print(i+" "); System.out.println(); static void printforwards3(linkedlist<integer> list) for (ListIterator<Integer> it = list.listiterator(); it.hasnext();) System.out.print(it.next()+" "); System.out.println(); static void printreverse(linkedlist<integer> list) //Descending iterator gets an Iterator that starts at the end and goes backwards for (Iterator<Integer> it = list.descendingiterator(); it.hasnext();) System.out.print(it.next()+" "); System.out.println(); static void printreverse2(linkedlist<integer> list) for (ListIterator<Integer> it = list.listiterator(list.size()); it.hasprevious();) System.out.print(it.previous()+" "); System.out.println(); public static void main(string[] args) LinkedList<Integer> list = new LinkedList<>(); for (int i = 0; i < 10; ++i) list.add(i); printforwards(list); printforwards2(list); printforwards3(list); printreverse(list); printreverse2(list); 4

5 Note that we construct the ListIterator at position list.size() in printreverse2. This refers to the position just after the last entry (so calling previous gets the last entry). Look at the Java API documentation for ListIterator to learn more about the indices. Iterator Exercises 1. Suppose you are using an iterator to process a list, and then mid-iteration you modify the list: for (Iterator<T> it = list.iterator(); it.hasnext();) T t = it.next(); //Modify list not using the iterator //Like list.remove or list.add it.remove(); //Removes last element returned by next from list What could go wrong? 2. Write an iterator for a doubly linked list. 3. Explain how you would use an array to implement the following interface: FloorInfo.java //Gives the company on each floor of a commercial building //It's assumed that floor numbers begin at 0 and have very few gaps. public interface FloorInfo //Assigns a company to a given floor. //If the floor already has a company, replace it. void assignfloor(int floor, String company); //Get the company assigned to the given floor. //Returns null if there is no company assigned String getcompany(int floor); You may assume the constructor will take the maximum number of floors in the building. 4. Explain how you would use an ArrayList to implement the following interface: Balances.java //Stores balances associated with each customer public interface Balances //Associates a balance with a given name //If the name already has a balance, replace it 5

6 //with the current argument. void put(string name, Double balance); //Gets the balance for the given name. Returns null //if the name isn't stored. Double getbalance(string name); What are the runtimes of your methods? Iterator Solutions 1. Since the remove method on an iterator tries to remove the last value it returned, that value may not exist any more, or other aspects of the list could have changed. We say that these list operations invalidated the iterator. To detect this iterators and collections maintain an integer, the modification count. If the list is modified through the iterator, the modification count is incremented on both the list and the iterator. If the list is changed without the iterator, only the list s modification count is changed. If you try to use the iterator and the modification counts don t match, you get a ConcurentModificationException. 2. Below we give code that would sit inside of the DoublyLinkedList class. We have left out modcounts for simplicity. We could have used non-static inner classes below, but we haven t covered that. public class DoublyLinkedList<T> implements Iterable<T> private static class Iter<S> implements Iterator<S> private DoublyLinkedList<S> list; private Node<S> node; private Node<S> lastnext; private Iter(DoublyLinkedList<S> dll) list = dll; node = list.getfirst(); public boolean hasnext() return node.next!= list.sentinel; public S next() if (!hasnext()) throw new NoSuchElementException(); lastnext = node; node = node.next; return lastnext.value; 6

7 public void remove() if (lastnext == null) throw new IllegalStateException(); list.removenode(lastnext); lastnext = null; public Iterator<T> iterator() return new Iter<T>(this); // Other stuff 3. Our solution is below: BoundedFloorInfo.java public class BoundedFloorInfo implements FloorInfo private String[] companies; public BoundedFloorInfo(int maxfloor) companies = new String[maxFloor+1]; public void assignfloor(int floor, String company) companies[floor] = company; public String getcompany(int floor) return companies[floor]; 4. Our solution is below: import java.util.arraylist; BalancesImpl.java public class BalancesImpl implements Balances private static class Entry private String name; private Double balance; private Entry(String n, Double b) 7

8 name = n; balance = b; private ArrayList<Entry> data; public BalancesImpl() data = new ArrayList<>(); // Finds an entry with the given name, or returns null otherwise private Entry getentry(string name) for (int i = 0; i < data.size(); ++i) Entry e = data.get(i); if (e.name.equals(name)) return e; return null; public void put(string name, Double balance) Entry e = getentry(name); if (e!= null) e.balance = balance; return; data.add(new Entry(name, balance)); public Double getbalance(string name) Entry e = getentry(name); if (e!= null) return e.balance; return null; Both put and getbalance both use the helper method getentry which has a Θ(n) runtime. 8

9 Maps and HashMaps Both FloorInfo and Balances have the idea of mapping some piece of information (floor number or name) to another (company name or balance). We can generalize this idea using the Map (or Dictionary) ADT: Map.java //Stores a mapping of keys to values public interface Map<K,V> //Adds key to the map with the associated value. If key already //exists, the associated value is replaced. void put(k key, V value); //Gets the value for the given key, or null if it isn't found. V get(k key); //Returns true if the key is in the map, or false otherwise. boolean containskey(k key); //Removes the key from the map void remove(k key); //Number of keys in the map int size(); Above we saw that FloorInfo has an efficient implementation using an array/arraylist, but Balances does not. This is because the keys of FloorInfo directly map to the indices of our array. What we want is a way to have the flexibility of a Map, but the efficiency of an array. Is there a common ground? This idea leads us to the hashtable data structure (called a HashMap in Java). In a hashtable we apply a function, called a hash function, that will map each key object to an index of our array. We call each entry of our array a bucket. Suppose we plan on adding 1000 keys (with associated values) to our hashtable. An ideal situation would be to have an array of 1000 buckets, and then an efficient function h that for each of these keys gives a distinct array index between 0 and 999, inclusive. This is called a perfect hash (actually a minimal perfect hash). For example, h("bob")=0, h("frank")=1, etc. While this can be done to some extent if you know all of the keys ahead of time, in general this isn t possible to do efficiently. Thus we must lower some of our expectations: 1. Our array will be larger than the full number of keys. For example, Java s default HashMap will never be more than 75% used. The number of keys stored divided by the number of buckets is called the load factor of the table. 2. We will allow our hash function to map distinct keys to the same value (this is called a collision). Hopefully the keys are well spread out amongst the available values. One requirement we must have is that if key1.equals(key2) then h(key1)==h(key2). We will discuss how to get a hash function h a bit later. For now, suppose that we have some hash function h that maps our keys to the range 0,..., N 1 where N is the size of our array. The issue we must deal with is how to handle collisions. 9

10 Collision Handling Using Chaining With chaining, each element of our table points to a linked list of nodes. Each node stores the key-value pair. Whenever we need to add a new key k to the table we simply add a new key-value pair to the head of the list pointed at from index h(k). We choose the head since clients will often access recently added keys, so placing them at the head will lead to quicker searches. Collision Handling Using Probing Here we will discuss a method of collision handling confusingly called open addressing and called closed hashing. Such a hashtable (if implemented in Java) will maintain two arrays: an array of key references, and an array of value references. Suppose we try to add an element to the table with key k. As with all hashtables, we first compute h(k). If h(k) is already occupied in the key array, we will look at the entry (h(k) + 1)%N where N is the table size. If this is occupied we continue to (h(k) + 2)%N and so forth. Eventually we will find an open slot (since we always keep the table only partially full), and put both the key and the value. The hope is that if we maintain a fairly empty table (like half full) then we wont have to look very far. To determine if a key is already in the table we start at index h(k) and must keep adding 1 until we find the key in the table, or find an empty cell. The big advantage of probing over chaining is that we access memory in a more efficient pattern since we use contiguous arrays instead of scattered linked lists. The negative is that the collision handling code is more complex, and will often need to look at more nodes than with chaining. To help address this there are other methods of probing that can lead to benefits, but we wont discuss them here (e.g., quadratic probing, double hashing, cuckoo hashing, hopscotch hashing). Hashtable Exercises 1. Suppose we have a hashtable with 10 buckets. Suppose our keys are non-negative integers, our values are Strings, and our hash function h simply takes the last digit of the number. We add the following key-value pairs, in the order given, to our dictionary (1,"A"), (2,"B"), (11,"C"), (32,"D"), (14,"E"), (99,"A") (a) Explain how the final hashtable will look if chaining is used. (b) Explain how the final hashtable will look if linear probing is used. (c) Assume chaining is used. Explain how we will get the value for the keys 2 and Recall that the load factor of a hashtable is the number of keys divided by the number of buckets. We have decided that our hash table must always have a load factor that is at most.75. Suppose we add a new key to the table that puts our load factor over 10

11 the threshold (say we added the 751st key to a table with 1000 buckets). What should be done? 3. ( ) Suppose we have a hashtable with 100 buckets and a hash function h that uniformly distributes our keys over the buckets (a desirable property for a hash function). More precisely, suppose each new key that is added is equally likely to go into any bucket, and that each key is independent. How many keys must be added till a collision is likely? Hashtable Solutions 1. (a) C 1 A 32 D 2 B E A (b) 11

12 keys values A 2 2 B 11 3 C 32 4 D 14 5 E A (c) We first apply the hash function h to the key 2 to obtain the bucket h(2) = 2. We check the first entry and see the key is 32. This doesn t match 2, so we check the next key and see it is 2. We return the value B. For 31, we first apply the hash function h and obtain the bucket h(31) = 1. We then check the first entry in the list for bucket 1 and find the key 11. This doesn t match 31, so we move to the next entry with key 1. This also doesn t match 31, so we conclude the key is not in the table. 2. Just as in the ArrayList case, we will create a new bucket table that is double the size. Unfortunately we can t just copy all the nodes over to their same positions since the hash function depends on the size of the table. Recall that a hash function takes keys and turns them into table indices; thus the hash function depends on the size of the table. The way to resolve this issue is to move each entry from the original table into the new table making sure we compute the new value of h for each key, and add the entry to the correct bucket list in the new table. 3. This problem is called the birthday paradox. For K keys and B buckets the probability of a collision is B(B 1)(B 2) (B K + 1) 1. B K Letting B = 100 we see that the first value of K where this probability is larger than.5 is 13 (where it is.557). For general B, the minimum number of keys to make a collision likely grows like Θ( B). 12

Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019

Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019 CS18 Integrated Introduction to Computer Science Fisler Homework 2: Imperative Due: 5:00 PM, Feb 15, 2019 Contents 1 Overview of Generic/Parameterized Types 2 2 Double the Fun with Doubly-Linked Lists

More information

Fall 2017 Mentoring 9: October 23, Min-Heapify This. Level order, bubbling up. Level order, bubbling down. Reverse level order, bubbling up

Fall 2017 Mentoring 9: October 23, Min-Heapify This. Level order, bubbling up. Level order, bubbling down. Reverse level order, bubbling up CSM B Heaps & Hashing Fall 0 Mentoring : October 3, 0 Min-Heapify This. In general, there are 4 ways to heapify. Which ways actually work? Level order, bubbling up Level order, bubbling down Reverse level

More information

Lecture 13: AVL Trees and Binary Heaps

Lecture 13: AVL Trees and Binary Heaps Data Structures Brett Bernstein Lecture 13: AVL Trees and Binary Heaps Review Exercises 1. ( ) Interview question: Given an array show how to shue it randomly so that any possible reordering is equally

More information

What is an Iterator? An iterator is an abstract data type that allows us to iterate through the elements of a collection one by one

What is an Iterator? An iterator is an abstract data type that allows us to iterate through the elements of a collection one by one Iterators What is an Iterator? An iterator is an abstract data type that allows us to iterate through the elements of a collection one by one 9-2 2-2 What is an Iterator? An iterator is an abstract data

More information

Section 05: Midterm Review

Section 05: Midterm Review Section 05: Midterm Review 1. Asymptotic Analysis (a) Applying definitions For each of the following, choose a c and n 0 which show f(n) O(g(n)). Explain why your values of c and n 0 work. (i) f(n) = 5000n

More information

Introducing Hashing. Chapter 21. Copyright 2012 by Pearson Education, Inc. All rights reserved

Introducing Hashing. Chapter 21. Copyright 2012 by Pearson Education, Inc. All rights reserved Introducing Hashing Chapter 21 Contents What Is Hashing? Hash Functions Computing Hash Codes Compressing a Hash Code into an Index for the Hash Table A demo of hashing (after) ARRAY insert hash index =

More information

Section 05: Solutions

Section 05: Solutions Section 05: Solutions 1. Asymptotic Analysis (a) Applying definitions For each of the following, choose a c and n 0 which show f(n) O(g(n)). Explain why your values of c and n 0 work. (i) f(n) = 5000n

More information

Section 05: Solutions

Section 05: Solutions Section 05: Solutions 1. Memory and B-Tree (a) Based on your understanding of how computers access and store memory, why might it be faster to access all the elements of an array-based queue than to access

More information

(f) Given what we know about linked lists and arrays, when would we choose to use one data structure over the other?

(f) Given what we know about linked lists and arrays, when would we choose to use one data structure over the other? CSM B Hashing & Heaps Spring 0 Week 0: March 0, 0 Motivation. (a) In the worst case, how long does it take to index into a linked list? Θ(N) (b) In the worst case, how long does it take to index into an

More information

CS231 - Spring 2017 Linked Lists. ArrayList is an implementation of List based on arrays. LinkedList is an implementation of List based on nodes.

CS231 - Spring 2017 Linked Lists. ArrayList is an implementation of List based on arrays. LinkedList is an implementation of List based on nodes. CS231 - Spring 2017 Linked Lists List o Data structure which stores a fixed-size sequential collection of elements of the same type. o We've already seen two ways that you can store data in lists in Java.

More information

CSC 172 Data Structures and Algorithms. Lecture #9 Spring 2018

CSC 172 Data Structures and Algorithms. Lecture #9 Spring 2018 CSC 172 Data Structures and Algorithms Lecture #9 Spring 2018 SINGLY LINKED LIST 3.1.3 Linked lists We will consider these for Singly linked lists Doubly linked lists Basic Singly Linked List class Node

More information

1. Suppose you are using a HashMap<String,Integer>. What is the runtime of put and get assuming you have a reasonable hash function?

1. Suppose you are using a HashMap<String,Integer>. What is the runtime of put and get assuming you have a reasonable hash function? Data Structures Brett Bernstein Lecture 10: BitSets and Packages Exercises 1. Suppose you are using a HashMap. What is the runtime of put and get assuming you have a reasonable hash function?

More information

Lists. CSC212 Lecture 8 D. Thiebaut, Fall 2014

Lists. CSC212 Lecture 8 D. Thiebaut, Fall 2014 Lists CSC212 Lecture 8 D. Thiebaut, Fall 2014 Review List = Organization of Data in a Linear Fashion, where Order is Important Set of actions that can be carried out efficiently on the data. Typical Actions

More information

COMP 250. Lecture 32. interfaces. (Comparable, Iterable & Iterator) Nov. 22/23, 2017

COMP 250. Lecture 32. interfaces. (Comparable, Iterable & Iterator) Nov. 22/23, 2017 COMP 250 Lecture 32 interfaces (Comparable, Iterable & Iterator) Nov. 22/23, 2017 1 Java Comparable interface Suppose you want to define an ordering on objects of some class. Sorted lists, binary search

More information

Implementation. Learn how to implement the List interface Understand the efficiency trade-offs between the ArrayList and LinkedList implementations

Implementation. Learn how to implement the List interface Understand the efficiency trade-offs between the ArrayList and LinkedList implementations Readings List Implementations Chapter 20.2 Objectives Learn how to implement the List interface Understand the efficiency trade-offs between the ArrayList and LinkedList implementations Additional references:

More information

MIDTERM EXAM THURSDAY MARCH

MIDTERM EXAM THURSDAY MARCH Week 6 Assignments: Program 2: is being graded Program 3: available soon and due before 10pm on Thursday 3/14 Homework 5: available soon and due before 10pm on Monday 3/4 X-Team Exercise #2: due before

More information

Introduction hashing: a technique used for storing and retrieving information as quickly as possible.

Introduction hashing: a technique used for storing and retrieving information as quickly as possible. Lecture IX: Hashing Introduction hashing: a technique used for storing and retrieving information as quickly as possible. used to perform optimal searches and is useful in implementing symbol tables. Why

More information

Dynamic Dictionaries. Operations: create insert find remove max/ min write out in sorted order. Only defined for object classes that are Comparable

Dynamic Dictionaries. Operations: create insert find remove max/ min write out in sorted order. Only defined for object classes that are Comparable Hashing Dynamic Dictionaries Operations: create insert find remove max/ min write out in sorted order Only defined for object classes that are Comparable Hash tables Operations: create insert find remove

More information

Linked List Nodes (reminder)

Linked List Nodes (reminder) Outline linked lists reminders: nodes, implementation, invariants circular linked list doubly-linked lists iterators the Java foreach statement iterator implementation the ListIterator interface Linked

More information

Points off Total off Net Score. CS 314 Final Exam Spring 2017

Points off Total off Net Score. CS 314 Final Exam Spring 2017 Points off 1 2 3 4 5 6 Total off Net Score CS 314 Final Exam Spring 2017 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 300 points.

More information

Outline. iterator review iterator implementation the Java foreach statement testing

Outline. iterator review iterator implementation the Java foreach statement testing Outline iterator review iterator implementation the Java foreach statement testing review: Iterator methods a Java iterator only provides two or three operations: E next(), which returns the next element,

More information

CS61B Lecture #24: Hashing. Last modified: Wed Oct 19 14:35: CS61B: Lecture #24 1

CS61B Lecture #24: Hashing. Last modified: Wed Oct 19 14:35: CS61B: Lecture #24 1 CS61B Lecture #24: Hashing Last modified: Wed Oct 19 14:35:49 2016 CS61B: Lecture #24 1 Back to Simple Search Linear search is OK for small data sets, bad for large. So linear search would be OK if we

More information

COMP 250. Lecture 29. interfaces. Nov. 18, 2016

COMP 250. Lecture 29. interfaces. Nov. 18, 2016 COMP 250 Lecture 29 interfaces Nov. 18, 2016 1 ADT (abstract data type) ADT s specify a set of operations, and allow us to ignore implementation details. Examples: list stack queue binary search tree priority

More information

Announcements. Submit Prelim 2 conflicts by Thursday night A6 is due Nov 7 (tomorrow!)

Announcements. Submit Prelim 2 conflicts by Thursday night A6 is due Nov 7 (tomorrow!) HASHING CS2110 Announcements 2 Submit Prelim 2 conflicts by Thursday night A6 is due Nov 7 (tomorrow!) Ideal Data Structure 3 Data Structure add(val x) get(int i) contains(val x) ArrayList 2 1 3 0!(#)!(1)!(#)

More information

CS 307 Final Spring 2010

CS 307 Final Spring 2010 Points off 1 2 3 4 5 Total off Net Score CS 307 Final Spring 2010 Name UTEID login name Instructions: 1. Please turn off your cell phones. 2. There are 5 questions on this test. 3. You have 3 hours to

More information

CSE 214 Computer Science II Searching

CSE 214 Computer Science II Searching CSE 214 Computer Science II Searching Fall 2017 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse214/sec02/ Introduction Searching in a

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Iterator 1 (part I) Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 26, 2013 Abstract These lecture notes are meant to be looked

More information

The dictionary problem

The dictionary problem 6 Hashing The dictionary problem Different approaches to the dictionary problem: previously: Structuring the set of currently stored keys: lists, trees, graphs,... structuring the complete universe of

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Iterator 1 (part I) Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 26, 2013 Abstract These lecture notes are meant to be looked

More information

Introduction. hashing performs basic operations, such as insertion, better than other ADTs we ve seen so far

Introduction. hashing performs basic operations, such as insertion, better than other ADTs we ve seen so far Chapter 5 Hashing 2 Introduction hashing performs basic operations, such as insertion, deletion, and finds in average time better than other ADTs we ve seen so far 3 Hashing a hash table is merely an hashing

More information

Lecture 16. Reading: Weiss Ch. 5 CSE 100, UCSD: LEC 16. Page 1 of 40

Lecture 16. Reading: Weiss Ch. 5 CSE 100, UCSD: LEC 16. Page 1 of 40 Lecture 16 Hashing Hash table and hash function design Hash functions for integers and strings Collision resolution strategies: linear probing, double hashing, random hashing, separate chaining Hash table

More information

Arrays. Chapter Arrays What is an Array?

Arrays. Chapter Arrays What is an Array? Chapter 8 Arrays 81 Arrays 811 What is an Array? To motivate why we might be interested in using arrays, let us implement an app that creates a collection of doubles We will keep track of the number of

More information

Standard ADTs. Lecture 19 CS2110 Summer 2009

Standard ADTs. Lecture 19 CS2110 Summer 2009 Standard ADTs Lecture 19 CS2110 Summer 2009 Past Java Collections Framework How to use a few interfaces and implementations of abstract data types: Collection List Set Iterator Comparable Comparator 2

More information

COMP 103 RECAP-TODAY. Hashing: collisions. Collisions: open hashing/buckets/chaining. Dealing with Collisions: Two approaches

COMP 103 RECAP-TODAY. Hashing: collisions. Collisions: open hashing/buckets/chaining. Dealing with Collisions: Two approaches COMP 103 2017-T1 Lecture 31 Hashing: collisions Marcus Frean, Lindsay Groves, Peter Andreae and Thomas Kuehne, VUW Lindsay Groves School of Engineering and Computer Science, Victoria University of Wellington

More information

1.00 Lecture 32. Hashing. Reading for next time: Big Java Motivation

1.00 Lecture 32. Hashing. Reading for next time: Big Java Motivation 1.00 Lecture 32 Hashing Reading for next time: Big Java 18.1-18.3 Motivation Can we search in better than O( lg n ) time, which is what a binary search tree provides? For example, the operation of a computer

More information

Dictionary. Dictionary. stores key-value pairs. Find(k) Insert(k, v) Delete(k) List O(n) O(1) O(n) Sorted Array O(log n) O(n) O(n)

Dictionary. Dictionary. stores key-value pairs. Find(k) Insert(k, v) Delete(k) List O(n) O(1) O(n) Sorted Array O(log n) O(n) O(n) Hash-Tables Introduction Dictionary Dictionary stores key-value pairs Find(k) Insert(k, v) Delete(k) List O(n) O(1) O(n) Sorted Array O(log n) O(n) O(n) Balanced BST O(log n) O(log n) O(log n) Dictionary

More information

CS 314 Midterm 2 Spring 2013

CS 314 Midterm 2 Spring 2013 Points off 1 2 3 4 5 Total off Net Score CS 314 Midterm 2 Spring 2013 Your Name Your UTEID Circle yours TA s name: Donghyuk Lixun Padmini Zihao Instructions: 1. There are 5 questions on this test. The

More information

CS 104 (Spring 2014) Final Exam 05/09/2014

CS 104 (Spring 2014) Final Exam 05/09/2014 CS 104 (Spring 2014) Final Exam 05/09/2014 G o o d L u c k Your Name, USC username, and Student ID: This exam has 8 pages and 8 questions. If yours does not, please contact us immediately. Please read

More information

CS1020 Data Structures and Algorithms I Lecture Note #15. Hashing. For efficient look-up in a table

CS1020 Data Structures and Algorithms I Lecture Note #15. Hashing. For efficient look-up in a table CS1020 Data Structures and Algorithms I Lecture Note #15 Hashing For efficient look-up in a table Objectives 1 To understand how hashing is used to accelerate table lookup 2 To study the issue of collision

More information

CS 307 Final Spring 2009

CS 307 Final Spring 2009 Points off 1 2 3 4 5 Total off Net Score CS 307 Final Spring 2009 Name UTEID login name Instructions: 1. Please turn off your cell phones. 2. There are 5 questions on this test. 3. You have 3 hours to

More information

HASH TABLES cs2420 Introduction to Algorithms and Data Structures Spring 2015

HASH TABLES cs2420 Introduction to Algorithms and Data Structures Spring 2015 HASH TABLES cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -assignment 9 is due on Monday -assignment 10 will go out on Thursday -midterm on Thursday 3 last time 4

More information

Array Based Lists. Collections

Array Based Lists. Collections Array Based Lists Reading: RS Chapter 15 1 Collections Data structures stores elements in a manner that makes it easy for a client to work with the elements Specific collections are specialized for particular

More information

CS : Data Structures

CS : Data Structures CS 600.226: Data Structures Michael Schatz Nov 11, 2016 Lecture 30: Advanced Hash Tables Assignment 9: Due Friday Nov 18 @ 10pm Remember: javac Xlint:all & checkstyle *.java & JUnit Solutions should be

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists and Iterators MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Linked Lists 2 Introduction Linked List Abstract Data Type General Implementation of the ListADT

More information

CS 314 Exam 2 Fall 2017

CS 314 Exam 2 Fall 2017 Points off 1 2 3 4 5 Total off CS 314 Exam 2 Fall 2017 Your Name Your UTEID Circle your TAs Name: Gilbert Jacob Jorge Joseph Lucas Rebecca Shelby Instructions: 1. There are 5 questions on this test. 100

More information

Java Collections Framework: Interfaces

Java Collections Framework: Interfaces Java Collections Framework: Interfaces Introduction to the Java Collections Framework (JCF) The Comparator Interface Revisited The Collection Interface The List Interface The Iterator Interface The ListIterator

More information

Data Structures and Algorithms Winter term 2016

Data Structures and Algorithms Winter term 2016 Page 0 German University in Cairo December 26, 2016 Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Wael Abouelsaadat Data Structures and Algorithms Winter term 2016 Final Exam Bar Code

More information

Topic 11 Linked Lists

Topic 11 Linked Lists Topic 11 "All the kids who did great in high school writing pong games in BASIC for their Apple II would get to college, take CompSci 101, a data structures course, and when they hit the pointers business

More information

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2

CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2 CMSC 341 Lecture 16/17 Hashing, Parts 1 & 2 Prof. John Park Based on slides from previous iterations of this course Today s Topics Overview Uses and motivations of hash tables Major concerns with hash

More information

Class 32: The Java Collections Framework

Class 32: The Java Collections Framework Introduction to Computation and Problem Solving Class 32: The Java Collections Framework Prof. Steven R. Lerman and Dr. V. Judson Harward Goals To introduce you to the data structure classes that come

More information

Model Solutions. COMP 103: Mid-term Test. 19th of August, 2016

Model Solutions. COMP 103: Mid-term Test. 19th of August, 2016 Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 45 minutes

More information

1 / 20 2 / 20 3 / 20 4 / 20 5 / 20

1 / 20 2 / 20 3 / 20 4 / 20 5 / 20 CSC 207 (17fa) Exam 2 Practice Page 1 of 12 Exam 2 Practice (November 10, 2017) This exam is closed-book, notes, and technology. Please do not open the test until the instructor says time has begun. Please

More information

AAL 217: DATA STRUCTURES

AAL 217: DATA STRUCTURES Chapter # 4: Hashing AAL 217: DATA STRUCTURES The implementation of hash tables is frequently called hashing. Hashing is a technique used for performing insertions, deletions, and finds in constant average

More information

Examination Questions Midterm 1

Examination Questions Midterm 1 CS1102s Data Structures and Algorithms 10/2/2010 Examination Questions Midterm 1 This examination question booklet has 9 pages, including this cover page, and contains 15 questions. You have 40 minutes

More information

Generics. IRS W-9 Form

Generics. IRS W-9 Form Generics IRS W-9 Form Generics Generic class and methods. BNF notation Syntax Non-parametrized class: < class declaration > ::= "class" < identifier > ["extends" < type >] ["implements" < type list >]

More information

Computer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print)

Computer Science 62. Bruce/Mawhorter Fall 16. Midterm Examination. October 5, Question Points Score TOTAL 52 SOLUTIONS. Your name (Please print) Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 SOLUTIONS Your name (Please print) 1. Suppose you are given a singly-linked

More information

Algorithms and Data Structures

Algorithms and Data Structures Lesson 4: Sets, Dictionaries and Hash Tables Luciano Bononi http://www.cs.unibo.it/~bononi/ (slide credits: these slides are a revised version of slides created by Dr. Gabriele D Angelo)

More information

CSE 143 Sp03 Final Exam Sample Solution Page 1 of 13

CSE 143 Sp03 Final Exam Sample Solution Page 1 of 13 CSE 143 Sp03 Final Exam Sample Solution Page 1 of 13 Question 1. (3 points) Java classifies exceptions as either checked or unchecked. For each of the following, indicate whether it is checked or unchecked

More information

Introduction to Hashing

Introduction to Hashing Lecture 11 Hashing Introduction to Hashing We have learned that the run-time of the most efficient search in a sorted list can be performed in order O(lg 2 n) and that the most efficient sort by key comparison

More information

Lecture 8: Iterators and More Mutation

Lecture 8: Iterators and More Mutation Integrated Introduction to Computer Science Fisler, Nelson Contents 1 Traversing Lists 1 2 Motivating Iterators 2 3 Writing an Iterator 3 4 Writing Sum with an Iterator 4 Objectives By the end of this

More information

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.

Jump Statements. The keyword break and continue are often used in repetition structures to provide additional controls. Jump Statements The keyword break and continue are often used in repetition structures to provide additional controls. break: the loop is terminated right after a break statement is executed. continue:

More information

EXAMINATIONS 2005 END-YEAR. COMP 103 Introduction to Data Structures and Algorithms

EXAMINATIONS 2005 END-YEAR. COMP 103 Introduction to Data Structures and Algorithms T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I ÎÍÏ V I C T O R I A UNIVERSITY OF WELLINGTON EXAMINATIONS 2005 END-YEAR COMP 103 Introduction to Data Structures and Algorithms Time Allowed:

More information

Data Structures and Algorithms

Data Structures and Algorithms Data Structures and Algorithms CS245-2015S-05 Abstract Data Types and Lists David Galles Department of Computer Science University of San Francisco 05-0: Abstract Data Types Recall that an Abstract Data

More information

CS165 Practice Final Exam

CS165 Practice Final Exam CS165 Practice Final Exam I, the undersigned, do hereby affirm that the work contained in this exam is solely my own, and that none of the results were achieved by cheating. This includes using automated

More information

EXAMINATIONS 2016 TRIMESTER 2

EXAMINATIONS 2016 TRIMESTER 2 T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2016 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS

More information

A linked list grows as data is added to it. In a linked list each item is packaged into a node.

A linked list grows as data is added to it. In a linked list each item is packaged into a node. Lesson 4 Data Structures What is a data structure? A data structure is a particular way of organizing data in a computer. A data structure that we have already encountered is the array. An array stores

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Introduction to Computing II Iterator 1 (part I) Marcel Turcotte School of Electrical Engineering and Computer Science Version of March 24, 2013 Abstract These lecture notes are meant to be looked

More information

+ Abstract Data Types

+ Abstract Data Types Linked Lists Abstract Data Types An Abstract Data Type (ADT) is: a set of values a set of operations Sounds familiar, right? I gave a similar definition for a data structure. Abstract Data Types Abstract

More information

DATA STRUCTURES AND ALGORITHMS

DATA STRUCTURES AND ALGORITHMS LECTURE 11 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 9-10... Hash tables ADT Stack ADT Queue ADT Deque ADT Priority Queue Hash tables Today Hash tables 1 Hash

More information

CS S-05 Abstract Data Types and Lists 1

CS S-05 Abstract Data Types and Lists 1 CS245-2016S-05 Abstract Data Types and Lists 1 05-0: Abstract Data Types Recall that an Abstract Data Type is a definition of a type based on the operations that can be performed on it. An ADT is an interface

More information

11/2/ Dynamic Data Structures & Generics. Objectives. Array-Based Data Structures: Outline. Harald Gall, Prof. Dr.

11/2/ Dynamic Data Structures & Generics. Objectives. Array-Based Data Structures: Outline. Harald Gall, Prof. Dr. 12. Dynamic Data Structures & Generics Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich http://seal.ifi.uzh.ch Objectives! Define and use an instance of ArrayList! Describe general idea

More information

csci 210: Data Structures Maps and Hash Tables

csci 210: Data Structures Maps and Hash Tables csci 210: Data Structures Maps and Hash Tables Summary Topics the Map ADT Map vs Dictionary implementation of Map: hash tables READING: GT textbook chapter 9.1 and 9.2 Map ADT A Map is an abstract data

More information

Model Solutions. COMP 103: Test April, 2013

Model Solutions. COMP 103: Test April, 2013 Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 40 minutes

More information

Algorithms in Systems Engineering ISE 172. Lecture 12. Dr. Ted Ralphs

Algorithms in Systems Engineering ISE 172. Lecture 12. Dr. Ted Ralphs Algorithms in Systems Engineering ISE 172 Lecture 12 Dr. Ted Ralphs ISE 172 Lecture 12 1 References for Today s Lecture Required reading Chapter 5 References CLRS Chapter 11 D.E. Knuth, The Art of Computer

More information

COMP 103 Introduction to Data Structures and Algorithms

COMP 103 Introduction to Data Structures and Algorithms T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:..................... EXAMINATIONS 2005 END-YEAR COMP 103 Introduction to Data

More information

Need to access each element of a list. Use index to access an element of the list. It s quadratic, while:

Need to access each element of a list. Use index to access an element of the list. It s quadratic, while: ! " # $ $ % & ' () * + (, -. /* 0 * / (1 2 3-4 1 5 6 5 ' 7 8 * / 9 : ; < 8 * /' 8 - /4 J K L M N O PQ M R S After studying this chapter you should understand the following: the role of iterators in container

More information

Recursive Objects. Singly Linked List (Part 2)

Recursive Objects. Singly Linked List (Part 2) Recursive Objects Singly Linked List (Part 2) 1 Operations at the head of the list operations at the head of the list require special handling because there is no node before the head node 2 Adding to

More information

Nested Loops. A loop can be nested inside another loop.

Nested Loops. A loop can be nested inside another loop. Nested Loops A loop can be nested inside another loop. Nested loops consist of an outer loop and one or more inner loops. Each time the outer loop is repeated, the inner loops are reentered, and started

More information

[2:3] Linked Lists, Stacks, Queues

[2:3] Linked Lists, Stacks, Queues [2:3] Linked Lists, Stacks, Queues Helpful Knowledge CS308 Abstract data structures vs concrete data types CS250 Memory management (stack) Pointers CS230 Modular Arithmetic !!!!! There s a lot of slides,

More information

CS 314 Exam 2 Spring

CS 314 Exam 2 Spring Points off 1 2 3 4 5 Total off CS 314 Exam 2 Spring 2017 Your Name Your UTEID Instructions: 1. There are 5 questions on this test. 100 points available. Scores will be scaled to 200 points. 2. You have

More information

Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList

Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList Overview of Java ArrayList, HashTable, HashMap, Hashet,LinkedList This article discusses the main classes of Java Collection API. The following figure demonstrates the Java Collection framework. Figure

More information

1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004

1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004 1.00/1.001 Introduction to Computers and Engineering Problem Solving Final / December 13, 2004 Name: Email Address: TA: Solution Section: You have 180 minutes to complete this exam. For coding questions,

More information

1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004

1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004 1.00/1.001 Introduction to Computers and Engineering Problem Solving Final / December 13, 2004 Name: Email Address: TA: Section: You have 180 minutes to complete this exam. For coding questions, you do

More information

Announcements. Container structures so far. IntSet ADT interface. Sets. Today s topic: Hashing (Ch. 10) Next topic: Graphs. Break around 11:45am

Announcements. Container structures so far. IntSet ADT interface. Sets. Today s topic: Hashing (Ch. 10) Next topic: Graphs. Break around 11:45am Announcements Today s topic: Hashing (Ch. 10) Next topic: Graphs Break around 11:45am Container structures so far Array lists O(1) access O(n) insertion/deletion (average case), better at end Linked lists

More information

DO NOT. UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N.

DO NOT. UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. CS61B Fall 2013 UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division Test #2 Solutions DO NOT P. N. Hilfinger REPRODUCE 1 Test #2 Solution 2 Problems

More information

CMSC 202H. Containers and Iterators

CMSC 202H. Containers and Iterators CMSC 202H Containers and Iterators Container Definition A container is a data structure whose purpose is to hold objects. Most languages support several ways to hold objects Arrays are compiler-supported

More information

CIT-590 Final Exam. Name: Penn Key (Not ID number): If you write a number above, you will lose 1 point

CIT-590 Final Exam. Name: Penn Key (Not ID number): If you write a number above, you will lose 1 point 1 CIT-590 Final Exam Name: Penn Key (Not ID number): If you write a number above, you will lose 1 point Instructions: You will have two hours to complete this exam. If you finish in the last 15 minutes,

More information

Chapter 5 Hashing. Introduction. Hashing. Hashing Functions. hashing performs basic operations, such as insertion,

Chapter 5 Hashing. Introduction. Hashing. Hashing Functions. hashing performs basic operations, such as insertion, Introduction Chapter 5 Hashing hashing performs basic operations, such as insertion, deletion, and finds in average time 2 Hashing a hash table is merely an of some fixed size hashing converts into locations

More information

Hashing Techniques. Material based on slides by George Bebis

Hashing Techniques. Material based on slides by George Bebis Hashing Techniques Material based on slides by George Bebis https://www.cse.unr.edu/~bebis/cs477/lect/hashing.ppt The Search Problem Find items with keys matching a given search key Given an array A, containing

More information

Announcements. Hash Functions. Hash Functions 4/17/18 HASHING

Announcements. Hash Functions. Hash Functions 4/17/18 HASHING Announcements Submit Prelim conflicts by tomorrow night A7 Due FRIDAY A8 will be released on Thursday HASHING CS110 Spring 018 Hash Functions Hash Functions 1 0 4 1 Requirements: 1) deterministic ) return

More information

Dictionaries and Hash Tables

Dictionaries and Hash Tables Dictionaries and Hash Tables Nicholas Mainardi Dipartimento di Elettronica e Informazione Politecnico di Milano nicholas.mainardi@polimi.it 14th June 2017 Dictionaries What is a dictionary? A dictionary

More information

More on Hashing: Collisions. See Chapter 20 of the text.

More on Hashing: Collisions. See Chapter 20 of the text. More on Hashing: Collisions See Chapter 20 of the text. Collisions Let's do an example -- add some people to a hash table of size 7. Name h = hash(name) h%7 Ben 66667 6 Bob 66965 3 Steven -1808493797-5

More information

Today: Finish up hashing Sorted Dictionary ADT: Binary search, divide-and-conquer Recursive function and recurrence relation

Today: Finish up hashing Sorted Dictionary ADT: Binary search, divide-and-conquer Recursive function and recurrence relation Announcements HW1 PAST DUE HW2 online: 7 questions, 60 points Nat l Inst visit Thu, ok? Last time: Continued PA1 Walk Through Dictionary ADT: Unsorted Hashing Today: Finish up hashing Sorted Dictionary

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Linked Lists 2 Introduction Linked List Abstract Data Type SinglyLinkedList ArrayList Keep in Mind Introduction:

More information

SUMMARY INTRODUCTION COLLECTIONS FRAMEWORK. Introduction Collections and iterators Linked list Array list Hash set Tree set Maps Collections framework

SUMMARY INTRODUCTION COLLECTIONS FRAMEWORK. Introduction Collections and iterators Linked list Array list Hash set Tree set Maps Collections framework SUMMARY COLLECTIONS FRAMEWORK PROGRAMMAZIONE CONCORRENTE E DISTR. Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2015 2016 Introduction Collections and

More information

Lab 5 Random numbers!

Lab 5 Random numbers! Lab 5 Random numbers! ADT:s as Programming Tools! D0010E! Lecture 13! Iterators! MasterMind Reminder: Groups must have their designs approved before any actual programming is allowed to start. Some review

More information

Data Structures Brett Bernstein. Lecture 1: Introduction and a Review/Enrichment of CS 101

Data Structures Brett Bernstein. Lecture 1: Introduction and a Review/Enrichment of CS 101 Data Structures Brett Bernstein Lecture 1: Introduction and a Review/Enrichment of CS 101 Introduction Class Information The title of this course is Data Structures, but in reality the name only tells

More information

EXAMINATIONS 2012 Trimester 1, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS

EXAMINATIONS 2012 Trimester 1, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2012 Trimester 1, MID-TERM TEST COMP103 Introduction

More information

Computer Science 62. Midterm Examination

Computer Science 62. Midterm Examination Computer Science 62 Bruce/Mawhorter Fall 16 Midterm Examination October 5, 2016 Question Points Score 1 15 2 10 3 10 4 8 5 9 TOTAL 52 Your name (Please print) 1. Suppose you are given a singly-linked list

More information

HASH TABLES.

HASH TABLES. 1 HASH TABLES http://en.wikipedia.org/wiki/hash_table 2 Hash Table A hash table (or hash map) is a data structure that maps keys (identifiers) into a certain location (bucket) A hash function changes the

More information