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

Similar documents
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 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

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

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

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 Autumn 2010: Midterm #2 (closed book, closed notes, NO calculators allowed)

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

CSE373 Fall 2013, Midterm Examination October 18, 2013

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

CSE373 Winter 2014, Midterm Examination January 29, 2014

CSE 332, Spring 2010, Midterm Examination 30 April 2010

CSE332 Summer 2010: Midterm Exam Sample Solutions

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

CS171 Midterm Exam. October 29, Name:

CS 216 Exam 1 Fall SOLUTION

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

Practice Midterm Exam Solutions

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

Midterm solutions. n f 3 (n) = 3

COMP171 Data Structures and Algorithms Fall 2006 Midterm Examination

Computer Science E-22 Practice Final Exam

Recitation 9. Prelim Review

CSE 373: Practice Final

Exam Data structures DAT036/DAT037/DIT960

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

ECE242 Data Structures and Algorithms Fall 2008

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

CSE 373 Spring Midterm. Friday April 21st

Computer Science Foundation Exam

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

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

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

CS171 Final Practice Exam

Major2 Examination Term: 162 Year: 2016/2017

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

CS171 Final Practice Exam

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

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

Section 05: Midterm Review

# Points # Points. Total 120

Spring 2002: Fundamental Structures of Computer Science

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

Second Examination Solution

Sample Exam 1 Questions

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

UNIVERSITY REGULATIONS

EECS 311 Data Structures Midterm Exam Don t Panic!

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

COMP 250 Midterm #2 March 11 th 2013

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

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

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

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

Q1 Q2 Q3 Q4 Q5 Q6 Total

Midterm Exam 2 CS 455, Spring 2011

CS 455 Midterm 2 Spring 2018 [Bono] Apr. 3, 2018

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

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

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

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

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

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

CSE wi: Practice Midterm

Largest Online Community of VU Students

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

We've tried to include the common errors and grading standard for every question.

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

CS 112 Final May 8, 2008 (Lightly edited for 2011 Practice) Name: BU ID: Instructions GOOD LUCK!

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

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

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

COS 226 Algorithms and Data Structures Fall Midterm

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

Test 2: CPS 103 Owen Astrachan November 19, 1993 Name: Honor code acknowledgement (signature) Problem 1 value 9 pts. grade Problem 2 12 pts. Problem 3

Data Structure and Algorithm, Spring 2013 Midterm Examination 120 points Time: 2:20pm-5:20pm (180 minutes), Tuesday, April 16, 2013

Computer Science Foundation Exam

CS 315 Data Structures mid-term 2

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

Section 03: Asymptotic Analysis

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

CSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes

INSTITUTE OF AERONAUTICAL ENGINEERING

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Questions Total Points Score

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

ECE250: Algorithms and Data Structures Midterm Review

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

Computer Science Foundation Exam

CS 2150 Final Exam, Spring 2018 Page 1 of 10 UVa userid:

Prelim 2 Solution. CS 2110, April 26, 2016, 5:30 PM

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

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

Basic Data Structures (Version 7) Name:

1. AVL Trees (10 Points)

Suppose we want to create a data structure called DataStore that has the following operations:

Sorting Pearson Education, Inc. All rights reserved.

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

Final Examination CSE 100 UCSD (Practice)

Transcription:

Name: Email address: CSE 373 Spring 2010: 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: 78 points. Time: 50 minutes. Question Max Points 1 16 2 8 3 14 4 6 5 6 6 10 7 18 Total 78 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 ½ )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 12 )O(N N ), O(N 6 ), O(N 8 ), O(N 9 ) You do not need to explain your answer. a) f(n) = N (N 2 log N + N 2 ) b) f(n) = log 16 (2 N ) c) f(n) = (N/4) log (N/4) + N/4 d) f(n) = (2N + 2N) 3 e) f(n) = N ½ + log N f) f(n) = N log (100 3 ) g) f(n) = (N N N N) 3 h) f(n) = (N 3 + 2N) / N 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, int x, int y) { if (x < y) { for (int i = 0; i < n; ++i) for (int j = 0; j < n * i; ++j) System.out.println( y = + y); else { System.out.println( x = + x); Runtime: II. int silly(int n, int m) { if (n < 1) return n; else if (n < 100) return silly(n - m, m); else return silly(n - 1, m); III. void silly(int n) { j = 0; while (j < n) { for (int i = 0; i < n; ++i) { System.out.println( j = + j); j = j + 5; IV. void silly(int n) { for (int i = 0; i < n * n; ++i) { for (int j = 0; j < n; ++j) { for (int k = 0; k < i; ++k) System.out.println( k = + k); for (int m = 0; m < 100; ++m) System.out.println( m = + m); Page 3 of 10

3. (14 pts total) Trees. a) ( 3 pts) What is the minimum and maximum number of nodes at depth d in a full 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) (3 pts) Give traversals of the tree shown at the bottom of this page: Pre-Order: Post-Order: In-Order: c) (1 pt) What is the height of the tree shown below: d) (1 pt) Is it AVL balanced (ignore the values, only look at the shape): YES / NO A B C D E F G H I J K Page 4 of 10

3. (cont) (6 pts) Given the following six trees a through f: List the letters of all of the trees that have the following properties: (Note: It is possible that none of the trees above have the given property, it is also possible that some trees have more than one of the following properties.) Full: Complete: AVL balanced: Page 5 of 10

4. (6 pts total) Binary Search Trees & Binary Min Heaps a) (3 pts) Given the binary search tree shown below. Draw what the tree would look like after deleting the value 7. Use one of the methods for deleting described in class or in the book. Correction delete 9! 9 6 12 4 8 11 33 7 88 b) ( 3 pts) You are given a binary min heap of height 6. The minimum and maximum number of comparisons we might have to do when doing a deletemin is: Minimum = Maximum = Page 6 of 10

5. (6 pts) AVL Trees Draw the AVL tree that results from inserting the keys: 2, 8, 3, 9, 5, 4, 10 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 7 of 10

6. (10 pts total) Binary Min Heaps (a) [6 points] Draw the binary min heap that results from inserting 9, 3, 7, 4, 8, 2, 6, 5 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

6. (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

7. (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 ½ )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 12 )O(N N ), O(N 6 ), O(N 8 ), O(N 9 ) **For any credit, you must explain your answer. Assume that the most time-efficient implementation is used. Assume no duplicate values and that you can implement the operation as a member function of the class with access to the underlying data structure. a) Pop a value off a stack containing N elements implemented as an array. Explanation: a) b) Printing out all the odd values stored in a binary search tree containing N positive integers in ascending order. Explanation: b) c) Finding the minimum value in a binary search tree of size N. Explanation: c) d) Moving the values from a binary min heap, into an initially empty array of the same size. The final contents of the array should be sorted from low to high. Explanation: d) e) Finding the maximum value in a binary min heap of size N. Explanation: e) f) Printing out the values in an AVL tree in post-order. Explanation: f) Page 10 of 10