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

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

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

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

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

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

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

CSE373 Fall 2013, Midterm Examination October 18, 2013

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

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

CSE 332, Spring 2010, Midterm Examination 30 April 2010

CSE373 Winter 2014, Midterm Examination January 29, 2014

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

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

CSE332 Summer 2010: Midterm Exam Sample Solutions

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

COMP 250 Midterm #2 March 11 th 2013

Midterm solutions. n f 3 (n) = 3

CSE 373: Practice Final

Practice Midterm Exam Solutions

CS171 Midterm Exam. October 29, Name:

CSE wi: Practice Midterm

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

CSE373 Midterm I Fall 2009 (Closed book, closed notes)

COMP171 Data Structures and Algorithms Fall 2006 Midterm Examination

Section 05: Midterm Review

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

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

Section 03: Asymptotic Analysis

Q1 Q2 Q3 Q4 Q5 Q6 Total

CS171 Final Practice Exam

CS171 Final Practice Exam

EECS 311 Data Structures Midterm Exam Don t Panic!

Exam Data structures DAT036/DAT037/DIT960

Test #2. Login: 2 PROBLEM 1 : (Balance (6points)) Insert the following elements into an AVL tree. Make sure you show the tree before and after each ro

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

Assignment 8 CSCE 156/156H/RAIK 184H Spring 2017

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

CSE 373 Spring Midterm. Friday April 21st

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

CS 216 Exam 1 Fall SOLUTION

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

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

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL

Priority Queues. 04/10/03 Lecture 22 1

ECE250: Algorithms and Data Structures Midterm Review

UNIVERSITY REGULATIONS

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

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

Second Examination Solution

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

Recall: Properties of B-Trees

Prelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Computer Science Foundation Exam

Computer Science Foundation Exam

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

CSE 100 Practice Final Exam

Major2 Examination Term: 162 Year: 2016/2017

ECE242 Data Structures and Algorithms Fall 2008

Recitation 9. Prelim Review

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

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 )

Problem Set 6 Due: 11:59 Sunday, April 29

Section 1: True / False (2 points each, 30 pts total)

Computer Science Foundation Exam. Dec. 19, 2003 COMPUTER SCIENCE I. Section I A. No Calculators! KEY

CSE373: Data Structures & Algorithms Lecture 9: Priority Queues. Aaron Bauer Winter 2014

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

FACULTY OF SCIENCE ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING ADVANCED DATA STRUCTURES AND ALGORITHMS EXAM EXAMINATION JUNE 2014

CS 315 Data Structures mid-term 2

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

Binary Heaps. COL 106 Shweta Agrawal and Amit Kumar

Computer Science E-22 Practice Final Exam

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

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

c) A perfect ternary tree of height h? (In a ternary tree, each node may have up to three children.)

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

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 332 Autumn 2016 Final Exam (closed book, closed notes, no calculators)

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

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

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

CSE 373 NOVEMBER 8 TH COMPARISON SORTS

Prelim 2 Solution. CS 2110, November 19, 2015, 7:30 PM Total. Sorting Invariants Max Score Grader

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.

Part I: Short Answer (12 questions, 65 points total)

Basic Data Structures (Version 7) Name:

CSE 214 Computer Science II Heaps and Priority Queues

UNIVERSITY REGULATIONS

CSE 373: Data Structures and Algorithms

Prelim 2 Solution. CS 2110, November 19, 2015, 5:30 PM Total. Sorting Invariants Max Score Grader

Exam I Principles of Imperative Computation, Summer 2011 William Lovas. May 27, 2011

Computer Science Spring 2005 Final Examination, May 12, 2005

Name Section Number. CS210 Exam #3 *** PLEASE TURN OFF ALL CELL PHONES*** Practice

CPSC 331 Term Test #2 March 26, 2007

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

Computer Science Foundation Exam. May 6, Computer Science. Section 1A. No Calculators! KEY. Score: 50

Transcription:

Name: Email address: CSE 373 Winter 2009: Midterm #1 (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 which 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: 85 points. Time: 50 minutes. Question Max Points 1 16 2 8 3 13 4 14 5 6 6 18 7 10 Total 85 Score Page 1 of 10

1. (16 pts) Big-O 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. You MUST choose your answer from the following (not given in any particular order), each of which could be re-used (could be the answer for more than one of a) h)): O(N 2 ), O(N 3 log N), O(N log N), O(N), O(N 2 log N), O(N 5 ), O(2 N ), O(N 3 ), O(log N), O(1), O(N 4 ), O(N N ) You do not need to explain your answer. a) f(n) = N (100N + 200N 3 ) + N 3 b) f(n) = N 2 log N + N 3 + 1000 4 c) f(n) = 100N + (N/2) log (N/2) + N/4 d) f(n) = (N/4) +N 1/2 e) f(n) = N log(n 4 ) + 3 N 2 f) f(n) = (N 3 + N 1 ) / N g) f(n) = 400 N 2 20N h) f(n) = N 2 log N + N log (N 2 ) Page 2 of 10

