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

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

York University AK/ITEC OBJECT-BASED PROGRAMMING. Midterm Test Sample. Examiner: S.Y. Chen Duration: One Hour and Fifteen Minutes

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

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

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

This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.

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

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

ECE242 Data Structures and Algorithms Fall 2008

University of California, Berkeley. CS 186 Introduction to Databases, Spring 2014, Prof. Dan Olteanu MIDTERM

ECE 2035 A Programming HW/SW Systems Spring problems, 5 pages Exam Three 13 April Your Name (please print clearly)

Midterm solutions. n f 3 (n) = 3

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

On my honor I affirm that I have neither given nor received inappropriate aid in the completion of this exercise.

CSE 131 Introduction to Computer Science Fall Exam II

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

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

CIS 110 Introduction to Computer Programming Summer 2018 Final. Recitation # (e.g., 201):

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

Computer Science Foundation Exam

Computer Science Foundation Exam

CS171 Midterm Exam. October 29, Name:

Midterm Practice Exam Sample Solutions

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

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

CS 315 Data Structures mid-term 2

ECE 2035 Programming HW/SW Systems Fall problems, 4 pages Exam Three 14 November Your Name (please PRINT clearly) Signed.

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

COS 226 Midterm Exam, Spring 2011

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

2016 Spring COP 3502 Final Exam. Date: 4/28/2016. Name:

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

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

CS 455 Midterm Exam 1 Fall 2016 [Bono] Thursday, Sept. 29, 2016

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

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

Largest Online Community of VU Students

Exam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE

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

CMPSCI 145 MIDTERM #2 Solution Key SPRING 2018 April 13, 2018 Professor William T. Verts

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.

Data Structures and Algorithms Winter term 2016

OF VICTORIA EXAMINATIONS- DECEMBER 2010 CSC

CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017

CSI 1100 / 1500 Fall 2004 Introduction to Computer Science I Final Examination

CIS 110 Introduction to Computer Programming Summer 2018 Final. Recitation # (e.g., 201):

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

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

CS 151 Midterm. Instructions: Student ID. (Last Name) (First Name) Signature

CIS 110 Introduction to Computer Programming. 12 February 2013 Midterm

CIS 110 Introduction to Computer Programming Fall 2017 Midterm. Recitation ROOM :

UNIVERSITY OF TORONTO Faculty of Arts and Science

Q1 Q2 Q3 Q4 Q5 Q6 Total

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

Math 52 - Fall Final Exam PART 1

UNIVERSITY REGULATIONS

CSE 351 Midterm - Winter 2015

Practice final for EECS 380, 2001: Prof Markov

COS 226 Algorithms and Data Structures Fall Midterm

Data Structures and Algorithms

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

Data Structures and Algorithms Winter Semester

SAMPLE EXAM Final Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 16 December 2010

C0MP1911 Final Exam 1337 Computing 1

#101 Page: 1 Name: CS32 Midterm Exam. E01, W15, Phill Conrad, UC Santa Barbara

CIS 110 Introduction to Computer Programming 8 October 2013 Midterm

ECE250: Algorithms and Data Structures Midterm Review

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Midterm 1 1 /8 2 /9 3 /9 4 /12 5 /10. Faculty of Computer Science. Term: Fall 2018 (Sep4-Dec4) Student ID Information. Grade Table Question Score

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

CIS 110 Introduction to Computer Programming. February 29, 2012 Midterm

CSE 2320 Section 002, Fall 2015 Exam 2 Time: 80 mins

CSE413 Midterm. Question Max Points Total 100

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

Sorting. Task Description. Selection Sort. Should we worry about speed?

CS 151 Final. Q1 Q2 Q3 Q4 Q5 Total Credit Score. Instructions: Student ID. (Last Name) (First Name) Signature

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

Exam Datastrukturer. DIT960 / DIT961, VT-18 Göteborgs Universitet, CSE

COS 226 Midterm Exam, Spring 2009

CSE332 Summer 2010: Midterm Exam Sample Solutions

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

Final Exam. COMP Summer I June 26, points

Second Examination Solution

Exam Principles of Imperative Computation, Summer 2011 William Lovas. June 24, 2011

CIS 110 Introduction to Computer Programming Summer 2017 Final. Recitation # (e.g., 201):

CS 113 MIDTERM EXAM 2 SPRING 2013

CSE 351 Midterm - Winter 2015 Solutions

MIDTERM EXAMINATION Douglas Wilhelm Harder EIT 4018 x T09:30:00P1H20M Rooms: RCH-103 and RCH-302

QUIZ: What value is stored in a after this

COS 226 Fall 2015 Midterm Exam pts.; 60 minutes; 8 Qs; 15 pgs :00 p.m. Name:

