OF VICTORIA EXAMINATIONS- DECEMBER 2010 CSC

Similar documents
OF VICTORIA EXAMINATIONS- DECEMBER 2011 CSC

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;

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

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

COS 226 Midterm Exam, Spring 2009

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

Prelim CS410, Summer July 1998 Please note: This exam is closed book, closed note. Sit every-other seat. Put your answers in this exam. The or

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

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

COMP 250 Midterm #2 March 11 th 2013

Technical University of Denmark

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

UNIVERSITY REGULATIONS

Module Contact: Dr Tony Bagnall, CMP Copyright of the University of East Anglia Version 1

Midterm solutions. n f 3 (n) = 3

CS2223: Algorithms Sorting Algorithms, Heap Sort, Linear-time sort, Median and Order Statistics

Exam Sample Questions CS3212: Algorithms and Data Structures

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

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

CS2 Algorithms and Data Structures Note 6

The University of British Columbia

University of Waterloo CS240, Winter 2010 Assignment 2

SUGGESTION : read all the questions and their values before you start.

Algorithms and Data Structures

CS171 Final Practice Exam

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

CSE 373: Practice Final

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

CS171 Midterm Exam. October 29, Name:

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

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

ECE368 Exam 2 Spring 2016

CS171 Final Practice Exam

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

Solutions to Exam Data structures (X and NV)

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

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

FINAL EXAMINATION. COMP-250: Introduction to Computer Science - Fall 2011

CISC 320 Midterm Exam

EXAM ELEMENTARY MATH FOR GMT: ALGORITHM ANALYSIS NOVEMBER 7, 2013, 13:15-16:15, RUPPERT D

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

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

CS 170, Spring 2000 Midterm #1 Professor M. Clancy

CS1800 Discrete Structures Fall 2016 Profs. Aslam, Gold, Ossowski, Pavlu, & Sprague December 16, CS1800 Discrete Structures Final

9. The expected time for insertion sort for n keys is in which set? (All n! input permutations are equally likely.)

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

CS2 Algorithms and Data Structures Note 6

End-Term Examination Second Semester [MCA] MAY-JUNE 2006

Computer Science 302 Spring 2007 Practice Final Examination: Part I

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

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

D. Θ nlogn ( ) D. Ο. ). Which of the following is not necessarily true? . Which of the following cannot be shown as an improvement? D.

CSCE 2014 Final Exam Spring Version A

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

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

CROWDMARK. Examination Midterm. Spring 2017 CS 350. Closed Book. Page 1 of 30. University of Waterloo CS350 Midterm Examination.

About this exam review

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

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

INDIAN STATISTICAL INSTITUTE

END-TERM EXAMINATION

Computer Science Spring 2005 Final Examination, May 12, 2005

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

Computer Science E-22 Practice Final Exam

Final Examination. Algorithms & Data Structures II ( )

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

CS/ENGRD2110: Final Exam

CSE 332, Spring 2010, Midterm Examination 30 April 2010

Faculty of Science FINAL EXAMINATION

CS 2604 Data Structures Midterm Summer 2000 U T. Do not start the test until instructed to do so!

Cornell University Computer Science 211 Second Preliminary Examination 18 April 2006

Sorting and Selection

CS 170 Algorithms Spring 2009 David Wagner MT2

Parallel Sorting Algorithms

CPSC 331 Term Test #2 March 26, 2007

Questions Total Points Score

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

) $ f ( n) " %( g( n)

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

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

Final. Please write (printing clearly) the infonnation requested in the boxes at the top of this page.

Final Examination CSE 100 UCSD (Practice)

CS 314 Final Fall 2012

Matriculation number:

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

CSE332 Summer 2010: Final Exam

Prelim 1. CS2110, October 2, 2014, 5:30 PM Extra Total Question TrueFalse Multiple Object Oriented

Priority queues. Priority queues. Priority queue operations

COS 226 Algorithms and Data Structures Spring Midterm

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

( ). Which of ( ) ( ) " #& ( ) " # g( n) ( ) " # f ( n) Test 1

CSE 247 Data Structures and Algorithms Fall Exam I

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

CS211 Spring 2005 Prelim 2 April 19, Instructions

Final Exam 1 /12 2 /12 3 /10 4 /7 5 /4 6 /10 7 /8 8 /9 9 /8 10 /11 11 /8 12 /10 13 /9 14 /13 15 /10 16 /10 17 /12. Faculty of Computer Science

York University AK/ITEC INTRODUCTION TO DATA STRUCTURES. Final Sample II. Examiner: S. Chen Duration: Three hours

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

( ) n 3. n 2 ( ) D. Ο

McGill University Faculty of Science School of Computer Science. MIDTERM EXAMINATION - Sample solutions. COMP-250: Introduction to Computer Science

Practice Midterm Exam Solutions

Transcription:

