# CSE 373 Autumn 2010: Midterm #2 (closed book, closed notes, NO calculators allowed)

Save this PDF as:

Size: px
Start display at page:

Download "CSE 373 Autumn 2010: Midterm #2 (closed book, closed notes, NO calculators allowed)"

## Transcription

1 Name: address: CSE 373 Autumn 2010: Midterm #2 (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may give partial credit based on the work you write down, so if time permits, show your work! Use only the data structures and algorithms we have discussed in class or that were mentioned in the book so far. Note: For questions where you are drawing pictures, please circle your final answer for any credit. Good Luck! Total: 61 points. Time: 50 minutes. Question Max Points Total 61 Score Page 1 of 10

2 1) [11 points total] Disjoint Sets: Given the array representation of up-trees discussed in class (where size[x] = total number of values in set x, and up[x] == -1 indicates that node x is a root node), for example (size is unspecified for non-root nodes): up a) [6 points] Fill in the code below for Union by Size (weighted Union) (does not have to be perfect Java code). (On a tie in size, the set referred to by the second parameter should be added to the set referred to by the first.) int up[n]; int size[n]; size void Union(int x, int y) { // Assuming x and y are roots of two different sets, // fill in code to implement union by size (weight) // Break ties in size by adding the set y // to the set x. int wx = size[x]; int wy = size[y]; 6 } if (wx < wy) { // x should be added to y up[x] = y; size[y] = wx + wy; } else { // y should be added to x up[y] = x; size[x] = wx + wy; } Page 2 of 10 2

3 1) (cont) b) (1 pts) Now, draw the set of uptrees that results from executing a find(9) with path compression on the sets shown in on the previous page. You may update the set of uptrees on the previous page or redraw the sets here. If no changes occur, state that. c) (2 pts) Update the array to reflect the changes (if any) caused by that find operation. You may update the array on the previous page or redraw the array here. If no changes occur, state that up d) (2 pts) What is the worst case running time of a single find operation if union by size and path compression are used? N = total # of elements in all sets. (no explanation required) O(log N) Page 3 of 10

4 2) [10 points total] Hashing: Draw the contents of the two hash tables below. Show your work for partial credit. If an insertion fails, please indicate which values fail and attempt to insert any remaining values. The size of the hash table is 7. The hash function used is H(k) = k mod 7 13, 17, 6, 24, 3 a) Separate chaining, where each b) Double hashing, where bucket points to a sorted linked list. H2(k) = 7 (k mod 5) H2(6) = 7 (6 mod 5) = 7 1 = 6 H2(24) = 7 (24 mod 5) = 7 4 = 3 H2(3) = 7 (3 mod 5) = 7 3 = 4 Page 4 of 10 4

5 2) (cont) c) (1 pt) What is the load factor for the table a)? 5/7 d) (1 pt) What is the load factor for the table b)? 5/7 Page 5 of 10

6 3) [10 points total] Leftist Heaps: a) [8 pts] Draw the leftist heap that results from inserting: 75, 28, 7, 61, 15, 55, 19, 4 in that order into an initially empty heap. You are only required to show the final heap, although if you draw intermediate heaps, please circle your final result for ANY credit. Page 6 of 10 6

7 3) (cont) b) [2 pts] What is the null path length of the root in your final heap from part a)? Page 7 of 10

8 4) [6 points] Skew Heaps Draw the skew heap that results from doing a deletemin on the skew heap shown below. You are only required to show the final tree, although if you draw intermediate trees, please circle your final result for ANY credit. Page 8 of 10 8

9 5) [8 points] Memory Hierarchy & Locality: Examine the code example below: c[1] = 5; z = 68; j = 2; while (j < 2000) { a[j] = a[j] + a[j-1]; z = b[10] + z; System.out.println( d[j] = + d[j]); j = j + 1; } f[25] = 60; y = c[2000] + c[2001] + c[2002] + c[2003] Considering only their use in the code segment above, for each of the following variables, indicate below what type of locality (if any) is demonstrated. Please circle all that apply (you may circle more than one item for each variable): a spatial locality temporal locality no locality b spatial locality temporal locality no locality c spatial locality temporal locality no locality d spatial locality temporal locality no locality f spatial locality temporal locality no locality j spatial locality temporal locality no locality y spatial locality temporal locality no locality z spatial locality temporal locality no locality Page 9 of 10

