COMP 103 Course Review. 2 Menu  A final word on hash collisions in Open Addressing / Probing  Course Summary  What we have covered  What you should.

Slides:



Advertisements
Similar presentations
Lecture 22, Revision 1 Lecture notes Java code – CodeFromLectures folder* Example class sheets – 4 of these plus solutions Extra examples (quicksort) Lab.
Advertisements

Hashing as a Dictionary Implementation
© 2004 Goodrich, Tamassia Hash Tables1  
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Carrano and Henry, © 2013.
Log Files. O(n) Data Structure Exercises 16.1.
Review. What to know You are responsible for all material covered in lecture, the readings, or the programming assignments There will also be some questions.
© 2006 Pearson Addison-Wesley. All rights reserved13 A-1 Chapter 13 Hash Tables.
Review for Test 2 i206 Fall 2010 John Chuang. 2 Topics  Operating System and Memory Hierarchy  Algorithm analysis and Big-O Notation  Data structures.
Course Review COMP171 Spring Hashing / Slide 2 Elementary Data Structures * Linked lists n Types: singular, doubly, circular n Operations: insert,
Introducing Hashing Chapter 21 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
© 2006 Pearson Addison-Wesley. All rights reserved13 B-1 Chapter 13 (excerpts) Advanced Implementation of Tables CS102 Sections 51 and 52 Marc Smith and.
Hash Tables. Container of elements where each element has an associated key Each key is mapped to a value that determines the table cell where element.
Hash Tables. Container of elements where each element has an associated key Each key is mapped to a value that determines the table cell where element.
(c) University of Washingtonhashing-1 CSC 143 Java Hashing Set Implementation via Hashing.
ICS220 – Data Structures and Algorithms Lecture 10 Dr. Ken Cosh.
1 Hash Tables  a hash table is an array of size Tsize  has index positions 0.. Tsize-1  two types of hash tables  open hash table  array element type.
CSCA48 Course Summary.
COMP 103 Priority Queues, Partially Ordered Trees and Heaps.
Final Review Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Information and Computer Sciences University of Hawaii, Manoa
Final Review Dr. Yingwu Zhu. Goals Use appropriate data structures to solve real- world problems –E.g., use stack to implement non-recursive BST traversal,
Hashing Chapter 20. Hash Table A hash table is a data structure that allows fast find, insert, and delete operations (most of the time). The simplest.
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.
COMP 103 Hashing 2014-T2 Lecture 32 Marcus Frean School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay.
Can’t provide fast insertion/removal and fast lookup at the same time Vectors, Linked Lists, Stack, Queues, Deques 4 Data Structures - CSCI 102 Copyright.
COMP 103 Hashing. 2 RECAP-TODAY RECAP Bitmaps are a fast way to implement Sets of integers, characters, etc TODAY  Hashing is a similar idea  Detecting.
HASHING PROJECT 1. SEARCHING DATA STRUCTURES Consider a set of data with N data items stored in some data structure We must be able to insert, delete.
Hashing as a Dictionary Implementation Chapter 19.
Final Exam Review CS Total Points – 60 Points Writing Programs – 50 Points Tracing Algorithms, determining results, and drawing pictures – 50.
LECTURE 35: COLLISIONS CSC 212 – Data Structures.
Chapter 11 Hash Tables © John Urrutia 2014, All Rights Reserved1.
“Never doubt that a small group of thoughtful, committed people can change the world. Indeed, it is the only thing that ever has.” – Margaret Meade Thought.
Java Methods Big-O Analysis of Algorithms Object-Oriented Programming
Hash Table March COP 3502, UCF 1. Outline Hash Table: – Motivation – Direct Access Table – Hash Table Solutions for Collision Problem: – Open.
COSC 2007 Data Structures II Chapter 13 Advanced Implementation of Tables IV.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Tirgul 11 Notes Hash tables –reminder –examples –some new material.
COMP 103 Hashing (II), and exam tips 2014-T2 Lecture 33 Marcus Frean School of Engineering and Computer Science, Victoria University of Wellington  Marcus.
Hashtables. An Abstract data type that supports the following operations: –Insert –Find –Remove Search trees can be used for the same operations but require.
Hashing 1 Hashing. Hashing 2 Hashing … * Again, a (dynamic) set of elements in which we do ‘search’, ‘insert’, and ‘delete’ n Linear ones: lists, stacks,
Hash Tables © Rick Mercer.  Outline  Discuss what a hash method does  translates a string key into an integer  Discuss a few strategies for implementing.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
ISOM MIS 215 Module 5 – Binary Trees. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
2014-T2 Lecture 29 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae and Thomas.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
1 i206: Lecture 12: Hash Tables (Dictionaries); Intro to Recursion Marti Hearst Spring 2012.
Dictionaries and Their Implementations Chapter 18 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Hash Tables ADT Data Dictionary, with two operations – Insert an item, – Search for (and retrieve) an item How should we implement a data dictionary? –
COMP 103 wrapping up and some exam tips 2015-T2 Lecture 32 Marcus Frean School of Engineering and Computer Science, Victoria University of Wellington 
Searching Tables Table: sequence of (key,information) pairs (key,information) pair is a record key uniquely identifies information, so no duplicate records.
 Saturday, April 20, 8:30-11:00am in B9201  Similar in style to written midterm exam  May include (a little) coding on paper  About 1.5 times as long.
