Dynamic tables. Amortized Analysis. Example of a dynamic table. Example of a dynamic table. CS Spring 2008
|
|
- Emma Grace Howard
- 6 years ago
- Views:
Transcription
1 CS 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. Elements can only be inserted, and all inserted elements are stored in one contiguous part in the array. The table should be as small as possible, but large enough so that it won t overflow. Problem: We may not know the proper size in advance! Solution: Dynamic tables. IDEA: Whenever the table overflows, grow it by allocating (via malloc or new) a new, larger table. Move all items from the old table into the new one, and free the storage for the old table. CS 56 Analysis of Algorithms. INSERT. INSERT overflow. INSERT. INSERT overflow CS 56 Analysis of Algorithms CS 56 Analysis of Algorithms 4
2 . INSERT. INSERT. INSERT. INSERT overflow CS 56 Analysis of Algorithms 5 CS 56 Analysis of Algorithms 6. INSERT. INSERT overflow. INSERT. INSERT CS 56 Analysis of Algorithms 7 CS 56 Analysis of Algorithms 8
3 . INSERT. INSERT 4. INSERT 4. INSERT. INSERT 4. INSERT 5. INSERT 4 overflow CS 56 Analysis of Algorithms 9 CS 56 Analysis of Algorithms 0. INSERT. INSERT 4. INSERT 5. INSERT overflow 4. INSERT. INSERT 4. INSERT 5. INSERT 4 CS 56 Analysis of Algorithms CS 56 Analysis of Algorithms
4 . INSERT. INSERT 4. INSERT 5. INSERT INSERT 6 7. INSERT 7 Worst-case analysis Consider a sequence of n insertions. The worst-case time to execute one insertion is Ο(n). Therefore, the worst-case time for n insertions is n Ο(n) = Ο(n ). WRONG! In fact, the worst-case cost for n insertions is only Θ(n) Ο(n ). Let s see why. CS 56 Analysis of Algorithms CS 56 Analysis of Algorithms 4 Tighter analysis Tighter analysis Let c i = the cost of the i th insertion Let c i = the cost of the i th insertion = + cost to double array size i size i c i i size i c i?????????? CS 56 Analysis of Algorithms 5 CS 56 Analysis of Algorithms 6
5 Tighter analysis Let c i = the cost of the i th insertion = + cost to double array size Tighter analysis Let c i = the cost of the i th insertion = + cost to double array size i size i c i i size i c i CS 56 Analysis of Algorithms 7 CS 56 Analysis of Algorithms 8 Tighter analysis (continued) Cost of n insertions = n c i i= lg( n ) n + n = Θ( n). j= 0 Thus, the average cost of each dynamic-table operation is Θ(n)/n = Θ(). j Amortized analysis An amortized analysis is any strategy for analyzing a sequence of operations: compute the total cost of the sequence, OR amortized cost of an operation = average cost per operation, averaged over the number of operations in the sequence amortized cost can be small, even though a single operation within the sequence might be expensive CS 56 Analysis of Algorithms 9 CS 56 Analysis of Algorithms 0
6 Amortized analysis Even though we re taking averages, however, probability is not involved! An amortized analysis guarantees the average performance of each operation in the worst case. Types of amortized analyses Three common amortization arguments: the aggregate method, the accounting method, Won t cover in class the potential method. We ve just seen an aggregate analysis. The aggregate method, though simple, lacks the precision of the other two methods. In particular, the accounting and potential methods allow a specific amortized cost to be allocated to each operation. CS 56 Analysis of Algorithms CS 56 Analysis of Algorithms Accounting method Charge i th operation a fictitious amortized cost ĉ i, where pays for unit of work (i.e., time). This fee is consumed to perform the operation, and any amount not immediately consumed is stored in the bank for use by subsequent operations. The bank balance must not go negative! We must ensure that n i= n c i cˆ i= for all n. Thus, the total amortized costs provide an upper bound on the total true costs. i CS 56 Analysis of Algorithms Accounting analysis of dynamic tables Charge an amortized cost of ĉ i =$for the i th insertion. pays for the immediate insertion. $ is stored for later table doubling. When the table doubles, pays to move a recent item, and pays to move an old item. Example: $0 $0 $0 $0 $ $ $ $ overflow CS 56 Analysis of Algorithms 4
7 Accounting analysis of dynamic tables Charge an amortized cost of ĉ i =$for the i th insertion. pays for the immediate insertion. $ is stored for later table doubling. When the table doubles, pays to move a recent item, and pays to move an old item. Example: $0 $0 $0 $0 $0 $0 $0 $0 overflow Accounting analysis of dynamic tables Charge an amortized cost of ĉ i =$for the i th insertion. pays for the immediate insertion. $ is stored for later table doubling. When the table doubles, pays to move a recent item, and pays to move an old item. Example: $0 $0 $0 $0 $0 $0 $0 $0 $ $ $ CS 56 Analysis of Algorithms 5 CS 56 Analysis of Algorithms 6 Accounting analysis (continued) Key invariant: Bank balance never drops below 0. Thus, the sum of the amortized costs provides an upper bound on the sum of the true costs. i size i c i 5 9 ĉ i * bank i *Okay, so I lied. The first operation costs only $, not $. CS 56 Analysis of Algorithms 7 Incrementing a Binary Counter Given: A k-bit binary counter A[0,,,k-], initialized with 0,0,,0. The counter supports the following INREMENT operation: INCREMENT(A) // increases counter by i 0 while i<length(a) and A[i]= do A[i] 0 i++ if i<length(a) then A[i] Question: In a sequence of n INCREMENT operations, what is the amortized runtime of one INCREMENT operation? CS 56 Analysis of Algorithms 8
8 Binary Counter Example Accounting Method Example for k=8 and n=9: Initial counter After increment After increments After increments After 4 increments After 5 increments After 6 increments After 7 increments After 8 increments After 9 increments flip $ $ 0 flip Charge $ to set a bit to (0 flip) pays for the actual flip Store on the bit as credit to be used later when this bit is flipped back to 0 Charge $0 to set a bit to 0 ( 0 flip) Every in the counter has credit on it, which is used to pay for this flip The worst-case runtime of one INCREMENT operation is O(k) For n operations the total is O(nk) CS 56 Analysis of Algorithms 9 CS 56 Analysis of Algorithms 0 Binary Counter Example Accounting Method Example for k=8 and n=9: Initial counter After increment After increments After increments After 4 increments After 5 increments After 6 increments After 7 increments After 8 increments After 9 increments flip $ $ 0 flip Charge $ to set a bit to (0 flip) pays for the actual flip Store on the bit as credit to be used later when this bit is flipped back to 0 Charge $0 to set a bit to 0 ( 0 flip) Every in the counter has credit on it, which is used to pay for this flip Since each INCREMENT operation is composed of one 0 flip and possibly multiple 0 flips, the asymptotic runtime of one INCREMENT operation is O(). CS 56 Analysis of Algorithms CS 56 Analysis of Algorithms
9 Conclusions Amortized costs can provide a clean abstraction of data-structure performance. Any of the analysis methods can be used when an amortized analysis is called for, but each method has some situations where it is arguably the simplest. Different schemes may work for assigning amortized costs in the accounting method, sometimes yielding radically different bounds. CS 56 Analysis of Algorithms
CMPS 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 informationIntroduction 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 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 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 informationHow fast can we sort? Sorting. Decision-tree example. Decision-tree example. CS 3343 Fall by Charles E. Leiserson; small changes by Carola
CS 3343 Fall 2007 Sorting Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk CS 3343 Analysis of Algorithms 1 How fast can we sort? All the sorting algorithms we have seen
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 informationAmortized Analysis. The time required to perform a sequence of (data structure) operations is averaged over all the operations performed.
Amortized Analysis The time required to perform a sequence of (data structure) operations is averaged over all the operations performed. No probabilistic assumptions - not an average case analysis! 1 Example:
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. Ric Glassey
Amortized Analysis Ric Glassey glassey@kth.se 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
More informationSorting. CMPS 2200 Fall Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk
CMPS 2200 Fall 2014 Sorting Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk 11/11/14 CMPS 2200 Intro. to Algorithms 1 How fast can we sort? All the sorting algorithms
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 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 informationOrthogonal range searching. Range Trees. Orthogonal range searching. 1D range searching. CS Spring 2009
CS 5633 -- Spring 2009 Orthogonal range searching Range Trees Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk CS 5633 Analysis of Algorithms 1 Input: n points in d dimensions
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 informationComputational Geometry
CS 5633 -- Spring 2004 Computational Geometry Carola Wenk Slides courtesy of Charles Leiserson with small changes by Carola Wenk CS 5633 Analysis of Algorithms 1 Computational geometry Algorithms for solving
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 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 informationCs445 Homework #1. Due 9/9/ :59 pm DRAFT
Cs5 Homework #. Due 9/9/06 :59 pm DRAFT Instructions.. Solution may not be submitted by students in pairs.. You may submit a pdf of the homework, either printed or hand-written and scanned, as long as
More informationCS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk
CS 6463: AT Computational Geometry Spring 2006 Convex Hulls Carola Wenk 8/29/06 CS 6463: AT Computational Geometry 1 Convex Hull Problem Given a set of pins on a pinboard and a rubber band around them.
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 informationIntroduction to Algorithms 6.046J/18.401J
Introduction to Algorithms 6.046J/18.401J LECTURE 1 Analysis of Algorithms Insertion sort Merge sort Prof. Charles E. Leiserson Course information 1. Staff. Prerequisites 3. Lectures 4. Recitations 5.
More informationTheory and Algorithms Introduction: insertion sort, merge sort
Theory and Algorithms Introduction: insertion sort, merge sort Rafael Ramirez rafael@iua.upf.es Analysis of algorithms The theoretical study of computer-program performance and resource usage. What s also
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 informationIntroduction to Algorithms 6.046J/18.401J/SMA5503
Introduction to Algorithms 6.046J/18.401J/SMA5503 Lecture 1 Prof. Charles E. Leiserson Welcome to Introduction to Algorithms, Fall 01 Handouts 1. Course Information. Calendar 3. Registration (MIT students
More informationHomework #5 Algorithms I Spring 2017
Homework #5 Algorithms I 600.463 Spring 2017 Due on: Saturday, March 18th, 11:59pm Late submissions: will NOT be accepted Format: Please start each problem on a new page. Where to submit: On Gradescope,
More informationIntroduction to Algorithms 6.046J/18.401J
Introduction to Algorithms 6.046J/18.401J Lecture 1 Prof. Piotr Indyk Analysis of algorithms The theoretical study of computer-program performance and resource usage. Also important: modularity maintainability
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 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 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 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 information16 Greedy Algorithms
16 Greedy Algorithms Optimization algorithms typically go through a sequence of steps, with a set of choices at each For many optimization problems, using dynamic programming to determine the best choices
More informationThe divide-and-conquer paradigm involves three steps at each level of the recursion: Divide the problem into a number of subproblems.
2.3 Designing algorithms There are many ways to design algorithms. Insertion sort uses an incremental approach: having sorted the subarray A[1 j - 1], we insert the single element A[j] into its proper
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 informationCS302 Topic: Algorithm Analysis #2. Thursday, Sept. 21, 2006
CS302 Topic: Algorithm Analysis #2 Thursday, Sept. 21, 2006 Analysis of Algorithms The theoretical study of computer program performance and resource usage What s also important (besides performance/resource
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 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 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 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 informationLecture 5: Sorting Part A
Lecture 5: Sorting Part A Heapsort Running time O(n lg n), like merge sort Sorts in place (as insertion sort), only constant number of array elements are stored outside the input array at any time Combines
More informationINDIAN STATISTICAL INSTITUTE
INDIAN STATISTICAL INSTITUTE Mid Semestral Examination M. Tech (CS) - I Year, 2016-2017 (Semester - II) Design and Analysis of Algorithms Date : 21.02.2017 Maximum Marks : 60 Duration : 3.0 Hours Note:
More informationCS Fall 2010 B-trees Carola Wenk
CS 3343 -- Fall 2010 B-trees Carola Wenk 10/19/10 CS 3343 Analysis of Algorithms 1 External memory dictionary Task: Given a large amount of data that does not fit into main memory, process it into a dictionary
More informationCS 561, Lecture Topic: Amortized Analysis. Jared Saia University of New Mexico
CS 561, Lecture Topic: Amortized Analysis Jared Saia University of New Mexico Outline Amortized Analysis Aggregate, Taxation and Potential Methods Dynamic Table Union Find Data Structure 1 Amortized Analysis
More informationCS 561, Lecture Topic: Amortized Analysis. Jared Saia University of New Mexico
CS 561, Lecture Topic: Amortized Analysis Jared Saia University of New Mexico Outline Amortized Analysis Aggregate, Taxation and Potential Methods Dynamic Table Union Find Data Structure 1 Amortized Analysis
More informationCS302 Topic: Algorithm Analysis. Thursday, Sept. 22, 2005
CS302 Topic: Algorithm Analysis Thursday, Sept. 22, 2005 Announcements Lab 3 (Stock Charts with graphical objects) is due this Friday, Sept. 23!! Lab 4 now available (Stock Reports); due Friday, Oct. 7
More informationAlgorithm Analysis Part 2. Complexity Analysis
Algorithm Analysis Part 2 Complexity Analysis Introduction Algorithm Analysis measures the efficiency of an algorithm, or its implementation as a program, as the input size becomes large Actually, an estimation
More informationPlane Sweep Algorithms
CMPS 6640/4040 Computational Geometry Spring 2016 Plane Sweep Algorithms Carola Wenk 3/3/16 CMPS 6640/4040 Computational Geometry 1 Line Segment Intersection Input: A set S={s 1,, s n } of (close) line
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 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 informationChapter 6 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
Chapter 6 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS 1 Reference books: The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie Programming in C (3rd Edition) by Stephen G. Kochan. Data
More informationTirgul 4. Order statistics. Minimum & Maximum. Order Statistics. Heaps. minimum/maximum Selection. Overview Heapify Build-Heap
Tirgul 4 Order Statistics minimum/maximum Selection Heaps Overview Heapify Build-Heap Order statistics The i th order statistics of a set of n elements is the i th smallest element. For example the minimum
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 informationMath 501 Solutions to Homework Assignment 10
Department of Mathematics Discrete Mathematics Math 501 Solutions to Homework Assignment 10 Section 7.3 Additional Exercises 1. int CountValuesLessThanT(int a[], int n, int T) { int count = 0; for (int
More informationData Structures and Algorithms Key to Homework 1
Data Structures and Algorithms Key to Homework 1 January 31, 2005 15 Define an ADT for a set of integers (remember that a set may not contain duplicates) Your ADT should consist of the functions that can
More informationLecture 2: Algorithm Analysis
ECE4050/CSC5050 Algorithms and Data Structures Lecture 2: Algorithm Analysis 1 Mathematical Background Logarithms Summations Recursion Induction Proofs Recurrence Relations 2 2 Logarithm Definition: 3
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 informationAlgorithm Analysis. (Algorithm Analysis ) Data Structures and Programming Spring / 48
Algorithm Analysis (Algorithm Analysis ) Data Structures and Programming Spring 2018 1 / 48 What is an Algorithm? An algorithm is a clearly specified set of instructions to be followed to solve a problem
More informationThe complexity of Sorting and sorting in linear-time. Median and Order Statistics. Chapter 8 and Chapter 9
Subject 6 Spring 2017 The complexity of Sorting and sorting in linear-time Median and Order Statistics Chapter 8 and Chapter 9 Disclaimer: These abbreviated notes DO NOT substitute the textbook for this
More informationChapter 8 Sorting in Linear Time
Chapter 8 Sorting in Linear Time The slides for this course are based on the course textbook: Cormen, Leiserson, Rivest, and Stein, Introduction to Algorithms, 3rd edition, The MIT Press, McGraw-Hill,
More informationPROGRAM EFFICIENCY & COMPLEXITY ANALYSIS
Lecture 03-04 PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS By: Dr. Zahoor Jan 1 ALGORITHM DEFINITION A finite set of statements that guarantees an optimal solution in finite interval of time 2 GOOD ALGORITHMS?
More informationLecture: Analysis of Algorithms (CS )
Lecture: Analysis of Algorithms (CS583-002) Amarda Shehu Fall 2017 Amarda Shehu Lecture: Analysis of Algorithms (CS583-002) Sorting in O(n lg n) Time: Heapsort 1 Outline of Today s Class Sorting in O(n
More informationPlotting run-time graphically. Plotting run-time graphically. CS241 Algorithmics - week 1 review. Prefix Averages - Algorithm #1
CS241 - week 1 review Special classes of algorithms: logarithmic: O(log n) linear: O(n) quadratic: O(n 2 ) polynomial: O(n k ), k 1 exponential: O(a n ), a > 1 Classifying algorithms is generally done
More informationPractice Midterm Exam Solutions
CSE 332: Data Abstractions Autumn 2015 Practice Midterm Exam Solutions Name: Sample Solutions ID #: 1234567 TA: The Best Section: A9 INSTRUCTIONS: You have 50 minutes to complete the exam. The exam is
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 informationCSCI 104 Log Structured Merge Trees. Mark Redekopp
1 CSCI 10 Log Structured Merge Trees Mark Redekopp Series Summation Review Let n = 1 + + + + k = σk i=0 n = k+1-1 i. What is n? What is log (1) + log () + log () + log (8)++ log ( k ) = 0 + 1 + + 3+ +
More informationCS 137 Part 8. Merge Sort, Quick Sort, Binary Search. November 20th, 2017
CS 137 Part 8 Merge Sort, Quick Sort, Binary Search November 20th, 2017 This Week We re going to see two more complicated sorting algorithms that will be our first introduction to O(n log n) sorting algorithms.
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 informationCS166 Handout 11 Spring 2018 May 8, 2018 Problem Set 4: Amortized Efficiency
CS166 Handout 11 Spring 2018 May 8, 2018 Problem Set 4: Amortized Efficiency In this problem set, you'll get to explore amortized efficient data structures and a number of their properties. You'll design
More informationCITS3001. Algorithms, Agents and Artificial Intelligence. Semester 2, 2016
CITS3001 Algorithms, Agents and Artificial Intelligence Semester 2, 2016 Tim French School of Computer Science & Software Eng. The University of Western Australia 2. Review of algorithmic concepts CLRS,
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 informationOutline for Today. Why could we construct them in time O(n)? Analyzing data structures over the long term.
Amortized Analysis Outline for Today Euler Tour Trees A quick bug fix from last time. Cartesian Trees Revisited Why could we construct them in time O(n)? Amortized Analysis Analyzing data structures over
More informationThe divide and conquer strategy has three basic parts. For a given problem of size n,
1 Divide & Conquer One strategy for designing efficient algorithms is the divide and conquer approach, which is also called, more simply, a recursive approach. The analysis of recursive algorithms often
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 informationCS141: Intermediate Data Structures and Algorithms Analysis of Algorithms
CS141: Intermediate Data Structures and Algorithms Analysis of Algorithms Amr Magdy Analyzing Algorithms 1. Algorithm Correctness a. Termination b. Produces the correct output for all possible input. 2.
More informationOutline for Today. Euler Tour Trees Revisited. The Key Idea. Dynamic Graphs. Implementation Details. Dynamic connectivity in forests.
Dynamic Graphs Outline for Today Euler Tour Trees Revisited Dynamic connectivity in forests. The Key Idea Maintaining dynamic connectivity in general graphs Dynamic Graphs A data structure for dynamic
More informationINTRODUCTION TO ALGORITHMS
UNIT- Introduction: Algorithm: The word algorithm came from the name of a Persian mathematician Abu Jafar Mohammed Ibn Musa Al Khowarizmi (ninth century) An algorithm is simply s set of rules used to perform
More informationMultiple-choice (35 pt.)
CS 161 Practice Midterm I Summer 2018 Released: 7/21/18 Multiple-choice (35 pt.) 1. (2 pt.) Which of the following asymptotic bounds describe the function f(n) = n 3? The bounds do not necessarily need
More informationIntroduction to Asymptotic Running Time Analysis CMPSC 122
Introduction to Asymptotic Running Time Analysis CMPSC 122 I. Comparing Two Searching Algorithms Let's begin by considering two searching algorithms you know, both of which will have input parameters of
More informationAdvanced algorithms. binary heap, d-ary heap, binomial heap, amortized analysis, Fibonacci heap. Jiří Vyskočil, Radek Mařík 2013
binary heap, d-ary heap, binomial heap, amortized analysis, Fibonacci heap Jiří Vyskočil, Radek Mařík 2013 heap Heaps [haldy] a heap is a specialized data structure (usually tree-based) that satisfies
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 information1 Probability Review. CS 124 Section #8 Hashing, Skip Lists 3/20/17. Expectation (weighted average): the expectation of a random quantity X is:
CS 124 Section #8 Hashing, Skip Lists 3/20/17 1 Probability Review Expectation (weighted average): the expectation of a random quantity X is: x= x P (X = x) For each value x that X can take on, we look
More informationLecture 2: Getting Started
Lecture 2: Getting Started Insertion Sort Our first algorithm is Insertion Sort Solves the sorting problem Input: A sequence of n numbers a 1, a 2,..., a n. Output: A permutation (reordering) a 1, a 2,...,
More informationData Structure Lecture#5: Algorithm Analysis (Chapter 3) U Kang Seoul National University
Data Structure Lecture#5: Algorithm Analysis (Chapter 3) U Kang Seoul National University U Kang 1 In This Lecture Learn how to evaluate algorithm efficiency Learn the concept of average case, best case,
More informationAdvanced Algorithms and Data Structures
Advanced Algorithms and Data Structures Prof. Tapio Elomaa Course Basics A new 7 credit unit course Replaces OHJ-2156 Analysis of Algorithms We take things a bit further than OHJ-2156 We will assume familiarity
More informationCMPS 2200 Fall Dynamic Programming. Carola Wenk. Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk
CMPS 00 Fall 04 Dynamic Programming Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 9/30/4 CMPS 00 Intro. to Algorithms Dynamic programming Algorithm design technique
More informationCMPS 2200 Fall 2017 B-trees Carola Wenk
CMPS 2200 Fall 2017 B-trees Carola Wenk 9/18/17 CMPS 2200 Intro. to Algorithms 1 External memory dictionary Task: Given a large amount of data that does not fit into main memory, process it into a dictionary
More information/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/27/17
01.433/33 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Priority Queues / Heaps Date: 9/2/1.1 Introduction In this lecture we ll talk about a useful abstraction, priority queues, which are
More informationChapter 2: Complexity Analysis
Chapter 2: Complexity Analysis Objectives Looking ahead in this chapter, we ll consider: Computational and Asymptotic Complexity Big-O Notation Properties of the Big-O Notation Ω and Θ Notations Possible
More information[ 11.2, 11.3, 11.4] Analysis of Algorithms. Complexity of Algorithms. 400 lecture note # Overview
400 lecture note #0 [.2,.3,.4] Analysis of Algorithms Complexity of Algorithms 0. Overview The complexity of an algorithm refers to the amount of time and/or space it requires to execute. The analysis
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 146. Asymptotic Analysis Interview Question of the Day Homework 1 & Project 1 Work Session
CSE 146 Asymptotic Analysis Interview Question of the Day Homework 1 & Project 1 Work Session Comparing Algorithms Rough Estimate Ignores Details Or really: independent of details What are some details
More informationPrinciples of Algorithm Design
Principles of Algorithm Design When you are trying to design an algorithm or a data structure, it s often hard to see how to accomplish the task. The following techniques can often be useful: 1. Experiment
More informationMinimum Spanning Trees
CSMPS 2200 Fall Minimum Spanning Trees Carola Wenk Slides courtesy of Charles Leiserson with changes and additions by Carola Wenk 11/6/ CMPS 2200 Intro. to Algorithms 1 Minimum spanning trees Input: A
More informationProblem Set 4 Solutions
Design and Analysis of Algorithms March 5, 205 Massachusetts Institute of Technology 6.046J/8.40J Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Problem Set 4 Solutions Problem Set 4 Solutions This
More informationTable of Contents. Course Minutiae. Course Overview Algorithm Design Strategies Algorithm Correctness Asymptotic Analysis 2 / 32
Intro Lecture CS 584/684: Algorithm Design and Analysis Daniel Leblanc1 1 Senior Adjunct Instructor Portland State University Maseeh College of Engineering and Computer Science Spring 2018 1 / 32 2 / 32
More informationV Advanced Data Structures
V Advanced Data Structures B-Trees Fibonacci Heaps 18 B-Trees B-trees are similar to RBTs, but they are better at minimizing disk I/O operations Many database systems use B-trees, or variants of them,
More informationEECS 2011M: Fundamentals of Data Structures
M: Fundamentals of Data Structures Instructor: Suprakash Datta Office : LAS 3043 Course page: http://www.eecs.yorku.ca/course/2011m Also on Moodle Note: Some slides in this lecture are adopted from James
More informationToday: Amortized Analysis (examples) Multithreaded Algs.
Today: Amortized Analysis (examples) Multithreaded Algs. COSC 581, Algorithms March 11, 2014 Many of these slides are adapted from several online sources Reading Assignments Today s class: Chapter 17 (Amortized
More informationCS/COE 1501
CS/COE 1501 www.cs.pitt.edu/~nlf4/cs1501/ Introduction Meta-notes These notes are intended for use by students in CS1501 at the University of Pittsburgh. They are provided free of charge and may not be
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 informationQuiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)
Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology 6.006 Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1 Solutions Problem 1. Quiz 1 Solutions Asymptotic orders
More information