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

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

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

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

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

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

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

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

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

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

CSE 332, Spring 2010, Midterm Examination 30 April 2010

CSE332 Summer 2010: Midterm Exam Sample Solutions

CSE373 Fall 2013, Midterm Examination October 18, 2013

Practice Midterm Exam Solutions

CSE 373 Sample Midterm #2 (closed book, closed notes, calculators o.k.)

CSE wi: Practice Midterm

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

CSE 332 Autumn 2016 Final Exam (closed book, closed notes, no calculators)

CS171 Final Practice Exam

ECE250: Algorithms and Data Structures Midterm Review

COMP 250 Midterm #2 March 11 th 2013

How much space does this routine use in the worst case for a given n? public static void use_space(int n) { int b; int [] A;

CS 61B Summer 2005 (Porter) Midterm 2 July 21, SOLUTIONS. Do not open until told to begin

CS171 Final Practice Exam

ECE242 Data Structures and Algorithms Fall 2008

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

Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University

Course Review. Cpt S 223 Fall 2009

CSE373 Winter 2014, Midterm Examination January 29, 2014

Course Review. Cpt S 223 Fall 2010

Section 05: Solutions

CS171 Midterm Exam. October 29, Name:

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

CPSC 331 Term Test #2 March 26, 2007

CS61B Fall 2014 Guerrilla Section 2 This worksheet is quite long. Longer than we ll cover in guerrilla section.

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

Section 05: Midterm Review

Final Examination CSE 100 UCSD (Practice)

Final Exam in Algorithms and Data Structures 1 (1DL210)

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING ECE 250 ALGORITHMS AND DATA STRUCTURES

Computer Science Foundation Exam

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

UNIVERSITY OF WATERLOO DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING E&CE 250 ALGORITHMS AND DATA STRUCTURES

Final Exam in Algorithms and Data Structures 1 (1DL210)

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

Computer Science E-22 Practice Final Exam

CS301 - Data Structures Glossary By

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

Priority Queues Heaps Heapsort

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

Part 1: Multiple Choice Circle only ONE answer. Each multiple choice question is worth 3.5 marks.

Assume you are given a Simple Linked List (i.e. not a doubly linked list) containing an even number of elements. For example L = [A B C D E F].

UNIVERSITY REGULATIONS

INSTITUTE OF AERONAUTICAL ENGINEERING

University of Waterloo Department of Electrical and Computer Engineering ECE250 Algorithms and Data Structures Fall 2014

CLO Assessment CLO1 Q1(10) CLO2 Q2 (10) CLO3 Q4 (10) CLO4 Q3a (4)

Section 4 SOLUTION: AVL Trees & B-Trees

Computer Science Foundation Exam

Basic Data Structures (Version 7) Name:

CSE 373: Practice Final

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

CSE 332 Winter 2018 Final Exam (closed book, closed notes, no calculators)

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions

Computer Science Foundation Exam

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.

Introduction to Algorithms October 12, 2005 Massachusetts Institute of Technology Professors Erik D. Demaine and Charles E. Leiserson Quiz 1.

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

CS 216 Exam 1 Fall SOLUTION

Prelim 2, CS2110. SOLUTION

1. AVL Trees (10 Points)

Second Examination Solution

APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY THIRD SEMESTER B.TECH DEGREE EXAMINATION, JULY 2017 CS205: DATA STRUCTURES (CS, IT)

You must include this cover sheet. Either type up the assignment using theory5.tex, or print out this PDF.

Course Review for Finals. Cpt S 223 Fall 2008

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

Q1 Q2 Q3 Q4 Q5 Q6 Total

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

CSE373 Fall 2013, Final Examination December 10, 2013 Please do not turn the page until the bell rings.

a) For the binary tree shown below, what are the preorder, inorder and post order traversals.

CE 221 Data Structures and Algorithms

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

Sample Exam 1 Questions

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. ECE 345 Algorithms and Data Structures Fall 2012

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

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

CS 315 Data Structures mid-term 2

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

You must print this PDF and write your answers neatly by hand. You should hand in the assignment before recitation begins.

OF VICTORIA EXAMINATIONS- DECEMBER 2010 CSC

Exam Data structures DAT036/DAT037/DIT960

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Section 05: Solutions

Programming Abstractions

Data Structures Question Bank Multiple Choice

Midterm solutions. n f 3 (n) = 3

2016 Spring COP 3502 Final Exam. Date: 4/28/2016. Name:

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

Prelim 2 SOLUTION. 5:30 PM, 25 April Total Question Name Short Search/ Collections Trees Graphs

CSCI2100B Data Structures Heaps

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

Transcription:

Name: Email address: Quiz Section: CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will give partial credit based on the work you write down, so 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: 100 points. Time: 50 minutes. Question Max Points 1 18 2 6 3 10 4 6 5 8 6 6 7 8 8 15 9 15 10 8 Total 100 Score Page 1 of 12

1. (18 pts) Big-Oh (2 pts each) For each of the functions f(n) given below, indicate the tightest bound possible (in other words, giving O(2 N ) as the answer to every question is not likely to result in many points). Unless otherwise specified, all logs are base 2. Your answer should be as tight and simple as possible. For questions that ask about running time of operations, assume that the most efficient implementation is used. You do not need to explain your answer. a) Find in a separate chaining hash table containing N elements where each bucket points to a sorted linked list (worst case) b) Preorder traversal on an AVL tree containing N elements (worst case) c) f(n) = N ( log N) 2 + N log log N d) f(n) = N log 2 (N + N) e) Enqueue in a queue containing N elements implemented using linked list nodes (worst case) f) Determine what the maximum value is in a binary search tree containing N elements (worst case) g) DecreaseKey(k, v) on a binary min heap containing N elements. Assume you have a reference to the key k. v is the amount that k should be decreased. (worst case) h) Merging two binary min heaps containing N elements each. (worst case) i) T(N) = T(N-1) + 5 2 of 12

