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

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

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

Midterm solutions. n f 3 (n) = 3

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

CPSC 331 Term Test #2 March 26, 2007

Introduction to Algorithms May 14, 2003 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser.

CSL 201 Data Structures Mid-Semester Exam minutes

CSE 143 Final Exam Part 1 - August 18, 2011, 9:40 am

CSE 373 Spring Midterm. Friday April 21st

Final Exam. Problem Parts Points Grade Grader Problem Parts Points Grade Grader Total 180. Name: Athena username: Joe WF3a. Joe WF2.

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

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

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

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

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

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

Data Structures Lecture 8

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

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

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

CSE 332, Spring 2010, Midterm Examination 30 April 2010

Sample Exam 1 Questions

York University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes

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

University of New Mexico Department of Computer Science. Midterm Examination. CS 561 Data Structures and Algorithms Fall, 2013

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

Quiz 1 Practice Problems

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

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

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Summer I Instructions:

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2006

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring Instructions:

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

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

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

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

University of Illinois at Chicago Department of Computer Science. Final Examination. CS 151 Mathematical Foundations of Computer Science Fall 2012

CS583 Lecture 01. Jana Kosecka. some materials here are based on Profs. E. Demaine, D. Luebke A.Shehu, J-M. Lien and Prof. Wang s past lecture notes

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;

ECE250: Algorithms and Data Structures Midterm Review

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

Divide-and-Conquer. Dr. Yingwu Zhu

ECE242 Data Structures and Algorithms Fall 2008

CSE wi: Practice Midterm

Prelim One Solution. CS211 Fall Name. NetID

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

York University. AP/ITEC Section M INTRODUCTION TO DATA STRUCTURES Winter Midterm Test

CSE373 Fall 2013, Midterm Examination October 18, 2013

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

Solutions. (a) Claim: A d-ary tree of height h has at most 1 + d +...

Practice Midterm Exam Solutions

Computer Science E-22 Practice Final Exam

Midterm I Exam Principles of Imperative Computation André Platzer Ananda Gunawardena. February 23, Name: Andrew ID: Section:

CPSC 320 Midterm #1. February 4, 2015

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

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

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

COT 5407: Introduction to Algorithms. Giri Narasimhan. ECS 254A; Phone: x3748

Second Examination Solution

Lecture 2: Algorithm Analysis

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

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

Choice of C++ as Language

UNIVERSITY REGULATIONS

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

Chapter 4. Divide-and-Conquer. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

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

CMSC351 - Fall 2014, Homework #2

Prelim 2, CS2110. SOLUTION

Spring 2002: Fundamental Structures of Computer Science

EECS Sample Midterm Exam

Final Examination CSE 100 UCSD (Practice)

Here is a recursive algorithm that solves this problem, given a pointer to the root of T : MaxWtSubtree [r]

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

Divide-and-Conquer. The most-well known algorithm design strategy: smaller instances. combining these solutions

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

: Fundamental Data Structures and Algorithms. June 06, 2011 SOLUTIONS

CSE 331 Introduction to Algorithm Analysis and Design. Sample Mid-term Exam-I: Fall 2018

EE 368. Week 6 (Notes)

CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014

Binary search trees. Binary search trees are data structures based on binary trees that support operations on dynamic sets.

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

UNIVERSITY OF MANITOBA. SIGNATURE: (in ink) (I understand that cheating is a serious offense)

Midterm I Exam Principles of Imperative Computation André Platzer Ananda Gunawardena. February 23, 2012

COMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018

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

Plotting run-time graphically. Plotting run-time graphically. CS241 Algorithmics - week 1 review. Prefix Averages - Algorithm #1

The divide and conquer strategy has three basic parts. For a given problem of size n,

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

CSE Winter 2015 Quiz 1 Solutions

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

Quiz 1 Practice Problems

Questions Total Points Score

PROGRAM EFFICIENCY & COMPLEXITY ANALYSIS

Binary Search Trees Treesort

CS161 - Final Exam Computer Science Department, Stanford University August 16, 2008

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

Assignment 1 (concept): Solutions