### CSE 373 Autumn 2012: Midterm #2 (closed book, closed notes, NO calculators allowed)

Name: Sample Solution Email address: CSE 373 Autumn 0: Midterm # (closed book, closed notes, NO calculators allowed) Instructions: Read the directions for each question carefully before answering. We may

### CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators)

_ UWNetID: Lecture Section: A CSE 332 Winter 2015: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will give

### CSE373 Fall 2013, Second Midterm Examination November 15, 2013

CSE373 Fall 2013, Second Midterm Examination November 15, 2013 Please do not turn the page until the bell rings. Rules: The exam is closed-book, closed-note, closed calculator, closed electronics. Please

### CS350: Data Structures Heaps and Priority Queues

Heaps and Priority Queues James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Priority Queue An abstract data type of a queue that associates a priority

### Priority Queues (Heaps)

Priority Queues (Heaps) 1 Priority Queues Many applications require that we process records with keys in order, but not necessarily in full sorted order. Often we collect a set of items and process the

### 3. Priority Queues. ADT Stack : LIFO. ADT Queue : FIFO. ADT Priority Queue : pick the element with the lowest (or highest) priority.

3. Priority Queues 3. Priority Queues ADT Stack : LIFO. ADT Queue : FIFO. ADT Priority Queue : pick the element with the lowest (or highest) priority. Malek Mouhoub, CS340 Winter 2007 1 3. Priority Queues

### Binary Heaps. COL 106 Shweta Agrawal and Amit Kumar

Binary Heaps COL Shweta Agrawal and Amit Kumar Revisiting FindMin Application: Find the smallest ( or highest priority) item quickly Operating system needs to schedule jobs according to priority instead

### BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015

BINARY HEAP cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -assignment 10 is due on Thursday -midterm grades out tomorrow 3 last time 4 -a hash table is a general storage

### CSE 100 Disjoint Set, Union Find

CSE 100 Disjoint Set, Union Find Union-find using up-trees The union-find data structure 1 0 2 6 7 4 3 5 8 Perform these operations: Find(4) =! Find(3) =! Union(1,0)=! Find(4)=! 2 Array representation

### Binary Heaps. CSE 373 Data Structures Lecture 11

Binary Heaps CSE Data Structures Lecture Readings and References Reading Sections.1-. //0 Binary Heaps - Lecture A New Problem Application: Find the smallest ( or highest priority) item quickly Operating

### Midterm II Exam Principles of Imperative Computation Frank Pfenning. March 31, 2011

Midterm II Exam 15-122 Principles of Imperative Computation Frank Pfenning March 31, 2011 Name: Sample Solution Andrew ID: fp Section: Instructions This exam is closed-book with one sheet of notes permitted.

### Q1 Q2 Q3 Q4 Q5 Q6 Total

Name: SSN: Computer Science Foundation Exam May 5, 006 Computer Science Section 1A Q1 Q Q3 Q4 Q5 Q6 Total KNW KNW KNW ANL,DSN KNW DSN You have to do all the 6 problems in this section of the exam. Partial

### Algorithms and Data Structures

Algorithms and Data Structures Dr. Malek Mouhoub Department of Computer Science University of Regina Fall 2002 Malek Mouhoub, CS3620 Fall 2002 1 6. Priority Queues 6. Priority Queues ffl ADT Stack : LIFO.

### ! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge

Trees (& Heaps) Week 12 Gaddis: 20 Weiss: 21.1-3 CS 5301 Spring 2015 Jill Seaman 1 Tree: non-recursive definition! Tree: set of nodes and directed edges - root: one node is distinguished as the root -