2. (6 pts) Big-Oh and Run Time Analysis: Describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n. Your answer should be as tight and simple as possible. Showing your work is not required I. void sunny (int n, int sum) { for (int k = n; k > 0; k = k/2) { for (int j = n; j > 0; j--) sum++; } } Runtime: II. int funny (int n) { if (n < 100) return n - 2; else { return funny (n - 2); } } III. int happy (int n, int sum) { for (int k = 0; k < n; k = k++) { for (int i = 0; i < k; i++) sum++; for (int j = n * n; j > 0; j--) sum++; } } return sum; Page 3 of 12

3. (10 pts) Big-O, Big Ω, Big (2 pts each) For parts (a) (e) circle whether the statement is true or false. You do not need to show any work or give an explanation. TRUE / FALSE a) N log N + 100 N = Ω (N 2 ) TRUE / FALSE b) 50 N 2 + N 3 + 10 N 4 = (N 3 ) TRUE / FALSE c) 5 N + (½) N = Ω (N log N) TRUE / FALSE d) N 3 + N 3 = O (N 6 ) TRUE / FALSE e) 5 N log N = Ω (N 2 ) 4 of 12

4. (6 pts) Recurrence Relationships - Suppose that the running time of an algorithm satisfies the recurrence relationship and T(1) = 7. T(N) = T(N-2) + 4 for odd integers N > 1 Find the closed form for T(N) and show your work step by step. In other words express T(N) as a function of N. Your answer should not be in Big-Oh notation show the relevant exact constants in your answer (e.g. don t use C in your answer). Page 5 of 12

5. (8 pts) Draw the AVL tree that results from inserting the keys 5, 1, 4, 7, 8, 9, 2 in that order into an initially empty AVL tree. You are only required to show the final tree, although if you draw intermediate trees, please circle your final result for ANY credit. 6 of 12

6. (6 pts) Trees a) ( 2 pts) What is the minimum number of nodes in an AVL tree of height 5? (Hint: the height of a tree consisting of a single node is 0) Give an exact number not a formula. b) ( 2 pts) What is the minimum number of nodes than must be examined in order to find the minimum value in an AVL tree of height 5? Give an exact number not a formula. c) ( 2 pts) Given a perfect binary tree of height h, what are the minimum and maximum number of nodes in the right subtree of the root? Minimum: Maximum: Page 7 of 12

7. (8 pts) B-trees a) (4 pts) Given a B-tree of height H, give the tight big-o running time for a find operation in terms of M, L, N, and H. Do not simplify your answer it is o.k. to ignore constants and smaller order terms other than those containing M, L, N, or H but do not remove any occurrences of M, L, N, or H from your answers. Worst case running time for a find operation = Best case running time for a find operation = b) (4 pts) Given the following parameters for a B-tree with M= 11 and L = 8: Key Size = 10 bytes Pointer Size = 2 bytes Data Size = 16 bytes per record (includes the key) Assuming that M and L were chosen appropriately, what is the likely size of a disk block on the machine where this implementation will be deployed? Give a numeric answer and a short justification based on two equations using the parameter values above. 8 of 12

8. (15 pts) Hash Tables For a) and b) below, insert the following elements in this order: 51, 30, 39, 10, 19, 40. For each table, TableSize = 10, and you should use the primary hash function h(k) = k%10. If an item cannot be inserted into the table, please indicate this and continue inserting the remaining values. a) Quadratic probing hash table 0 1 2 3 4 5 6 7 8 9 b) Separate chaining hash table use an unsorted linked list for each bucket, insert at front 0 1 2 3 4 5 6 7 8 9 c) What is the load factor in Table a)? d) In a sentence or two, describe one advantage that separate chaining has over quadratic probing? e) In a sentence or two, describe one advantage that linear probing has over quadratic probing? Page 9 of 12

9. (15 pts) Min Three Heaps - As discussed on homework 2, a three heap with n elements can be stored in an array A, where A[0] contains the root of the tree. a) Given indexing that starts at A[0], give the equations for how you would calculate the three children of the value stored at index i as well as the parent. Child 1: Child 2: Child 3: Parent: b) Implement the insertthreeheap method. To avoid ambiguity, please give your answer in Java. You should implement a min heap. You can assume that the array A is big enough to contain all inserted values and that the values you will be inserting are ints > 0 and will not contain duplicates. You do not need to optimize your code by bubbling a hole up/down, but it is fine to do so. You may NOT assume that other methods have been implemented (such as percolateup, percolatedown, swap, etc.), however it is fine to implement such helper methods if you would like to. Assume that you can read and modify the size of the heap. // Given that values are stored in A[0] to A[size-1], // insert val into the min three heap. void insertthreeheap(int[] A, int val) { 10 of 12

9. Min Three Heaps (continued) feel free to use the space on this page as well. Page 11 of 12

10. (8 pts) B-tree Insertion a) (2pts) In the B-Tree shown below, please write in the appropriate values for the interior nodes. b) (2 pts) Based on the picture below, what are the values for M and L? M = L = c) (4 pts) Starting with the B-tree shown below, insert 27. Draw and circle the resulting tree (including values for interior nodes) below. Use the method for insertion described in lecture and used on homework. 3 11 46 72 86 7 22 58 75 99 25 12 of 12