Name: ID Number: UNIVERSITY OF VICTORIA EXAMINATIONS- DECEMBER 2010 CSC 225 - Algorithms and Data Structures: I Section A01 (CRN 1089) Instructor: Wendy Myrvold Duration: 3 hours TO BE ANSWERED ON THE PAPER. Instructions: Students MUST count the number of pages in this examination paper before beginning to write, and report any discrepancy immediately to the invigilator. This exam has ten pages (the last page is blank in case you need extra space) plus the header page. Use only space provided on exam for answering questions. Closed book. No aids permitted. Question Value Mark 1 12 2 8 3 20 10 5 20 6 15 7 15 Total 100

CSC 225- Page 1 of 10 1. Circle true or false for each question and justify your answer. No marks will be given unless there isacorrect justification. (a) [3 marks] For a fixed integer k, the sum S(n) = Σ n i k is in O(n k ). True False i = 1 [3 marks] A search for a data item in a binary search tree can take Ω(n) time in the worst case. True False (c) [3 marks] It takes at least O(n log 2 n)time in the worst case to build a heap because both bubble up and bubble down take Ω(log 2 n)time in the worst case. True False (d) [3 marks] Suppose singly linked lists are used to implement a queue. Then, adding to the queue should be done at the front of the list, and deletions from the queue should be taken from the rear of the list. True False

2. [8 marks] Prove that if 2 k n <2 k+1, k 0, then (k + 1) 2 k+1 O(n log 2 n). CSC 225- Page 2 of 10

CS 225- Page 3 of 10 3. [20 marks, -2 marks for each incorrect answer] Your job is to analyse various data structures for implementing a set. The sets under consideration can contain up to n elements represented by the integers from zero up to n 1. Consider the following data structures for a set S: (a) (c) The elements of set S are stored in a sorted array. The elements of set S are stored in an unsorted linked list. Important: the linked list should not contain any duplicate values. The elements of S are indicated by a characteristic vector which is an array of size n which has position i set to 1 if element i is in the set and 0 if it is not in the set. Let S be a set which has size s and let T be a set of size t. Give the worst case time complexities of algorithms for the following set operations as functions of n, s, and t. If you want to use a sorting routine, use mergesort (and not Radix sort). Operation (a) Sorted array Unsorted list (c) Characteristic vector Is x in S? Add x to S (do not count time to check if x in S) Print elements in S in sorted order Create union of S and T

CS 225- Page of 10. Weighted UNION/Collapsing FIND 10 2 1 9 12 3 5 0 7 6 11 8 (a) [6 marks] Show the updated data structure after UNION(9, 6) assuming that weighted UNION and collapsing FIND are used. [2 marks] What does the parent array contain before the update? 0 1 2 3 5 6 7 8 9 10 11 12 [2 marks] What does the parent array contain after the update? 0 1 2 3 5 6 7 8 9 10 11 12

CSC 225- Page 5 of 10 5. Suppose amax-heap of size n is stored in an array A[0.. n 1]. (a) [6 marks] Give the formulas for determining the parent, left child and right child for the node in A[i]. parent left child right child [ marks] What should you use for f (n) inthis loop to get the linear time heapify routine? for (i= f(n); i >= 0; i--) bubbledown(n, A, i); (c) [10 marks] Give pseudocode for a recursive bubbledown routine that is very close to C or Java code (syntax does not matter, but do not refer to methods/functions unless you define them). bubbledown(n, A, pos) n- number of items in the heap A- array storing the heap pos- position in array of item to bubble down.

CS 225- Page 6 of 10 6. [15 marks] Show the values of the data structures tree, min_wt, and closest (as described in class) after each phase of the Dijkstra/Prim minimum spanning tree algorithm. The phase equals the number of vertices in the tree so far. The columns are numbered by the phase and the rows by the vertex numbers. Mark the edges in the MST. tree: 0 1 2 3 5 0 1 2 3 start here 0 6 8 7 2 1 2 3 1 3 5 min_wt: 0 1 2 3 5 0 1 2 3 closest: 0 1 2 3 5 0 1 2 3

CSC 225- Page 7 of 10 7. Consider this Java method: public void readrear(scanner in) { ListNode tmp, current; int data; int i; n= readinteger(in); start=null; rear=null; for (i=0; i < n; i++) { data= readinteger(in); tmp= new ListNode(data, null); if (i==0) { start=tmp; } else { current= start; while (current.next!= null) { current= current.next; // Statement to count. } current.next= tmp; } rear= tmp; } } (a) [3 marks] Set up a recurrence relation which counts the number of times that the statement with the comment // Statement to count. is executed for a given value of n and justify your formula.

CSC 225- Page 8 of 10 [Question 7 continued] [3 marks] Solve your recurrence from (a) to get a closed formula.

CSC 225- Page 9 of 10 [Question 7 continued] (c) [9 marks] Prove by induction that your closed formula from is the number of times that the given statement is executed for a problem of size n.

CSC 225- Page 10 of 10 Use this page if you need more space. Clearly indicate the question you are answering. The End.