OF VICTORIA EXAMINATIONS- DECEMBER 2010 CSC

Midterm 1 Exam Principles of Imperative Computation. Thursday 6 th October, This exam is closed-book with one sheet of notes permitted.

Transcription:

University of Toronto Department of Electrical and Computer Engineering Midterm Examination ECE 345 Algorithms and Data Structures Fall 2010 Print your name and ID number neatly in the space provided below; print your name at the upper right corner of every page. The exam is eight (8) pages including the cover page; if not, report it to the instructor or TA. Name: ID Number: This is an open book exam. You are permitted to use the textbook for the course but nothing else is permissible. You may reference/use textbook page/section/algorithms if you wish so. Non-native English speakers may use a dictionary. Do all three problems in this booklet. Try not to spend too much time on one problem. Use terminology from the textbook. You must define any different terms before you use them. Write clearly and only in the space provided. Ask the proctor if you need more paper. Nothing on the back of the sheets will be graded. You have 110 minutes for this exam. Raise your hand if you have a question. Turn off your mobile phone. Do not give C code! Write pseudocode and analyze time/memory requirements of your algorithms when asked to receive full credit. All logarithms are base 2 unless otherwise noted. Question Points Score Grader 1 50 2 25 3 25 Total 100

ECE 345 Midterm Fall 2010 1 Name: 1. [Asymptotics, Induction, Sorting, RBTs, Recurrences, BSTs, Heaps] Short Answers, 8+8+8+8+9+9 points. Answer only in the space provided. (a) Does there exist (positive) functions f(n) and g(n) satisfying both f(n) O(g(n)) and g(n) O(f(n))? If yes, give an example of such functions. If no, briefly explain why not. yes no (b) Give the best asymptotic (i.e., in Big-Oh) characterization of the worst case and the best case time complexities of the following algorithm. This algorithm takes as input arrays of integers A and B each of size n. You must explain your reasoning. Algorithm i = 0 sum = 0 while i < n if A[i] < 0 i = n else if A[i] < n for j = 0 to A[i] sum = sum + B[j] endif i = i + 1 Best case: Worst case:

ECE 345 Midterm Fall 2010 2 Name: (c) Use induction to prove that: 1 2 + 2 3 +... + n(n + 1) = n(n + 1)(n + 2)/3 whenever n is a positive integer. Clearly show the induction base/hypothesis/step. (d) Use the Master Theorem to solve the following recurrence. Show your work. T (n) = 2T ( n 2 ) + n lg lg (5) n

ECE 345 Midterm Fall 2010 3 Name: (e) Let T be a binary search tree storing 512 entries. What is the smallest and largest possible heights for T? Assume that the leaves do not store any entries. Explain your reasoning for each case. (f) Let H be a minheap storing more than 3 entries. Assume it stores unique keys, i.e. no repeated keys allowed. Mark the following statements as true or false. You do not need to explain your reasoning for this question. Preorder traversal always lists keys in non-decreasing order Preorder traversal never lists keys in non-decreasing order Inorder traversal sometimes lists keys in non-decreasing order Postorder traversal sometimes lists keys in non-decreasing order

ECE 345 Midterm Fall 2010 4 Name: 2. Search, 25 points. You are given an array A of n integers in the range 0 to k. Describe an algorithm that answers any query about how many of the n integers fall into a range [a..b]. This algorithm should process the information in A into a new array C within Θ(n + k) time. Then it should be able to answer each query in O(1) time. Hint: During preprocessing, remember how many elements are i.

ECE 345 Midterm Fall 2010 5 Name: 3. Greedy Algorithms, 13+12 points. Let us consider a long, quiet country road with houses scattered very sparsely along it. Picture the road as a long line segment, with an eastern endpoint and a western endpoint. Further, let s suppose that the residents of all these houses are avid cell phone users. You want to place cell phone base stations at certain points along the road, so that every house is within four miles of one of the base stations. (a) Give a greedy algorithm that achieves this goal, using the minimum number of base stations. Hint: Start moving from west to east, appropriately placing stations along the way. (b) Prove the optimality of your algorithm.