2. (8 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. Showing your work is not required (although showing work may allow some partial credit in the case your answer is wrong don t spend a lot of time showing your work.). You MUST choose your answer from the following (not given in any particular order), each of which could be re-used (could be the answer for more than one of I. IV.): O(n 2 ), O(n 3 log n), O(n log n), O(n), O(n 2 log n), O(n 5 ), O(2 n ), O(n 3 ), O(log n), O(1), O(n 4 ), O(n n ) I. void silly(int n) { for (int i = 0; i < n; ++i) { for (int j = 0; j < i; ++j) { System.out.println( j = + j); for (int k = 0; k < j; ++k) System.out.println( k = + k); Runtime: II. void silly(int n, int x, int y) { for (int i = 0; i < n; ++i) { if (x > y) { for (int j = 0; j < n; ++j) System.out.println( j = + j); for (int k = 0; k < n * n; ++k) System.out.println( k = + k); else System.out.println( i = + i); III. void silly(int n, int m) { if (m > n) return; System.out.println( m = + m); silly(n, m+2); IV. void silly(int n) { for (int i = 0; i < n; i = i + 10) { for (int j = 0; j < i; ++j) { System.out.println( i = + i); System.out.println( j = + j); Page 3 of 10

3. (13 pts) Read each question carefully. Explanations are not necessary, but may yield partial credit. You must solve any summations or recurrences for full credit. a) (3 pts) What is the minimum and maximum number of nodes at depth d in a perfect binary tree? Be sure to list the nodes at depth d. Do not include nodes at depth d-1 or d+1 or other depths. (Hint: the root is at depth 0) Minimum = Maximum = b) (4 pts) What is the minimum and maximum number of nodes in a balanced AVL tree of height 5? Minimum = Maximum = c) (4 pts) You are given a binary min heap of height h. The minimum and maximum number of comparisons we might have to do when inserting the next value (in terms of h) is: Minimum = Maximum = d) (2 pts) A full binary tree satisfies the AVL balance condition at each node. (circle one) TRUE or FALSE Page 4 of 10

4. (14 pts) Trees a.) (6 pts) Give traversals of the tree shown below: In-Order: Post-Order: Pre-Order: b.) (8 pts) Given the following tree: 14 9 36 10 30 50 Circle yes or no to indicate whether the tree above might represent each of the following data structures. If you circle no, you must draw a new picture containing the same values that satisfies the given condition.). 1) AVL tree yes no 2) Binary Search Tree yes no 3) Complete Tree yes no 4) Binary Min Heap yes no Draw and label any necessary pictures here: 31 Page 5 of 10

5. (6 pts) AVL Trees Draw the AVL tree that results from inserting the keys: 3, 9, 2, 7, 4, 5, 8 in that order into an initially empty AVL tree. You are only required to show the final tree, although drawing intermediate trees may result in partial credit. If you draw intermediate trees, please circle your final tree for ANY credit. Page 6 of 10

6. (18 pts) Running Time Analysis: Give the tightest possible upper bound for the worst case running time for each of the following in terms of N. You MUST choose your answer from the following (not given in any particular order), each of which could be reused (could be the answer for more than one of a) f)): O(N 2 ), O(N 3 log N), O(N log N), O(N), O(N 2 log N), O(N 5 ), O(2 N ), O(N 3 ), O(log N), O(1), O(N 4 ), O(N N ) **For any credit, you must explain your answer. Assume that the most time-efficient implementation is used. Assume that all keys are distinct. a) Inserting N values into an initially empty Binary Search Tree a) b) Finding the minimum value in a Binary Min Heap of size N b) c) Inserting a value into a Binary Search Tree of size N, where the value you are inserting c) is the median value when compared to values currently in the tree. d) Dequeue from a queue containing N elements implemented as a circular array (as described in lecture) d) e) Pre-order traversal of a Perfect Binary Tree containing N elements e) f) Finding the maximum value in an AVL Tree containing N elements. f) Page 7 of 10

7. (10 pts total) Binary Min Heaps (a) [6 points] Draw the binary min heap that results from inserting 4, 9, 3, 7, 2, 5, 8, 6 in that order into an initially empty binary min heap. You do not need to show the array representation of the heap. You are only required to show the final tree, although drawing intermediate trees may result in partial credit. If you draw intermediate trees, please circle your final result for any credit. Page 8 of 10

7. (cont.) (b) [2 points] Draw the result of one deletemin call on your heap draw in part (a). (c) [2 points] Draw the result of one deletemin call on your heap draw in part (b). Page 9 of 10

Scratch Paper Page Page 10 of 10