CS 261 Spring 2013 Midterm

Similar documents
Exam Data structures DAT036/DAT037/DIT960

University of Toronto Mississauga. Flip to the back cover and write down your name and student number.

CSE 332, Spring 2010, Midterm Examination 30 April 2010

Basic Data Structures (Version 7) Name:

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Balanced Binary Search Trees. Victor Gao

Binary Search Trees Treesort

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination

CSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1

9. Heap : Priority Queue

Exam Data structures DIT960/DAT036

CS-245 Database System Principles

Sorting and Searching

Thus, it is reasonable to compare binary search trees and binary heaps as is shown in Table 1.

Implementations. Priority Queues. Heaps and Heap Order. The Insert Operation CS206 CS206

Sorting and Searching

Algorithms and Data Structures

Section 1: True / False (1 point each, 15 pts total)

x-fast and y-fast Tries

Exam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE

BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015

Binary heaps (chapters ) Leftist heaps

So the actual cost is 2 Handout 3: Problem Set 1 Solutions the mark counter reaches c, a cascading cut is performed and the mark counter is reset to 0

CSE548, AMS542: Analysis of Algorithms, Fall 2012 Date: October 16. In-Class Midterm. ( 11:35 AM 12:50 PM : 75 Minutes )

x-fast and y-fast Tries

Sorting. Chapter 12. Objectives. Upon completion you will be able to:

CSE 241 Class 17. Jeremy Buhler. October 28, Ordered collections supported both, plus total ordering operations (pred and succ)

Operations on Heap Tree The major operations required to be performed on a heap tree are Insertion, Deletion, and Merging.

Priority Queues and Binary Heaps

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value

Binary Heaps in Dynamic Arrays

CS 372: Computational Geometry Lecture 3 Line Segment Intersection

Final Exam. Jonathan Turner 5/12/2010. CS 542 Advanced Data Structures and Algorithms

Recall: Properties of B-Trees

Outline. Computer Science 331. Definitions: Paths and Their Costs. Computation of Minimum Cost Paths

Hash Tables. CS 311 Data Structures and Algorithms Lecture Slides. Wednesday, April 22, Glenn G. Chappell

CS711008Z Algorithm Design and Analysis

Second Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

CISC-235* Test #3 March 19, 2018

( ) n 5. Test 1 - Closed Book

CS711008Z Algorithm Design and Analysis

Question Paper Code : 97044

CSE 373 Final Exam 3/14/06 Sample Solution

CS 251, LE 2 Fall MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY

Computer Science 302 Fall 2009 (Practice) Second Examination, October 15, 2009

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

CSE 373 Winter 2009: Midterm #1 (closed book, closed notes, NO calculators allowed)

CPSC 311: Analysis of Algorithms (Honors) Exam 1 October 11, 2002

CSCI2100B Data Structures Heaps

: Fundamental Data Structures and Algorithms. June 06, 2011 SOLUTIONS

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

This is a set of practice questions for the final for CS16. The actual exam will consist of problems that are quite similar to those you have

Randomized incremental construction. Trapezoidal decomposition: Special sampling idea: Sample all except one item

Dijkstra s Single Source Shortest Path Algorithm. Andreas Klappenecker

Computer Science Spring 2005 Final Examination, May 12, 2005

Outline. Computer Science 331. Heap Shape. Binary Heaps. Heap Sort. Insertion Deletion. Mike Jacobson. HeapSort Priority Queues.

Introduction to Algorithms March 11, 2009 Massachusetts Institute of Technology Spring 2009 Professors Sivan Toledo and Alan Edelman Quiz 1

Lecture 19 Apr 25, 2007

Lecture Summary CSC 263H. August 5, 2016

Computer Science 210 Data Structures Siena College Fall Topic Notes: Priority Queues and Heaps

Algorithms in a Nutshell. Session 4 Recap Algorithm Themes 11:20 11:40

Priority queues. Priority queues. Priority queue operations

2.1 Greedy Algorithms. 2.2 Minimum Spanning Trees. CS125 Lecture 2 Fall 2016

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

COS 226 Midterm Exam, Spring 2011

DIT960 Datastrukturer

COMP 352 FALL Tutorial 10

Problem Set 9 Solutions

CS-301 Data Structure. Tariq Hanif

CS166 Handout 11 Spring 2018 May 8, 2018 Problem Set 4: Amortized Efficiency

Programming II (CS300)

Design and Analysis of Algorithms Lecture- 9: Binary Search Trees

Algorithm Design and Analysis

Direct Addressing Hash table: Collision resolution how handle collisions Hash Functions:

Advanced Algorithms. Class Notes for Thursday, September 18, 2014 Bernard Moret

9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology

Route planning / Search Movement Group behavior Decision making

W4231: Analysis of Algorithms

) $ f ( n) " %( g( n)

CSE373 Fall 2013, Midterm Examination October 18, 2013