UNIVERSITY OF TORONTO Faculty of Arts and Science. Midterm Sample Solutions CSC324H1 Duration: 50 minutes Instructor(s): David Liu.

Programming II (CS300)

PRACTICE FINAL EXAM 3

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

School of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015

Student name: Student ID: MATH 61 (Butler) Midterm II, 12 November 2008

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

CIS 110 Introduction to Computer Programming Spring 2016 Midterm

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

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

Transcription:

York University AS/AK/ITEC 2620 3.0 INTRODUCTION TO DATA STRUCTURES Midterm Sample I Examiner: S. Chen Duration: One Hour and 30 Minutes This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g. for computing and/or communicating) is NOT permitted. Do not unstaple this test book any detached sheets will be discarded. Answer all questions in the space provided. No additional sheets are permitted a blank page is attached at the back for rough work. Work independently. The value of each part of each question is indicated. The total value of all questions is 60. However, the test is out of 50, so there are 10 extra marks available it is possible to score more than 100% on this test. Write your name and student number in the space below. Do the same on the top of each sheet of this exam where indicated. NOTE: YOU MAY USE PEN OR PENCIL, BUT ANSWERS IN PENCIL WILL NOT BE CONSIDERED FOR REGRADING. Surname: Given Names: Student Number: 1 2 Total 3 4 Page 1 of 8

Question 1 (15 marks) Short Answer (maximum 20 words): Answer all five parts below. Part A (3 marks): What is the time complexity of the best case to insert a new node into a minimum-level BST with n nodes? Explain. (Hint: You may draw a diagram as part of your solution.) Part B (3 marks): The best case to find the smallest value in an unsorted array is O(1) when there is only one element in the array. True or false? Explain. Part C (3 marks): If both have n nodes and are sorted smallest to largest, will it be faster to find the smallest value in a sorted linked list or a minimum-level BST? Explain. Part D (3 marks): Two O(n 2 ) algorithms will always take the same amount of time for a given value of n. True or false? Explain. Part E (3 marks): You have a (large) unsorted set of n records that you wish to store in a BST. The BST will be built by adding one record at a time. Will it be faster to build the BST if the records are first sorted so that they can be added to the BST in sorted order? Yes or no? Explain. Page 2 of 8

Question 2 (15 marks) Complexity Analysis/Estimation: Answer all three parts below. Part A (5 marks): Develop a recurrence relationship for the bizarre method that is called as follows: int result = bizarre(n, n); public static int bizarre (int first, int second) { if (second <= 1) { int temp = 0; for (int i = 0; i < first; i++) temp += i; return temp; } } return bizarre (first, second-1); Page 3 of 8

Part B (5 marks): What is the complexity of the following recurrence relation? Show the details of your analysis. T(1) = 1 T(n) = 2*T(n-1) + 1 Part C (5 marks): What is the complexity of the given code as a function of the problem size n? Show all details of your analysis. for (int i=0; i < n; i++) loops(i); public static void loops (int x) { if (x < 0) return; } for (int i=0; i < x; i++) for (int j=0; j < x; j++) print ( hi ); Page 4 of 8

Question 3 (15 marks) Linked Data Structures: Answer all seven parts below. Tree T shown below is a BST. 9 3 16 1 8 15 22 7 18 Part A (2 marks): Starting with the original tree T, insert 12. Draw the resulting tree below. Part B (2 marks): Starting with the tree developed in Part A, delete 22. Draw the resulting tree below. Page 5 of 8

Part C (2 marks): Starting with the tree developed in Part B, insert 22. Draw the resulting tree below. Part D (4 marks): Starting with the original tree T, delete 9. Use the deletion strategy presented in class. Draw the resulting tree below. Part E (5 marks): Draw the BST that is created by inserting the following nodes/values in the given order into a BST that is initially empty. 6 3 8 4 7 2 5 1 Page 6 of 8

Question 4 (15 marks) Recursion: The modulus operation returns the unit value of a number in a given base. For example: In base 10, the unit value of 237 is 7. (237%10 = 7) In base 2, the unit value of 1023 is 1. (1023%2 = 1) In base 8, the unit value of 6 is 6. (6%8 = 6) Write a recursive function in that will calculate the modulus of two positive inputs (the number and the base). Note: you may only use addition and subtraction you must not use multiplication, division, modulus, or any other methods in your solution, and you will not receive any credit for a non-recursive solution. Hint: use repeated subtraction. For example, the following statements would lead to the underlined output: Example 1: Example 2: Example 3: print ( modulus( 237, 10 )); 7 print ( modulus( 1023, 2 )); 1 print ( modulus( 6, 8 )); 6 Note: you may assume two positive inputs no error checking of inputs is required. Please write your method on the following page. You may use this page for rough work, but anything on this page will not be graded. Page 7 of 8

int modulus (number, base) { } Page 8 of 8