CSE 373 Autumn 2010: 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 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 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

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

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

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

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)

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

Practice Midterm Exam Solutions

CSE332 Summer 2010: Midterm Exam Sample Solutions

CS 216 Exam 1 Fall SOLUTION

CS171 Midterm Exam. October 29, Name:

Midterm solutions. n f 3 (n) = 3

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

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

COMP171 Data Structures and Algorithms Fall 2006 Midterm Examination

ECE242 Data Structures and Algorithms Fall 2008

CSE 373: Practice Final

INSTITUTE OF AERONAUTICAL ENGINEERING

UNIVERSITY REGULATIONS

CSE 373 APRIL 17 TH TREE BALANCE AND AVL

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

CS171 Final Practice Exam

Exam Data structures DAT036/DAT037/DIT960

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

CS171 Final Practice Exam

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

Computer Science E-22 Practice Final Exam

Section 05: Midterm Review

Basic Data Structures (Version 7) Name:

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

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

CSE 100 Practice Final Exam

CSE 373 Spring Midterm. Friday April 21st

Sample Exam 1 Questions

CSE wi: Practice Midterm

CSE 373 OCTOBER 11 TH TRAVERSALS AND AVL

Recitation 9. Prelim Review

Computer Science Foundation Exam

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

ECE250: Algorithms and Data Structures Midterm Review

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

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

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

COS 226 Algorithms and Data Structures Fall Midterm

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

Computer Science Foundation Exam

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

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

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

Course Review. Cpt S 223 Fall 2009

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

Major2 Examination Term: 162 Year: 2016/2017

Second Examination Solution

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

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

CS 315 Data Structures mid-term 2

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 Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Mid-Term Exam. CSE2100 DS & Algorithms 1

Course Review. Cpt S 223 Fall 2010

Largest Online Community of VU Students

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

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

COMP 250 Midterm #2 March 11 th 2013

Section 03: Asymptotic Analysis

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

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

ECE 250 Data Structures and Algorithms MID-TERM EXAMINATION /08:30-9:50 RCH 105, RCH 110

EECS 311 Data Structures Midterm Exam Don t Panic!

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

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

CMSC 341 Lecture 14: Priority Queues, Heaps

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

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

Computer Science Foundation Exam

Computer Science Spring 2005 Final Examination, May 12, 2005

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

Course Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU

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

Hierarchical data structures. Announcements. Motivation for trees. Tree overview

Midterm 2 Exam Principles of Imperative Computation. Tuesday 31 st March, This exam is closed-book with one sheet of notes permitted.

Course Review for Finals. Cpt S 223 Fall 2008

Data Structures Question Bank Multiple Choice

Final Examination CSE 100 UCSD (Practice)

UNIVERSITY REGULATIONS

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

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

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

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

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

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

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

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

MLR Institute of Technology

Analysis of Algorithms

Transcription:

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

3. (15 pts total) Trees. a) (4 pts) What is the minimum and maximum number of nodes in an AVL tree of height 6? (Hint: the height of a tree consisting of a single node is 0) Give an exact number for both of your answers not a formula. 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 depth of node F in 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 Page 4 of 10

3. (cont) e) (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. (4 pts total) Binary Search Trees & AVL Trees a) (2 pts) Given the binary search tree shown below. Draw what the tree would look like after deleting the value 11. Use one of the methods for deleting described in class or in the book do NOT use lazy deletion. 11 4 18 1 9 13 33 6 14 88 b) ( 2 pts) You are given an AVL tree of height 6. The minimum and maximum number of rotations we might have to do when doing an insert is: (Give an exact number, not a formula. A single rotation = 1 rotation, a double rotation = 1 rotation) Minimum = Maximum = Page 6 of 10

5. (6 pts) AVL Trees Draw the AVL tree that results from inserting the keys: 4, 8, 9, 3, 5, 6 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. (8 pts total) Binary Min Heaps (a) [6 points] Draw the binary min heap that results from inserting 8, 2, 7, 6, 9, 3, 1 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 drawn at the end of part (a). Page 9 of 10

7. (18 pts) Algorithms & Running Time Analysis: Describe the most time-efficient way to implement the operations listed below. 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. Then, give the tightest possible upper bound for the worst case running time for each operation in terms of N. **For any credit, you must explain why it gets this worst case running time. You must choose your answer from the following (not listed in any particular order), each of which could be re-used (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 ) a) Pushing a value onto a stack containing N values, implemented as a linked list. Explanation: a) b) Enqueue a value onto a queue containing N values implemented as a circular array (as described in class). (Assume the array is size N+5.) Explanation: b) c) Deleting the minimum value in a binary min heap of size N. Explanation: c) d) Given a binary search tree containing N integers, create an AVL tree containing the same values. You should not destroy the original BST in the process. Explanation: d) e) Printing out the values stored in all of the leaves of a perfect BST containing N values in ascending order. Explanation: e) f) Given an AVL tree containing N positive integers, print out all the even values contained in the tree in descending order (e.g. 12, 8, 6, 2). Be sure to explain how you will get f) descending order. Explanation: Page 10 of 10