ADT Priority Queue. Heaps. A Heap Implementation of the ADT Priority Queue. Heapsort

The questions will be short answer, similar to the problems you have done on the homework

Quiz 1 Solutions. (a) f(n) = n g(n) = log n Circle all that apply: f = O(g) f = Θ(g) f = Ω(g)

Outline for Today. How can we speed up operations that work on integer data? A simple data structure for ordered dictionaries.

CS 223: Data Structures and Programming Techniques. Exam 2. April 19th, 2012

CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014

l Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are:

CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)

5. Hashing. 5.1 General Idea. 5.2 Hash Function. 5.3 Separate Chaining. 5.4 Open Addressing. 5.5 Rehashing. 5.6 Extendible Hashing. 5.

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

l So unlike the search trees, there are neither arbitrary find operations nor arbitrary delete operations possible.

CS 151 Quiz 4. Instructions: Student ID. (Last Name) (First Name) Signature

9. Which situation is true regarding a cascading cut that produces c trees for a Fibonacci heap?

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination

Rank-Pairing Heaps. Bernard Haeupler Siddhartha Sen Robert E. Tarjan. SIAM JOURNAL ON COMPUTING Vol. 40, No. 6 (2011), pp.

CS251-SE1. Midterm 2. Tuesday 11/1 8:00pm 9:00pm. There are 16 multiple-choice questions and 6 essay questions.

FINALTERM EXAMINATION Fall 2009 CS301- Data Structures Question No: 1 ( Marks: 1 ) - Please choose one The data of the problem is of 2GB and the hard

COSC 2007 Data Structures II Final Exam. Part 1: multiple choice (1 mark each, total 30 marks, circle the correct answer)

Priority Queues and Heaps

Outline for Today. How can we speed up operations that work on integer data? A simple data structure for ordered dictionaries.

Transcription:

CS 261 Spring 2013 Midterm Name: Student ID: 1: 2: 3: 4: 5: 6: Total:

1. (20 points) Suppose that we implement a simplified version of the dynamic array data structure in which the amount of memory allocated for the dynamic array is always the smallest power of two that is at least as large as the number of items in the array. If we try to do an increase-length (insertion) operation that would cause the number of items in the array to be larger than this power of two, we reallocate a new piece of memory twice as long as the previous one, and if we try to do a decrease-length (deletion) operation that would cause the number of remaining items to be smaller than half of this power of two, we reallocate a new piece of memory half as large. (a) Using the potential function Φ = 2 (number of items in array) (allocated size), show that the amortized time per insertion (for a sequence of insertions without any deletions, starting from an empty array) is constant. (b) Using the different potential function Φ = (allocated size) (number of items in array), show that the amortized time per deletion (for a sequence of deletions without any insertions, starting from an array with exactly 2 k items in it, for some chosen value k) is constant. (c) Do these two pieces of analysis together imply that this version of the dynamic array uses constant amortized time for insertions and deletions mixed together? Why or why not?

2. (20 points) The time analysis of Fibonacci heaps uses the fact that certain shapes of trees cannot be formed by the Fibonacci heap operations. Draw an example of a tree that cannot be formed as part of a Fibonacci heap. (You do not need to draw the priorities of the items stored in the tree, just the shape of the tree itself.) 3. (20 points) Suppose that we are inserting some number of keys into a Cuckoo hash data structure in which each of the two tables has room for ten items. (a) Give an example of three keys and an assignment of hash values for each of these keys that, when inserted, would be certain to cause the cuckoo hash structure to fail and need to be rebuilt. (b) If the hash functions we are using are 3-independent, for tables of this size, what is the probability that any particular triple of keys has hash values that cause the structure to fail?

4. (20 points) If we are doing tabulation hashing for 32-bit keys, broken into 8-bit bytes, how many random numbers are needed to initialize the tables used in the hash function? 5. (20 points) Suppose that we are using a software library that includes a binary search tree structure that allows us to insert or delete data items with associated keys, and to answer predecessor or successor queries that find the item with the smallest key larger than a query value q. However, the library does not give us access to the internal structure of the tree, so we can t directly follow paths in it: we have to use the operations we are already given. Rather than using this structure as a binary search tree, we wish to use it as a priority queue. Describe (in English or pseudocode) how to use the predecessor or successor operations to find the highest priority item in the structure, assuming that the keys are being used as priorities and that lower key numbers correspond to higher priorities. If you need them, you may assume the existence of special key values and + that are less than (greater than, respectively) all data keys. 6. (20 points) If we have an unsorted array of n items, and we search it by scanning from the start rather than by using binary search, the time to search for the item in position i will be O(i + 1). In particular, searching for items that happen to be near the start of the array will be faster than O(log n). Describe an assignment of weights w i for the items such that the O(log(W/w i )) time bound for splay trees (with W = w i ) is at least as fast as this O(i + 1) time bound for scanning an array.

You may use this page (or the back of the other pages) as scratch paper.