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

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

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

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

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)

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

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

CSE 332, Spring 2010, Midterm Examination 30 April 2010

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

CSE332 Summer 2010: Midterm Exam Sample Solutions

CSE373 Fall 2013, Midterm Examination October 18, 2013

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

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

CSE wi: Practice Midterm

Practice Midterm Exam Solutions

ECE250: Algorithms and Data Structures Midterm Review

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

Section 05: Midterm Review

CS171 Final Practice Exam

CS171 Final Practice Exam

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

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

CS171 Midterm Exam. October 29, Name:

CSE373 Winter 2014, Midterm Examination January 29, 2014

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

CPSC 331 Term Test #2 March 26, 2007

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

Computer Science Foundation Exam

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

Computer Science E-22 Practice Final Exam

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

COMP 250 Midterm #2 March 11 th 2013

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

Final Examination CSE 100 UCSD (Practice)

Course Review. Cpt S 223 Fall 2009

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

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

Computer Science Foundation Exam

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

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

Course Review. Cpt S 223 Fall 2010

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

CSL 201 Data Structures Mid-Semester Exam minutes

CSE 373 Spring Midterm. Friday April 21st

ECE242 Data Structures and Algorithms Fall 2008

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

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

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

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

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 )

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

UNIVERSITY REGULATIONS

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

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

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

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;

21# 33# 90# 91# 34# # 39# # # 31# 98# 0# 1# 2# 3# 4# 5# 6# 7# 8# 9# 10# #

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

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

Spring 2002: Fundamental Structures of Computer Science

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

Q1 Q2 Q3 Q4 Q5 Q6 Total

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n))

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

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

CSE100 Practice Final Exam Section C Fall 2015: Dec 10 th, Problem Topic Points Possible Points Earned Grader

INSTITUTE OF AERONAUTICAL ENGINEERING

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

CS210 (161) with Dr. Basit Qureshi Final Exam Weight 40%

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

Introduction to Algorithms March 12, 2008 Massachusetts Institute of Technology Spring 2008 Professors Srini Devadas and Erik Demaine Quiz 1

Computer Science Foundation Exam

CS 315 Data Structures mid-term 2

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

COMP171 Data Structures and Algorithms Fall 2006 Midterm Examination

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

CS 216 Exam 1 Fall SOLUTION

Spring 2013 CS 122C & CS 222 Midterm Exam (and Comprehensive Exam, Part I) (Max. Points: 100)

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination T09:00

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

Section 05: Solutions

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

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

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].

CSE 373: Practice Final

How many leaves on the decision tree? There are n! leaves, because every permutation appears at least once.

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

Total Score /1 /20 /41 /15 /23 Grader

17 February Given an algorithm, compute its running time in terms of O, Ω, and Θ (if any). Usually the big-oh running time is enough.

COS 226 Midterm Exam, Spring 2009

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

Sample Exam 1 Questions

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

PROBLEM 1 : (And the winner is...(12 points)) Assume you are considering the implementation of a priority queue that will always give you the smallest

Priority Queues Heaps Heapsort

COS 226 Algorithms and Data Structures Spring Midterm Exam

Computer Science Foundation Exam

Section 05: Solutions

Transcription:

Name: Email address: Quiz Section: CSE 332 Spring 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 8 7 8 8 14 9 14 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. You do not need to explain your answer. a) f(n) = N log N + N log log N b) f(n) = 50 log N 2 + 100 ( log N) 2 c) f(n) = N log 2 (4 N ) d) Push in a stack containing N elements implemented using linked list nodes (worst case) e) A preorder traversal in a binary search tree containing N elements (worst case) f) Insert in a separate chaining hash table containing N elements where each bucket points to an AVL tree (worst case) g) IncreaseKey(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 increased. (worst case) h) T(N) = T(N-1) + N i) T(N) = T(N/2) + 100 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. int sunny (int n) { if (n < 10) return n - 1; else { return sunny (n / 2); } } Runtime: II. int funny (int n, int sum) { for (int k = 0; k < n * n; ++k) for (int j = 0; j < k; j++) sum++; return sum; } III. int happy (int n, int sum) { for (int k = n; k > 0; k = k - 1) { for (int i = 0; i < k; i++) sum++; for (int j = n; j > 0; j--) sum++; } } return sum; Page 3 of 12

