Amortized Analysis. Ric Glassey
|
|
- Bridget Wilkinson
- 5 years ago
- Views:
Transcription
1 Amortized Analysis Ric Glassey
2 Overview Amortized Analysis Aim: Develop methods of determining the average cost of operations on a data structure Motivation: We do not always want to think about the worst case scenario, rather what the average or amortized cost of an operations is Key concepts: Amortized Cost Aggregate Analysis Accounting Method Demonstration: insertion into dynamic table 2
3 AMORTIZED COST 3
4 Best to think in terms of money... If you receive 1024kr per month You spend 256kr per month on small things You invest the 768kr left in a savings account Eventually you spend 9216kr on something big The amortized cost is only 1024kr per month Not the worst case single month costing (9216kr) But this is not Financial Management 101 We can use this concept to think about the average time costs of (small and big) operations on data structures 4
5 DYNAMIC TABLES 5
6 Using Dynamic Tables How big should we make a hashtable? We do not know how many entries are required We want to allocate enough space to ensure good performance More space will ensure less hashing collisions Remember we hash then compress to within table size We do not have infinite resources We should aim to maintain a healthy load factor What should happen as load factor approaches 1? table size = N and entries = n load factor is α = n/n 6
7 Dynamic Table in Operation Create a new table of size 1 insert(1) into table Overflow on insert(2) insert(1) 1 insert(2)? 7
8 Dynamic Table in Operation copy 1 insert(1) insert(2) 1 overflow 1 2 insert 2 On insert(2) an overflow occurs, no space. Create a new table twice the size, copy 1 into new table, insert 2 into empty space What now happens if we try to insert(3)? 8
9 Dynamic Table in Operation copy 1,2 insert(1) insert(2) insert(3) 1 2 overflow insert On insert(3) an overflow occurs, no space. Create a new table twice the size, copy 1,2 into new table, insert 3 into empty space How many opera?ons just took place? What now happens if we try to insert(4)? 9
10 Dynamic Table in Operation insert(1) insert(2) insert(3) insert(4) insert 4 On insert(4) there is an available slot, so no overflow occurs. No further opera?ons required How many opera?ons just occurred? What now happens if we try to insert(5)? 10
11 Dynamic Table in Operation copy 1,2,3,4 insert(1) insert(2) insert(3) insert(4) insert(5) overflow insert 5 On insert(5) there was overflow Once again, double the space in the table, copy old values into new table, insert 5 How many opera?ons just occurred? What now happens if we try to insert(6) or insert(7) or insert(8)? 11
12 Dynamic Table in Operation insert(1) insert(2) insert(3) insert(4) insert(5) insert(6) insert(7) insert(8) insert(9) ? As we can see, things are improving, we are gejng more done, with less resizing What happens on insert(9)? How many insert opera?ons before the next table resize? 12
13 Worst Case Analysis of Dynamic Table As we noticed, the worst case insertion caused a table resize, copying all entries, and inserting the new item O(n) For a sequence of n operations, the worst case time will be n. O(n) = O(n 2 ) However... We observed something about the progress of the operation cost and the distance between table doubling 13
14 AGGREGATE ANALYSIS 14
15 Aggregate Analysis We consider T(n) to be the total cost for a sequence of n operations Average cost will simply be T(n)/n We say that the average cost is the amortized cost of each operation All operations have the same amortized cost Think about: why having the same cost for all operations might not be so useful in all contexts? 15
16 Counting the costs table resize event Insertion Op (i) Size of Table In the sequence of opera?ons, there were only 4 table resize events Whilst there were 10 insert operabons Let s assume it costs 1 unit of Bme to insert an item (with no resize) Also, it costs 1 unit of Bme to copy an item from the old table to the new And the cost of alloca?ng the new table in memory comes for free :- ) 16
17 Counting the costs table resize event Insertion Op (i) Size of Table Cost of all Ops (c) avg( ) < 10^2 For each insert opera?on, we can count up all the operabon costs No?ce where we take a hit, and where we do not As a sanity check, we can show that so far, we are no where near O(n 2 ) for cost 17
18 Counting the costs Insertion Op (i) Size of Table Cost of insert (c) Cost of Copy We rarely double the double, only when i-1 is a power of 2 sum of n insertions + sum of [[which]] series? Finally, if we separate the raw inser?on costs from the resize costs, a parern emerges 18
19 Average cost Worst case cost was O(n 2 ), but this cannot hold Total cost c i is in fact much better, n c i n + i=1 lg(n 1) j=0 2 j <n+2n =Θ(n) Therefore, the amortized cost per operation is constant Θ(n)/n =Θ(1) 19
20 ACCOUNTING METHOD 20
21 Accounting Method We imagine that each operation on a data structure can incur a financial cost (nkr) Different operations can cost different amounts Determined by a process of trial and error Overcharge for some operations It only costs 1Kr to insert, but we charge 3Kr anyway This overcharging occurs early in sequence The remaining 2Kr will accrue in credit Whenever a more expensive operation happens, it can draw from this credit Key invariant - we cannot go into debt! 21
22 Counting the cost (II) For our dynamic table, we have the cost model To insert, we charge amortised cost of 3Kr 1Kr of that pays for the insertion 2Kr is stored as credit, when we need to pay for table resize When table is resized 1Kr is charged to move a recent item inserted 1Kr is charged to copy an old item already inserted Invariant: credit 0 In the back of your mind keep asking: why 3Kr? 22
23 Counting the cost (II) Initial state, empty, or just after a resize operation Here, there are 4 items, and we think of them as 0Kr Kr insert( item 5) will charge amortized cost 3Kr It costs 1Kr to insert The left over 2Kr are 'deposited as credit' credit = 2Kr 23
24 Counting the cost (II) Each insertion operation adds to the credit Kr insert (item 5), charge 3Kr, only pay 1Kr, save 2Kr credit = 2Kr Kr 2Kr insert (item 6), charge 3Kr, only pay 1Kr, save 2Kr credit = 4Kr Kr 2Kr 2Kr insert (item 7), charge 3Kr, only pay 1Kr, save 2Kr credit = 6Kr Kr 2Kr 2Kr 2Kr insert (item 8), charge 3Kr, only pay 1Kr, save 2Kr credit = 8Kr 24
25 Counting the cost (II) insert(item 9) causes overflow and requires table resize Kr 2Kr 2Kr 2Kr / Kr 2Kr 2Kr 2Kr We have 8Kr and 8 items at cost 1Kr to be copied insert (item 9), charge 3Kr, only pay 1Kr, save 2Kr credit = 2Kr Kr 25
26 Counting the cost (II) Insertion Op (i) Size of Table Cost of insert (c) Cost of Copy Amortised Cost (ĉi) 2* In the Bank (ci) pay from credit for the resize start building credit we can observe that the amortised cost will be 3n, as long as sum(ĉi) sum(ci) 26
27 Average Cost As shown, the invariant credit 0 is held Amortised cost (ĉ i ) of 3n creates an upper bound on the true cost (c i ): n i=1 ĉ i n i=1 c i For n operations, we find a constant 3n/n Θ(3n/n) =Θ(1) 27
28 Comparison of Aggregate and Accounting Aggregate analysis is intuitive It lacks the precision of accounting method We are only considering single types of operations in the sequences (shown earlier) Accounting method provides more precision, and allows different operations to have specific costs associated with them It relies on good knowledge of the data structure behaviour Initial costs must be determined by trial and error 28
29 Challenge We did not discuss deletion from the dynamic table, which may have different costs We want to maintain a healthy load factor, and also not waste too much memory with unfilled slots What is a good strategy for table contraction? Don t change it (memory is cheap) Divide it in 2 when α = n/n =.5 Something else? 29
30 Readings Introduction to Algorithms, 3 rd Edition Chapter 17: Amortized Analysis Full text available via KTH Library KTH:KTH_SFX Or, watch a great lecture from one of the authors recorded at MIT and part of their opencourseware: 30
31 Feedback! This week, I will mostly be asking about: Topic detail throughout course (P1 to P3) Improvements Tipjar Survey will appear at this link Also on the course web page after this lecture 31
Introduction to Algorithms
Introduction to Algorithms 6.046J/8.40J/SMA5503 Lecture 4 Prof. Charles E. Leiserson How large should a hash table be? Goal: Make the table as small as possible, but large enough so that it won t overflow
More informationDynamic tables. Amortized Analysis. Example of a dynamic table. Example of a dynamic table. CS Spring 2008
CS 56 -- Spring 008 Amortized Analysis Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk CS 56 Analysis of Algorithms Dynamic tables Task: Store a dynamic set in a table/array.
More informationCS583 Lecture 12. Previously. Jana Kosecka. Amortized/Accounting Analysis Disjoint Sets. Dynamic Programming Greedy Algorithms
CS583 Lecture 12 Jana Kosecka Amortized/Accounting Analysis Disjoint Sets Dynamic Programming Greedy Algorithms Slight digression Amortized analysis Disjoint sets Previously 1 Amortized Analysis Amortized
More informationAnnouncements. Problem Set 3 is due this Tuesday! Midterm graded and will be returned on Friday during tutorial (average 60%)
CSC263 Week 7 Announcements Problem Set 3 is due this Tuesday! Midterm graded and will be returned on Friday during tutorial (average 60%) Amortized Analysis O"en, we perform sequences of opera.ons on
More informationGraduate Analysis of Algorithms Prof. Karen Daniels
UMass Lowell Computer Science 9.503 Graduate Analysis of Algorithms Prof. Karen Daniels Fall, 203 Lecture 3 Monday, 9/23/3 Amortized Analysis Stack (computational geometry application) Dynamic Table Binary
More informationCMPS 2200 Fall Amortized Analysis. Carola Wenk. Slides courtesy of Charles Leiserson with changes by Carola Wenk
CMPS 2200 Fall 2017 Amortized Analysis Carola Wenk Slides courtesy of Charles Leiserson with changes by Carola Wenk 11/15/17 CMPS 2200 Intro. to Algorithms 1 Dynamic tables Task: Store a dynamic set in
More informationDATA STRUCTURES. amortized analysis binomial heaps Fibonacci heaps union-find. Lecture slides by Kevin Wayne. Last updated on Apr 8, :13 AM
DATA STRUCTURES amortized analysis binomial heaps Fibonacci heaps union-find Lecture slides by Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos Last updated on Apr 8, 2013 6:13 AM Data structures
More informationHash Table. Ric Glassey
Hash Table Ric Glassey glassey@kth.se Overview Hash Table Aim: Describe the map abstract data type with efficient insertion, deletion and search operations Motivation: List data structures are divided
More informationCSE373: Data Structures & Algorithms Lecture 12: Amortized Analysis and Memory Locality. Linda Shapiro Winter 2015
CSE373: Data Structures & Algorithms Lecture 12: Amortized Analysis and Memory Locality Linda Shapiro Winter 2015 Announcements Winter 2015 CSE 373 Data structures and Algorithms 2 Amortized Analysis In
More informationAmortized Analysis. Prof. Clarkson Fall Today s music: : "Money, Money, Money" by ABBA
Amortized Analysis Prof. Clarkson Fall 2015 Today s music: : "Money, Money, Money" by ABBA Review Current topic: Reasoning about performance Efficiency Big Oh Today: Alternative notions of efficiency Amortized
More informationCSE373: Data Structures & Algorithms Lecture 12: Amortized Analysis and Memory Locality. Lauren Milne Spring 2015
CSE373: Data Structures & Algorithms Lecture 12: Amortized Analysis and Memory Locality Lauren Milne Spring 2015 Announcements Homework 3 due on Wednesday at 11pm Catie back Monday Spring 2015 CSE 373
More informationCSE 373: Data Structures and Algorithms
CSE 373: Data Structures and Algorithms Lecture 6: Finishing Amortized Analysis; Dictionaries ADT; Introduction to Hash Tables Instructor: Lilian de Greef Quarter: Summer 2017 Today: Finish up Amortized
More informationCOP 4531 Complexity & Analysis of Data Structures & Algorithms
COP 4531 Complexity & Analysis of Data Structures & Algorithms Amortized Analysis Thanks to the text authors who contributed to these slides What is amortized analysis? Analyze a sequence of operations
More informationAmortized Analysis. A Simple Analysis. An Amortized Analysis. Incrementing Binary Numbers. A Simple Analysis
Amortized Analysis The problem domains vary widely, so this approach is not tied to any single data structure The goal is to guarantee the average performance of each operation in the worst case Three
More informationAmortized Analysis. Andreas Klappenecker. [partially based on the slides of Prof. Welch]
Amortized Analysis Andreas Klappenecker [partially based on the slides of Prof. Welch] 1 People who analyze algorithms have double happiness. First of all they experience the sheer beauty of elegant mathematical
More informationGraduate Algorithms CS F-12 Amortized Analysis
Graduate Algorithms CS673-2016F-12 Amortized Analysis David Galles Department of Computer Science University of San Francisco 12-0: Amortized Analysis Standard Stack Push(S,elem) Pop(S) How much time for
More informationCS:3330 (22c:31) Algorithms
What s an Algorithm? CS:3330 (22c:31) Algorithms Introduction Computer Science is about problem solving using computers. Software is a solution to some problems. Algorithm is a design inside a software.
More informationHash Tables. Reading: Cormen et al, Sections 11.1 and 11.2
COMP3600/6466 Algorithms 2018 Lecture 10 1 Hash Tables Reading: Cormen et al, Sections 11.1 and 11.2 Many applications require a dynamic set that supports only the dictionary operations Insert, Search
More informationActivity 13: Amortized Analysis
Activity 3: Amortized Analysis Model : Incrementing a binary counter 5 4 3 2 9 8 7 6 5 4 3 2 2 3 4 5 Model shows a binary counter, stored as an array of bits with the 2 i place stored at index i, undergoing
More informationLet the dynamic table support the operations TABLE-INSERT and TABLE-DELETE It is convenient to use the load factor ( )
17.4 Dynamic tables Let us now study the problem of dynamically expanding and contracting a table We show that the amortized cost of insertion/ deletion is only (1) Though the actual cost of an operation
More informationLecture Summary CSC 263H. August 5, 2016
Lecture Summary CSC 263H August 5, 2016 This document is a very brief overview of what we did in each lecture, it is by no means a replacement for attending lecture or doing the readings. 1. Week 1 2.
More informationCS240 Fall Mike Lam, Professor. Dynamic Arrays
CS240 Fall 2014 Mike Lam, Professor Dynamic Arrays Computer Memory Lowest level: sequence of bytes Each byte has a 32-bit or 64-bit address Every byte is equally easy to access "Random access" memory 0x
More informationLecture 11 Unbounded Arrays
Lecture 11 Unbounded Arrays 15-122: Principles of Imperative Computation (Spring 2018) Rob Simmons, Frank Pfenning Arrays have efficient O(1) access to elements given an index, but their size is set at
More informationAlgorithms 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 informationCS Prof. Clarkson Fall 2014
CS 3110 Lecture 25: Amortized Analysis Prof. Clarkson Fall 2014 Today s music: "Money, Money, Money" by ABBA "Mo Money Mo Problems" by The Notorious B.I.G. "Material Girl" by Madonna Review Current topic:
More informationCOMP251: Amortized Analysis
COMP251: Amortized Analysis Jérôme Waldispühl School of Computer Science McGill University Based on (Cormen et al., 2009) Overview Analyze a sequence of operations on a data structure. We will talk about
More informationBank to Bank Transfers User Guide
Bank to Bank Transfers User Guide GETTING STARTED Bank to Bank Transfers allow you to transfer money between your Kansas State Bank accounts and up to two external accounts (accounts at other financial
More informationIntroduction. Introduction: Multi-Pop Stack Example. Multi-Pop Stack Cost (clever) Multi-Pop Stack Cost (naïve)
Introduction Today we begin studying how to calculate the total time of a sequence of operations as a whole. (As opposed to each operation individually.) Why and when we care: You have an algorithm that
More informationFall 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 informationToday we begin studying how to calculate the total time of a sequence of operations as a whole. (As opposed to each operation individually.
Introduction Today we begin studying how to calculate the total time of a sequence of operations as a whole. (As opposed to each operation individually.) Why and when we care: You have an algorithm that
More informationCS2 Algorithms and Data Structures Note 4
CS2 Algorithms and Data Structures Note 4 Hash Tables In this lecture, we will introduce a particularly efficient data structure for the Dictionary ADT. 4.1 Dictionaries A Dictionary stores key element
More informationFast Lookup: Hash tables
CSE 100: HASHING Operations: Find (key based look up) Insert Delete Fast Lookup: Hash tables Consider the 2-sum problem: Given an unsorted array of N integers, find all pairs of elements that sum to a
More informationUnion-Find and Amortization
Design and Analysis of Algorithms February 20, 2015 Massachusetts Institute of Technology 6.046J/18.410J Profs. Erik Demaine, Srini Devadas and Nancy Lynch Recitation 3 Union-Find and Amortization 1 Introduction
More informationCMSC 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 information1 / 22. Inf 2B: Hash Tables. Lecture 4 of ADS thread. Kyriakos Kalorkoti. School of Informatics University of Edinburgh
1 / 22 Inf 2B: Hash Tables Lecture 4 of ADS thread Kyriakos Kalorkoti School of Informatics University of Edinburgh 2 / 22 Dictionaries A Dictionary stores key element pairs, called items. Several elements
More informationCS F-12 Amortized Analysis 1
CS673-2016F-12 Amortized Analysis 1 12-0: Amortized Analysis Standard Stack Push(S,elem) Pop(S) How much time for each operation? 12-1: Amortized Analysis Standard Stack Push(S,elem)O(1) Pop(S)O(1) Multipop(S,k)
More informationAmortization Analysis
December 21, 2011 Amortization Analysis The concept of amortized runtime analysis is usually first encountered when studying the efficiency of the resizing operation for an array or vector, such as in
More informationWe don t have much time, so we don t teach them [students]; we acquaint them with things that they can learn. Charles E. Leiserson
Homework 3 CS 321 - Data Structures Fall 2018 Dec 6, 2018 Name: Collaborators: We don t have much time, so we don t teach them [students]; we acquaint them with things that they can learn. Charles E. Leiserson
More informationLecture 16: HashTables 10:00 AM, Mar 2, 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Lecture 16: HashTables 10:00 AM, Mar 2, 2018 Contents 1 Speeding up Lookup 1 2 Hashtables 2 2.1 Java HashMaps.......................................
More information1 Static-to-Dynamic Transformations
You re older than you ve ever been and now you re even older And now you re even older And now you re even older You re older than you ve ever been and now you re even older And now you re older still
More informationHow many leaves on the decision tree? There are n! leaves, because every permutation appears at least once.
Chapter 8. Sorting in Linear Time Types of Sort Algorithms The only operation that may be used to gain order information about a sequence is comparison of pairs of elements. Quick Sort -- comparison-based
More informationCSE 548: (Design and) Analysis of Algorithms
Intro Aggregate Charging Potential Table resizing Disjoint sets 1 / 33 CSE 548: (Design and) Analysis of Algorithms Amortized Analysis R. Sekar Intro Aggregate Charging Potential Table resizing Disjoint
More informationLecture 8 13 March, 2012
6.851: Advanced Data Structures Spring 2012 Prof. Erik Demaine Lecture 8 13 March, 2012 1 From Last Lectures... In the previous lecture, we discussed the External Memory and Cache Oblivious memory models.
More informationMake $400 Daily. With Only. 5 Minutes Of Work
Make $400 Daily With Only 5 Minutes Of Work Hello friends, I am not a professional copywriter, so you will find a lot of mistakes and lack of professional touch in this e-book. But I have not made this
More informationToday s Outline. CS 561, Lecture 18. Potential Method. Pseudocode. Dynamic Tables. Jared Saia University of New Mexico
Today s Outline CS 561, Lecture 18 Jared Saia University of New Mexico Dynamic Tables 1 Pseudocode Potential Method Table-Insert(T,x){ if (T.size == 0){allocate T with 1 slot;t.size=1} if (T.num == T.size){
More informationLecture 17. Improving open-addressing hashing. Brent s method. Ordered hashing CSE 100, UCSD: LEC 17. Page 1 of 19
Lecture 7 Improving open-addressing hashing Brent s method Ordered hashing Page of 9 Improving open addressing hashing Recall the average case unsuccessful and successful find time costs for common openaddressing
More informationCSE373: Data Structures & Algorithms Lecture 9: Priority Queues. Aaron Bauer Winter 2014
CSE373: Data Structures & Algorithms Lecture 9: Priority Queues Aaron Bauer Winter 2014 Midterm On Wednesday, in class Closed book Closed note Closed electronic devices Closed classmate Covers everything
More informationCSCI Analysis of Algorithms I
CSCI 305 - Analysis of Algorithms I 04 June 2018 Filip Jagodzinski Computer Science Western Washington University Announcements Remainder of the term 04 June : lecture 05 June : lecture 06 June : lecture,
More informationlecture23: Hash Tables
lecture23: Largely based on slides by Cinda Heeren CS 225 UIUC 18th July, 2013 Announcements mp6.1 extra credit due tomorrow tonight (7/19) lab avl due tonight mp6 due Monday (7/22) Hash tables A hash
More informationHashing. Hashing Procedures
Hashing Hashing Procedures Let us denote the set of all possible key values (i.e., the universe of keys) used in a dictionary application by U. Suppose an application requires a dictionary in which elements
More informationProblem Set 4. Problem 4-1. [35 points] Hash Functions and Load
Introduction to Algorithms: 6.006 Massachusetts Institute of Technology 7 October, 2011 Professors Erik Demaine and Srini Devadas Problem Set 4 Problem Set 4 Both theory and programming questions are due
More informationLecture Notes on Interfaces
Lecture Notes on Interfaces 15-122: Principles of Imperative Computation Frank Pfenning Lecture 14 October 16, 2012 1 Introduction The notion of an interface to an implementation of an abstract data type
More informationYou must include this cover sheet. Either type up the assignment using theory4.tex, or print out this PDF.
15-122 Assignment 4 Page 1 of 12 15-122 : Principles of Imperative Computation Fall 2012 Assignment 4 (Theory Part) Due: Thursday, October 18, 2012 at the beginning of lecture Name: Andrew ID: Recitation:
More informationWhen you first login to CountAbout you will be on the Transactions tab (Figure 1). This is where you will spend most of your time on the website.
Table of Contents Overview... Page 1 ACCOUNTS (Add, Edit, Delete, Hide)... Page 2 CATEGORIES (Add, Edit, Delete, Hide)... Page 4 Transactions tab... Page 6 Widgets... Page 8 Budgets tab... Page 10 Reports
More informationAlgorithms I Dr Robert Harle. CST Paper I (IA NST CS, PPS CS and CST) Easter 2009/10
Algorithms I Dr Robert Harle CST Paper I (IA NST CS, PPS CS and CST) Easter 2009/10 Algorithms I This course was developed by Dr Frank Stajano, who is on sabbatical this year I'm the substitute teacher
More informationCSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)
Name: Email address: Quiz Section: CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will
More informationCS 372: Computational Geometry Lecture 3 Line Segment Intersection
CS 372: Computational Geometry Lecture 3 Line Segment Intersection Antoine Vigneron King Abdullah University of Science and Technology September 9, 2012 Antoine Vigneron (KAUST) CS 372 Lecture 3 September
More informationCSE 373: AVL trees. Michael Lee Friday, Jan 19, 2018
CSE 373: AVL trees Michael Lee Friday, Jan 19, 2018 1 Warmup Warmup: What is an invariant? What are the AVL tree invariants, exactly? Discuss with your neighbor. 2 AVL Trees: Invariants Core idea: add
More informationLecture 11: Perfect Hashing
Lecture 11: Perfect Hashing COSC242: Algorithms and Data Structures Brendan McCane Department of Computer Science, University of Otago Hashing Review The point of hashing is to get fast (O(1) on average)
More informationStandard 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 informationCSE 373 NOVEMBER 8 TH COMPARISON SORTS
CSE 373 NOVEMBER 8 TH COMPARISON SORTS ASSORTED MINUTIAE Bug in Project 3 files--reuploaded at midnight on Monday Project 2 scores Canvas groups is garbage updated tonight Extra credit P1 done and feedback
More informationCOMP 161 Lecture Notes 16 Analyzing Search and Sort
COMP 161 Lecture Notes 16 Analyzing Search and Sort In these notes we analyze search and sort. Counting Operations When we analyze the complexity of procedures we re determine the order of the number of
More informationCMSC 341 Hashing (Continued) Based on slides from previous iterations of this course
CMSC 341 Hashing (Continued) Based on slides from previous iterations of this course Today s Topics Review Uses and motivations of hash tables Major concerns with hash tables Properties Hash function Hash
More informationOutline for Today. Analyzing data structures over the long term. Why could we construct them in time O(n)? A simple and elegant queue implementation.
Amortized Analysis Outline for Today Amortized Analysis Analyzing data structures over the long term. Cartesian Trees Revisited Why could we construct them in time O(n)? The Two-Stack Queue A simple and
More informationIntroduction 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 informationIMPORTANT WORDS AND WHAT THEY MEAN
MOBILE PHONES WHAT IS DATA Data is Internet. It can let you do lots of different things on your phone or tablet. You can send or receive texts, emails or photos, listen to music, watch TV shows, movies
More information: Principles of Imperative Computation. Summer Assignment 4. Due: Monday, June 11, 2012 in class
15-122 Assignment 4 Page 1 of 8 15-122 : Principles of Imperative Computation Summer 1 2012 Assignment 4 (Theory Part) Due: Monday, June 11, 2012 in class Name: Andrew ID: Recitation: The written portion
More informationSo on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees.
So on the survey, someone mentioned they wanted to work on heaps, and someone else mentioned they wanted to work on balanced binary search trees. According to the 161 schedule, heaps were last week, hashing
More informationObject-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018
Object-oriented programming 1 and data-structures CS/ENGRD 2110 SUMMER 2018 Lecture 8: Sorting http://courses.cs.cornell.edu/cs2110/2018su Lecture 7 Recap 2 Introduced a formal notation for analysing the
More informationIntroduction to Algorithms
Introduction to Algorithms 6.046J/18.401J Lecture 6 Prof. Piotr Indyk Today: sorting Show that Θ (n lg n) is the best possible running time for a sorting algorithm. Design an algorithm that sorts in O(n)
More informationAlgorithms and Data Structures
Algorithms and Data Structures Open Hashing Ulf Leser Open Hashing Open Hashing: Store all values inside hash table A General framework No collision: Business as usual Collision: Chose another index and
More informationAdvanced Database Systems
Lecture IV Query Processing Kyumars Sheykh Esmaili Basic Steps in Query Processing 2 Query Optimization Many equivalent execution plans Choosing the best one Based on Heuristics, Cost Will be discussed
More informationHashing. Dr. Ronaldo Menezes Hugo Serrano. Ronaldo Menezes, Florida Tech
Hashing Dr. Ronaldo Menezes Hugo Serrano Agenda Motivation Prehash Hashing Hash Functions Collisions Separate Chaining Open Addressing Motivation Hash Table Its one of the most important data structures
More informationDATA STRUCTURES AND ALGORITHMS
LECTURE 2 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 1... Algorithm Analysis Course Organization Abstract Data Types and Data Structures Pseudocode Algorithm
More informationCSE 332: Data Structures & Parallelism Lecture 12: Comparison Sorting. Ruth Anderson Winter 2019
CSE 332: Data Structures & Parallelism Lecture 12: Comparison Sorting Ruth Anderson Winter 2019 Today Sorting Comparison sorting 2/08/2019 2 Introduction to sorting Stacks, queues, priority queues, and
More informationData Structures and Algorithms CSE 465
Data Structures and Algorithms CSE 465 LECTURE 2 Analysis of Algorithms Insertion Sort Loop invariants Asymptotic analysis Sofya Raskhodnikova and Adam Smith The problem of sorting Input: sequence a 1,
More informationCSCI 104 Runtime Complexity. Mark Redekopp David Kempe
1 CSCI 104 Runtime Complexity Mark Redekopp David Kempe 2 Runtime It is hard to compare the run time of an algorithm on actual hardware Time may vary based on speed of the HW, etc. The same program may
More informationUniversity of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2017
University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 207 Midterm Examination Instructor: Dr. Ladan Tahvildari, PEng, SMIEEE Date: Wednesday,
More informationAmortized Analysis and Union-Find , Inge Li Gørtz
Amortized Analysis and Union-Find 02283, Inge Li Gørtz 1 Today Amortized analysis 3 different methods 2 examples Union-Find data structures Worst-case complexity Amortized complexity 2 Amortized Analysis
More informationMergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015
CS161, Lecture 2 MergeSort, Recurrences, Asymptotic Analysis Scribe: Michael P. Kim Date: April 1, 2015 1 Introduction Today, we will introduce a fundamental algorithm design paradigm, Divide-And-Conquer,
More informationMidterm 2 Exam Principles of Imperative Computation. Tuesday 31 st March, This exam is closed-book with one sheet of notes permitted.
Midterm 2 Exam 15-122 Principles of Imperative Computation Tuesday 31 st March, 2015 Name: Andrew ID: Recitation Section: Instructions This exam is closed-book with one sheet of notes permitted. You have
More informationIntroduction to Algorithms: Massachusetts Institute of Technology 7 October, 2011 Professors Erik Demaine and Srini Devadas Problem Set 4
Introduction to Algorithms: 6.006 Massachusetts Institute of Technology 7 October, 2011 Professors Erik Demaine and Srini Devadas Problem Set 4 Problem Set 4 Both theory and programming questions are due
More informationIntroduction Data Structures
Introduction Data Structures This course Lecturer: Nick Smallbone (me) nicsma@chalmers.se, room 5469 Assistant: Alexander Sjösten sjosten@chalmers.se Lectures usually twice a week: Wednesdays 13-15, room
More informationDATA 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 informationScan and Quicksort. 1 Scan. 1.1 Contraction CSE341T 09/20/2017. Lecture 7
CSE341T 09/20/2017 Lecture 7 Scan and Quicksort 1 Scan Scan is a very useful primitive for parallel programming. We will use it all the time in this class. First, lets start by thinking about what other
More informationRecall from Last Time: Big-Oh Notation
CSE 326 Lecture 3: Analysis of Algorithms Today, we will review: Big-Oh, Little-Oh, Omega (Ω), and Theta (Θ): (Fraternities of functions ) Examples of time and space efficiency analysis Covered in Chapter
More informationAlgorithm Design and Analysis
Algorithm Design and Analysis LECTURE 6 Greedy Graph Algorithms Shortest paths Adam Smith 9/8/14 The (Algorithm) Design Process 1. Work out the answer for some examples. Look for a general principle Does
More informationOutline for Today. Towards Perfect Hashing. Cuckoo Hashing. The Cuckoo Graph. Analysis of Cuckoo Hashing. Reducing worst-case bounds
Cuckoo Hashing Outline for Today Towards Perfect Hashing Reducing worst-case bounds Cuckoo Hashing Hashing with worst-case O(1) lookups. The Cuckoo Graph A framework for analyzing cuckoo hashing. Analysis
More informationHash Tables. Hashing Probing Separate Chaining Hash Function
Hash Tables Hashing Probing Separate Chaining Hash Function Introduction In Chapter 4 we saw: linear search O( n ) binary search O( log n ) Can we improve the search operation to achieve better than O(
More informationDiscover How to Watch the Mass Ascension of the Albuquerque International Balloon Fiesta Even if You Can t Be There
Attention: Balloon Enthusiasts Interested in Seeing the Balloon Fiesta Discover How to Watch the Mass Ascension of the Albuquerque International Balloon Fiesta Even if You Can t Be There Here s A New,
More informationFundamental Algorithms
Fundamental Algorithms Chapter 7: Hash Tables Michael Bader Winter 2011/12 Chapter 7: Hash Tables, Winter 2011/12 1 Generalised Search Problem Definition (Search Problem) Input: a sequence or set A of
More informationcamcorders as a social research method
Real Life Methods Part of the ESRC National Centre for Research Methods Toolkit #04 Participant Produced Video: Giving participants camcorders as a social research method Stewart Muir, Real Life Methods,
More information(Refer Slide Time: 01.26)
Data Structures and Algorithms Dr. Naveen Garg Department of Computer Science and Engineering Indian Institute of Technology, Delhi Lecture # 22 Why Sorting? Today we are going to be looking at sorting.
More informationLecture 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 informationWeek - 01 Lecture - 03 Euclid's Algorithm for gcd. Let us continue with our running example of gcd to explore more issues involved with program.
Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 03 Euclid's Algorithm
More informationMost of this PDF is editable. You can either type your answers in the red boxes/lines, or you can write them neatly by hand.
15-122 : Principles of Imperative Computation, Spring 2016 Written Homework 7 Due: Monday 7 th March, 2016 Name:q1 Andrew ID: q2 Section:q3 This written homework covers amortized analysis and hash tables.
More informationThe Best Event Marketing Plan. Ever.
The Best Event Email Marketing Plan. Ever. Introduction: You ve created a kick-ass, awesome event at an amazing location with a beautiful event page - and all within budget! But now what? Your biggest
More informationstacks operation array/vector linked list push amortized O(1) Θ(1) pop Θ(1) Θ(1) top Θ(1) Θ(1) isempty Θ(1) Θ(1)
Hashes 1 lists 2 operation array/vector linked list find (by value) Θ(n) Θ(n) insert (end) amortized O(1) Θ(1) insert (beginning/middle) Θ(n) Θ(1) remove (by value) Θ(n) Θ(n) find (by index) Θ(1) Θ(1)
More informationBalanced Trees Part Two
Balanced Trees Part Two Outline for Today Recap from Last Time Review of B-trees, 2-3-4 trees, and red/black trees. Order Statistic Trees BSTs with indexing. Augmented Binary Search Trees Building new
More informationCPS 231 Exam 2 SOLUTIONS
CPS 231 Exam 2 SOLUTIONS Fall 2003 1:00-2:25, Tuesday November 20th Closed book exam NAME: Problem Max Obtained 1 10 2 25 3 (a) 15 3 (b) 15 3 (c) 10 4 (a) 10 4 (b) 15 4 (c) 10 Total 110 1 [10 points ]
More information