### CMSC 341 Lecture 14: Priority Queues, Heaps

CMSC 341 Lecture 14: Priority Queues, Heaps Prof. John Park Based on slides from previous iterations of this course Today s Topics Priority Queues Abstract Data Type Implementations of Priority Queues:

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

Priority Queues An internet router receives data packets, and forwards them in the direction of their destination. When the line is busy, packets need to be queued. Some data packets have higher priority

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

COSC 2007 Data Structures II Final Exam Thursday, April 13 th, 2006 This is a closed book and closed notes exam. There are total 3 parts. Please answer the questions in the provided space and use back

### CSE 373 Data Structures and Algorithms. Lecture 15: Priority Queues (Heaps) III

CSE 373 Data Structures and Algorithms Lecture 15: Priority Queues (Heaps) III Generic Collections Generics and arrays public class Foo { private T myfield; // ok } public void method1(t param) { myfield

### CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total

CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Please check your tutorial (TUT) section from the list below: TUT 101: F 11:30, MC 4042 TUT 102: M 10:30, MC 4042 TUT 103: M 11:30, MC 4058 TUT 104: F 10:30,

### CSE 214 Computer Science II Heaps and Priority Queues

CSE 214 Computer Science II Heaps and Priority Queues Spring 2018 Stony Brook University Instructor: Shebuti Rayana shebuti.rayana@stonybrook.edu http://www3.cs.stonybrook.edu/~cse214/sec02/ Introduction

### Cpt S 223 Fall Cpt S 223. School of EECS, WSU

Course Review Cpt S 223 Fall 2012 1 Final Exam When: Monday (December 10) 8 10 AM Where: in class (Sloan 150) Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes

### Figure 1: A complete binary tree.

The Binary Heap A binary heap is a data structure that implements the abstract data type priority queue. That is, a binary heap stores a set of elements with a total order (that means that every two elements

### Data Structures. Giri Narasimhan Office: ECS 254A Phone: x-3748

Data Structures Giri Narasimhan Office: ECS 254A Phone: x-3748 giri@cs.fiu.edu Motivation u Many applications where Items have associated priorities Job scheduling Long print jobs vs short ones; OS jobs

### York University AK/ITEC INTRODUCTION TO DATA STRUCTURES. Final Sample II. Examiner: S. Chen Duration: Three hours

York University AK/ITEC 262 3. INTRODUCTION TO DATA STRUCTURES Final Sample II Examiner: S. Chen Duration: Three hours This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g.

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

7.2 Binary Min-Heaps A heap is a tree-based structure, but it doesn t use the binary-search differentiation between the left and right sub-trees to create a linear ordering. Instead, a binary heap only

### 9. Heap : Priority Queue

9. Heap : Priority Queue Where We Are? Array Linked list Stack Queue Tree Binary Tree Heap Binary Search Tree Priority Queue Queue Queue operation is based on the order of arrivals of elements FIFO(First-In

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

University of Illinois at Urbana-Champaign Department of Computer Science Final Examination CS 225 Data Structures and Software Principles Spring 2010 7-10p, Wednesday, May 12 Name: NetID: Lab Section

### BINARY SEARCH TREES cs2420 Introduction to Algorithms and Data Structures Spring 2015

BINARY SEARCH TREES cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -assignment 7 due tonight at midnight -asking for regrades through assignment 5 and midterm must

### CS 315 Data Structures Spring 2012 Final examination Total Points: 80

CS 315 Data Structures Spring 2012 Final examination Total Points: 80 Name This is an open-book/open-notes exam. Write the answers in the space provided. Answer for a total of 80 points, including at least

1 19 Sorting 2 19.1 Introduction (Cont.) Sorting data Place data in order Typically ascending or descending Based on one or more sort keys Algorithms Insertion sort Selection sort Merge sort More efficient,

### CS171 Final Practice Exam

CS171 Final Practice Exam Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 150 minutes to complete this exam. Read each problem carefully, and review your

### Final Examination CSE 100 UCSD (Practice)

Final Examination UCSD (Practice) RULES: 1. Don t start the exam until the instructor says to. 2. This is a closed-book, closed-notes, no-calculator exam. Don t refer to any materials other than the exam

### Heaps. Heaps. A heap is a complete binary tree.

A heap is a complete binary tree. 1 A max-heap is a complete binary tree in which the value in each internal node is greater than or equal to the values in the children of that node. A min-heap is defined

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

CSE 2100 Data Structures and Introduction to Algorithms...! In Java!! Instructor: Fei Wang! Mid-Term Exam CSE2100 DS & Algorithms 1 1. True or False (20%=2%x10)! (1) O(n) is O(n^2) (2) The height h of

### Draw the resulting binary search tree. Be sure to show intermediate steps for partial credit (in case your final tree is incorrect).

Problem 1. Binary Search Trees (36 points) a) (12 points) Assume that the following numbers are inserted into an (initially empty) binary search tree in the order shown below (from left to right): 42 36

### Priority Queues. 1 Introduction. 2 Naïve Implementations. CSci 335 Software Design and Analysis III Chapter 6 Priority Queues. Prof.

Priority Queues 1 Introduction Many applications require a special type of queuing in which items are pushed onto the queue by order of arrival, but removed from the queue based on some other priority

### Sorting and Searching

Sorting and Searching Lecture 2: Priority Queues, Heaps, and Heapsort Lecture 2: Priority Queues, Heaps, and Heapsort Sorting and Searching 1 / 24 Priority Queue: Motivating Example 3 jobs have been submitted

### Heaps, Heap Sort, and Priority Queues.

Heaps, Heap Sort, and Priority Queues Sorting III / Slide 2 Background: Binary Trees Has a root at the topmost level Each node has zero, one or two children A node that has no child is called a leaf For

### Second Examination Solution

University of Illinois at Urbana-Champaign Department of Computer Science Second Examination Solution CS 225 Data Structures and Software Principles Fall 2007 7p-9p, Thursday, November 8 Name: NetID: Lab

### CMSC 341 Leftist Heaps

CMSC 341 Leftist Heaps Based on slides from previous iterations of this course Today s Topics Review of Min Heaps Introduction of Left-ist Heaps Merge Operation Heap Operations Review of Heaps Min Binary

### CS 310: Priority Queues and Binary Heaps

CS 310: Priority Queues and Binary Heaps Chris Kauffman Week 14-2 Priority Queues Queue What operations does a queue support? Priority: Number representing importance Convention lower is better priority

### Spring 2002: Fundamental Structures of Computer Science

Spring 2002: 15-211 Fundamental Structures of Computer Science Midterm Name: Andrew ID: Section or TA name: Instructions Fill out the Name/Andrew ID/Section box above now. This exam is open book, plus

### Course Review. Cpt S 223 Fall 2009

Course Review Cpt S 223 Fall 2009 1 Final Exam When: Tuesday (12/15) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program

### ( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

CSE 0 Name Test Fall 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally

### Fast 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

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

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

### Data Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions.

DATA STRUCTURES COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges book. Data

### CS106X Handout 35 Winter 2018 March 12 th, 2018 CS106X Midterm Examination

CS106X Handout 35 Winter 2018 March 12 th, 2018 CS106X Midterm Examination This is an open-book, open-note, closed-electronic-device exam. You needn t write #includes, and you may (and you re even encouraged

### COS 226 Algorithms and Data Structures Fall Midterm Solutions

1 COS 226 Algorithms and Data Structures Fall 2010 Midterm Solutions 1. Analysis of algorithms. (a) For each expression in the left column, give the best matching description from the right column. B.

### Homework 3. Theory (50 points) Data Structures and Algorithms in JAVA Shlomo Hershkop Department of Computer Science Columbia University Summer 2002

Homework 3 Data Structures and Algorithms in JAVA Shlomo Hershkop Department of Computer Science Columbia University Summer 2002 Due Thursday, Aug 1 (at beginning of class) Theory (50 points) 1. (5 points)

### Data Structures in Java. Session 18 Instructor: Bert Huang

Data Structures in Java Session 18 Instructor: Bert Huang http://www.cs.columbia.edu/~bert/courses/3134 Announcements Homework posted, due 11/24 Old homeworks, midterm exams Review Shortest Path algorithms

### Examination Questions Midterm 2

CS1102s Data Structures and Algorithms 12/3/2010 Examination Questions Midterm 2 This examination question booklet has 6 pages, including this cover page, and contains 12 questions. You have 30 minutes

### 8. Binary Search Tree

8 Binary Search Tree Searching Basic Search Sequential Search : Unordered Lists Binary Search : Ordered Lists Tree Search Binary Search Tree Balanced Search Trees (Skipped) Sequential Search int Seq-Search

### Computer Science Foundation Exam

Computer Science Foundation Exam December 13, 2013 Section I A COMPUTER SCIENCE NO books, notes, or calculators may be used, and you must work entirely on your own. SOLUTION Question # Max Pts Category

### CS 315 Data Structures mid-term 2

CS 315 Data Structures mid-term 2 1) Shown below is an AVL tree T. Nov 14, 2012 Solutions to OPEN BOOK section. (a) Suggest a key whose insertion does not require any rotation. 18 (b) Suggest a key, if

### Figure 1: A complete binary tree.

The Binary Heap A binary heap is a data structure that implements the abstract data type priority queue. That is, a binary heap stores a set of elements with a total order (that means that every two elements

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

University of Illinois at Urbana-Champaign Department of Computer Science Final Examination CS 225 Data Structures and Software Principles Fall 2009 7-10p, Tuesday, December 15 Name: NetID: Lab Section

### Recitation 9. Prelim Review

Recitation 9 Prelim Review 1 Heaps 2 Review: Binary heap min heap 1 2 99 4 3 PriorityQueue Maintains max or min of collection (no duplicates) Follows heap order invariant at every level Always balanced!

### CS61B Lecture #23. Today: Priority queues (Data Structures 6.4, 6.5) Range queries ( 6.2) Java utilities: SortedSet, Map, etc.

CS61B Lecture #23 Today: Priority queues (Data Structures 6., 6.5) Range queries ( 6.2) Java utilities: SortedSet, Map, etc. Next topic: Hashing (Data Structures Chapter 7). Last modified: Sat Oct 15 16:1:5

### Sorting and Selection

Sorting and Selection Introduction Divide and Conquer Merge-Sort Quick-Sort Radix-Sort Bucket-Sort 10-1 Introduction Assuming we have a sequence S storing a list of keyelement entries. The key of the element

### # Points # Points. Total 120

Practice Midterm 2 This test has 10 questions worth a total of 120 points, and is to be completed in 110 minutes. The exam is closed book, except that you are allowed to use one double sided written cheat

### Tree: non-recursive definition. Trees, Binary Search Trees, and Heaps. Tree: recursive definition. Tree: example.

Trees, Binary Search Trees, and Heaps CS 5301 Fall 2013 Jill Seaman Tree: non-recursive definition Tree: set of nodes and directed edges - root: one node is distinguished as the root - Every node (except

### COS 226 Algorithms and Data Structures Spring Midterm

COS 226 Algorithms and Data Structures Spring 2015 Midterm This test has 9 questions worth a total of 55 points. You have 0 minutes. The exam is closed book, except that you are allowed to use a one page

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

CS61B Fall 2011 UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division Test #2 Solutions P. N. Hilfinger 1. [3 points] Consider insertion sort, merge

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

Lecture 16 Hashing Hash table and hash function design Hash functions for integers and strings Collision resolution strategies: linear probing, double hashing, random hashing, separate chaining Hash table

### CSE 214 Computer Science II Searching

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

### CSE 373: Data Structures and Algorithms

CSE 373: Data Structures and Algorithms Lecture 19: Comparison Sorting Algorithms Instructor: Lilian de Greef Quarter: Summer 2017 Today Intro to sorting Comparison sorting Insertion Sort Selection Sort

### Database Applications (15-415)

Database Applications (15-415) DBMS Internals- Part V Lecture 13, March 10, 2014 Mohammad Hammoud Today Welcome Back from Spring Break! Today Last Session: DBMS Internals- Part IV Tree-based (i.e., B+

### CSCE 2014 Final Exam Spring Version A

CSCE 2014 Final Exam Spring 2017 Version A Student Name: Student UAID: Instructions: This is a two-hour exam. Students are allowed one 8.5 by 11 page of study notes. Calculators, cell phones and computers

### Sorting. Two types of sort internal - all done in memory external - secondary storage may be used

Sorting Sunday, October 21, 2007 11:47 PM Two types of sort internal - all done in memory external - secondary storage may be used 13.1 Quadratic sorting methods data to be sorted has relational operators

### Table ADT and Sorting. Algorithm topics continuing (or reviewing?) CS 24 curriculum

Table ADT and Sorting Algorithm topics continuing (or reviewing?) CS 24 curriculum A table ADT (a.k.a. Dictionary, Map) Table public interface: // Put information in the table, and a unique key to identify

### HASH TABLES. Goal is to store elements k,v at index i = h k

CH 9.2 : HASH TABLES 1 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM JORY DENNY AND

### 22c:31 Algorithms. Kruskal s Algorithm for MST Union-Find for Disjoint Sets

22c:1 Algorithms Kruskal s Algorithm for MST Union-Find for Disjoint Sets 1 Kruskal s Algorithm for MST Work with edges, rather than nodes Two steps: Sort edges by increasing edge weight Select the first

### COSC160: Data Structures Heaps. Jeremy Bolton, PhD Assistant Teaching Professor

COSC160: Data Structures Heaps Jeremy Bolton, PhD Assistant Teaching Professor Outline I. Priority Queue II. Heaps I. Binary Heaps II. Skew Heaps Balancing a Tree Binary trees lack a depth constraint.

### Open Addressing: Linear Probing (cont.)

Open Addressing: Linear Probing (cont.) Cons of Linear Probing () more complex insert, find, remove methods () primary clustering phenomenon items tend to cluster together in the bucket array, as clustering

### CSE 2123: Collections: Priority Queues. Jeremy Morris

CSE 2123: Collections: Priority Queues Jeremy Morris 1 Collections Priority Queue Recall: A queue is a specific type of collection Keeps elements in a particular order We ve seen two examples FIFO queues

### ( D. Θ n. ( ) f n ( ) D. Ο%

CSE 0 Name Test Spring 0 Multiple Choice. Write your answer to the LEFT of each problem. points each. The time to run the code below is in: for i=n; i>=; i--) for j=; j

### COS 226 Algorithms and Data Structures Spring Midterm

COS 226 Algorithms and Data Structures Spring 2012 Midterm This test has 9 questions worth a total of 60 points. You have 80 minutes. The exam is closed book, except that you are allowed to use a one page

### CSE 2320 Section 002, Fall 2015 Exam 2 Time: 80 mins

CSE 2320 Section 002, Fall 201 Exam 2 Time: 80 mins Name:. Student ID:. Total exam points: 100. Question Points Out of 1 24 2 10 3 10 4 18 6 1 16 Total 100 If you have the smallest doubt about what a question

### Announcements. Midterm exam 2, Thursday, May 18. Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps. Break around 11:45am

Announcements Midterm exam 2, Thursday, May 18 Closed book/notes but one sheet of paper allowed Covers up to stacks and queues Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps

### Data Structures in Java. Session 18 Instructor: Bert Huang

Data Structures in Java Session 18 Instructor: Bert Huang http://www.cs.columbia.edu/~bert/courses/3134 Announcements Homework 4 due Homework 5 posted, due 11/24 Graph theory problems Programming: All-pairs

### (D) There is a constant value n 0 1 such that B is faster than A for every input of size. n n 0.

Part : Multiple Choice Enter your answers on the Scantron sheet. We will not mark answers that have been entered on this sheet. Each multiple choice question is worth. marks. Note. when you are asked to

### Chapter 12: Indexing and Hashing

Chapter 12: Indexing and Hashing Basic Concepts Ordered Indices B+-Tree Index Files B-Tree Index Files Static Hashing Dynamic Hashing Comparison of Ordered Indexing and Hashing Index Definition in SQL

### Priority Queues, Binary Heaps, and Heapsort

Priority Queues, Binary eaps, and eapsort Learning Goals: Provide examples of appropriate applications for priority queues and heaps. Implement and manipulate a heap using an array as the underlying data

### e 10 6 Exam 1 Solutions edges l lnext rnext firstedge a b c d e 0 f Jonathan Turner 9/29/05 CS 542 Advanced Data Structures and Algorithms

CS Advanced Data Structures and Algorithms Exam Solutions Jonathan Turner //0 Be neat and concise, but complete.. ( points) An incomplete instance of the wgraph data structure is shown below. Fill in all

### # Points # Points. Total 120

Practice Midterm 2- Solutions This test has 10 questions worth a total of 120 points, and is to be completed in 110 minutes. The exam is closed book, except that you are allowed to use one double sided

### CSC 421: Algorithm Design Analysis. Spring 2013

CSC 421: Algorithm Design Analysis Spring 2013 Transform & conquer transform-and-conquer approach presorting balanced search trees, heaps Horner's Rule problem reduction 1 Transform & conquer the idea

### HEAPS: IMPLEMENTING EFFICIENT PRIORITY QUEUES

HEAPS: IMPLEMENTING EFFICIENT PRIORITY QUEUES 2 5 6 9 7 Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich, R. Tamassia, and M. H., Wiley, 2014

### - 1 - Handout #22S May 24, 2013 Practice Second Midterm Exam Solutions. CS106B Spring 2013

CS106B Spring 2013 Handout #22S May 24, 2013 Practice Second Midterm Exam Solutions Based on handouts by Eric Roberts and Jerry Cain Problem One: Reversing a Queue One way to reverse the queue is to keep

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

CS 251, LE 2 Fall 2016 MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY W1.) (i) Show one possible valid 2-3 tree containing the nine elements: 1 3 4 5 6 8 9 10 12. (ii) Draw the final binary search

### Chapter 11: Indexing and Hashing

Chapter 11: Indexing and Hashing Basic Concepts Ordered Indices B + -Tree Index Files B-Tree Index Files Static Hashing Dynamic Hashing Comparison of Ordered Indexing and Hashing Index Definition in SQL

### n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

CSE 220 Name Test Fall 20 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 4 points each. The time to compute the sum of the n elements of an integer array is in:

### CS 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

Lecture Note 05 CSE40/50 SKEW HEAPS: Self-Adjusting Heaps In this handout we describe the skew heap data structure, a self-adjusting form of heap related to the leftist heap of Crane and Knuth. Skew heaps,

### Binary Trees. BSTs. For example: Jargon: Data Structures & Algorithms. root node. level: internal node. edge.

Binary Trees 1 A binary tree is either empty, or it consists of a node called the root together with two binary trees called the left subtree and the right subtree of the root, which are disjoint from

### Range Queries. Kuba Karpierz, Bruno Vacherot. March 4, 2016

Range Queries Kuba Karpierz, Bruno Vacherot March 4, 2016 Range query problems are of the following form: Given an array of length n, I will ask q queries. Queries may ask some form of question about a

### Binary Search Trees > = 2014 Goodrich, Tamassia, Goldwasser. Binary Search Trees 1

Binary Search Trees < > = Binary Search Trees 1 Ordered Dictionary (Map) ADT get (k): record with key k put (k,data): add record (k,data) remove (k): delete record with key k smallest(): record with smallest