3. (10 pts) Big-O, Big Ω, Big (2 pts each) For parts (a) (c) circle whether the statement is true or false. Part (d) has its own instructions. You do not need to show your work for parts (a) (c). TRUE / FALSE a) 5N 2 + 100N = Ω (N) TRUE / FALSE b) 100N 2 + N 3 + 10N = (N 3 ) TRUE / FALSE c) 50 N 2 + 10N + 20 = Ω (N 2 ) d) (4 points) Demonstrate that: 10n 2 + 5n +42 is O(n 2 ) by finding positive integers c and n 0 such that the definition of Big Oh is satisfied. For full credit you must do more than just giving values for c and n 0. You do not need to give a proof, just briefly demonstrate why your constants are appropriate. 4 of 12

4. (6 pts) Recurrence Relationships - Suppose that the running time of an algorithm satisfies the recurrence relationship and T(1) = 5. T(N) = T(N-1) + 7 for 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 9, 8, 4, 3, 1, 6, 7 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. (8 pts) AVL Trees a) ( 2 pts) What is the minimum number of nodes in an AVL tree of height 4? (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 maximum value in an AVL tree of height 4? Give an exact number not a formula. c) ( 2 pts) What is the maximum number of nodes than must be examined in order to find the minimum value in an AVL tree of height 4? Give an exact number not a formula. d) ( 2 pts) Draw an example of an AVL tree of height 4 with the minimum number of nodes. You do not need to put values in the tree, just show the shape using dots for nodes. Page 7 of 12

7. (8 pts) B-trees a) (4 pts) Given M = 6 and L = 20, what is the minimum and maximum number of data items in a B-tree (as defined in lecture and in Weiss) of height 4? Give a single number as your answer, partial credit may be given for showing your work. Minimum number of data items = Maximum number of data items = b) (4 pts) Given the following parameters: 1 Page on disk = 1000 bytes Disk access time = 2 milli-secs per byte Key = 4 bytes Pointer = 16 bytes Data = 30 bytes per record (includes key) Assuming you can place things where you want in memory (in other words this is not a question about Java implementation of B-trees), what are the best values in a B-tree for: and M = L = 8 of 12

8. (14 pts) Hash Tables For a) and b) below, insert the following elements in this order: 72, 21, 10, 20, 1, 31. For each table, TableSize = 10, and you should use the primary hash function h(k) = h%10. If an item cannot be inserted into the table, please indicate this and continue inserting the remaining values. a) Separate chaining hash table use a unsorted linked list for each bucket, insert at front 0 1 2 3 4 5 6 7 8 9 b) Quadratic probing hash table 0 1 2 3 4 5 6 7 8 9 c) What is the load factor in Table a)? d) What is the load factor in Table b)? The following two questions are about hashing generally, NOT about the two tables above. e) What is the big-o worst case running time for a find operation in a linear probing hash table containing N elements? f) What is the big-o worst case running time for an insert operation in a separate chaining hash table containing N elements where each bucket points to a sorted linked list? Page 9 of 12

9. (14 pts) Binary Min Heaps a) (8 pts) Draw the binary min heap that results from inserting 8, 2, 3, 6, 9, 7, 5, 1, 4 in that order into an initially empty binary heap. You do not need to show the array representation of the heap. You are only required to show the final tree, although if you draw intermediate trees, please circle your final result for ANY credit. 10 of 12

9. Binary Min Heaps (continued) b) (2 pts) Draw the result of doing 1 deletemin on the heap you created in part a. You are only required to show the final tree, although if you draw intermediate trees, please circle your final result for ANY credit. c) (4 pts) Given a binary min heap of height h, what is minimum and maximum number of values in the left and right subtrees of the root? Min values in left subtree: Max values in left subtree: Min values in right subtree: Max values in right subtree: 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 25. Draw and circle the resulting tree (including values for interior nodes) below. Use the method for insertion described in lecture and used on homework. 2 10 34 60 77 5 20 65 89 12 of 12