Final Exam Review CS Total Points – 20 Points Writing Programs – 65 Points Tracing Algorithms, determining results, and drawing pictures – 50.
2015-T2 Lecture 28 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae and Thomas.
Chapter 11 (Lafore’s Book) Hash Tables Hwajung Lee.
Prof. Amr Goneid, AUC1 CSCI 210 Data Structures and Algorithms Prof. Amr Goneid AUC Part 5. Dictionaries(2): Hash Tables.
COMP 103 Exam Tips. 2 The Exam (Example) answer all questions manage your time Dumb calculators & non- electronic dictionaries are OK.
Final Exam Review CS 3358.
COMP 103 Hashing Marcus Frean 2015-T2 Lecture 31
COMP 103 Sorting with Binary Trees: Tree sort, Heap sort Alex Potanin
More complexity analysis & Binary Search
Dictionaries 9/14/ :35 AM Hash Tables   4
CS302 Data Structures Fall 2012.
CSE373: Data Structures & Algorithms Lecture 14: Hash Collisions
Chapter 21 Hashing: Implementing Dictionaries and Sets
CSE373: Data Structures & Algorithms Lecture 14: Hash Collisions
Searching Tables Table: sequence of (key,information) pairs
Final Review Dr. Yingwu Zhu.
EE 312 Final Exam Review.
Instructor: Dr. Michael Geiger Spring 2019 Lecture 34: Exam 3 Preview
Presentation transcript:

COMP 103 Course Review

2 Menu  A final word on hash collisions in Open Addressing / Probing  Course Summary  What we have covered  What you should have learnt  The exam  Structure, emphasis, how to do well!

3 Quadratic Probing  Make the sequence of probes have increasing steps:  runs don’t join up so fast h, h+1, h+4, h+9, h+16, … p=h, p+=1, p+=3, p+=5, p+= 7, p+= 9, ….  In general, quadratic probing uses a quadratic formula: probe i = hash + a  i + b  i 2 ( b  0)  Eg: with a=b=½, the step sizes become 1,2,3… instead of 1,3,5… “ eel ”“ kea ”“ ant ”“ cat ”“ fox ”“ dog ”“ hen ”“ bee ”“ owl ”

4 Hash Table with Probing: remove  Inserted: Stu (2) Sven (5) Sam (4) Steve (2) Sun (4)  Now remove: Sam (4)  What’s the problem?  contains(Sun) will return false!  To remove, need to leave a marker (not null, not a value !) public void remove() { throw new UnsupportedOperationException(); } SamSteveStigStuSvenSun insert a "tombstone" key instead

5 Iterator  Iterating through hash table is not simple:  there will be nulls to skip over  the order that items are returned appears random (and may change when the array is doubled!)  At each call to next(), Iterator must advance the index to the next non-null cell. “ eel ”“ kea ”“ ant ”“ cat ”“ bee ”“ fox ”“ dog ”

6 Other Probing Techniques  Quadratic probing:  Step sizes 1,2,3…  still suffers from “secondary clustering”  Double hashing:  use a second hash function, to compute next probe index: p = hash2(value, p);  less clustering, but more expensive  Cuckoo hashing...  Use two hash functions.  Try both indexes.  If both are full, kick out one of the values, and put it in its alternate place (kicking out a value if necessary,….) the new hash depends on the value as well (unlike with probing)

7 Course Summary  Different kinds of Collections:  Lists, Sets, Bags, Maps, Stacks, Queues, Priority Queues, Trees, Graphs  What are their properties?  When are they appropriate?  Using collections  Using generic types: List drawing = new ArrayList ();  Programming with collections Choosing appropriate collection types for applications Writing code that uses collections

8 Course Summary  Implementing collections  arrays, linked lists, BSTs, POTs/heaps, bitsets, hash tables  sorted vs unsorted  iterators, comparators  linear search vs binary search  hashing: chaining (buckets) vs open addressing (probing)  Understanding different ways of representing collections  Basic algorithms for accessing and updating different kinds of structures  How the data structure affects the costs of operations

9  Sorting algorithms  Slow sorts: insertion, selection  Fast sorts: mergesort, quicksort, treesort, heapsort  Cost of algorithms  Big-O (asymptotic cost)  Simple loops, nested loops, recursion, and traversal  Measuring performance Course Summary

10 Course Summary  Trees of several different kinds:  Trees for tree-structured data Binary trees vs general trees  Trees for efficient linear collections: BSTs, POTs/heaps  Algorithms on trees:  Constructing & traversing trees Depth first (pre-, in-, post-order) vs Breadth First Recursive vs Iterative  search, add, and remove in BST’s  add, and remove in POT’s/heaps

11 The Exam (Example) answer all questions 180 minutes for 180 marks Calculators & non-electronic dictionaries are OK

12 The Exam  Read the question carefully and make sure you know what is being asked.  Write your answer clearly!  Use extra pages for rough work or for answers  Cross out what you don’t want marked  Say where your answer is if not on same page!  For coding questions:  There’s more than one way...  If it’s complicated, start with the pseudocode  DON’T PANIC!!!

13 The Exam  There is a link on the 103 homepage to this:   “Assessment archive”  Do your best without the answers  Then check against the answers