BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE. Sample Final Exam

Similar documents
Computer Science 302 Fall 2009 (Practice) Second Examination, October 15, 2009

Data Structures Question Bank Multiple Choice

ASSIGNMENTS. Progra m Outcom e. Chapter Q. No. Outcom e (CO) I 1 If f(n) = Θ(g(n)) and g(n)= Θ(h(n)), then proof that h(n) = Θ(f(n))

Table of Contents. Chapter 1: Introduction to Data Structures... 1

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE

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

Name CPTR246 Spring '17 (100 total points) Exam 3

1) What is the primary purpose of template functions? 2) Suppose bag is a template class, what is the syntax for declaring a bag b of integers?

MULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR

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

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

PROGRAMMING IN C++ (Regulation 2008) Answer ALL questions PART A (10 2 = 20 Marks) PART B (5 16 = 80 Marks) function? (8)

A6-R3: DATA STRUCTURE THROUGH C LANGUAGE

Course goals. exposure to another language. knowledge of specific data structures. impact of DS design & implementation on program performance

Course Review for Finals. Cpt S 223 Fall 2008

CSL 201 Data Structures Mid-Semester Exam minutes

DYNAMIC MEMORY ALLOCATION AND DEALLOCATION

Course Review. Cpt S 223 Fall 2009

CPSC 331 Term Test #2 March 26, 2007

CSI33 Data Structures

Chapter 20: Binary Trees

ECE250: Algorithms and Data Structures Midterm Review

First Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

( ) D. Θ ( ) ( ) Ο f ( n) ( ) Ω. C. T n C. Θ. B. n logn Ο

Computer Science 302 Spring 2007 Practice Final Examination: Part I

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

logn D. Θ C. Θ n 2 ( ) ( ) f n B. nlogn Ο n2 n 2 D. Ο & % ( C. Θ # ( D. Θ n ( ) Ω f ( n)

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

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

Computer Science 302 Spring 2017 (Practice for) Final Examination, May 10, 2017

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

INSTITUTE OF AERONAUTICAL ENGINEERING

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

n 2 C. Θ n ( ) Ο f ( n) B. n 2 Ω( n logn)

Prepared By: Ms. Nidhi Solanki (Assist. Prof.) Page 1

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

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

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

Student number: Datenstrukturen & Algorithmen page 1

CS301 - Data Structures Glossary By

1 P a g e A r y a n C o l l e g e \ B S c _ I T \ C \

1. Attempt any three of the following: 15

Computer Science 302 Fall 2018 (Practice for) Third Examination, November 14, 2018

CS171 Final Practice Exam

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

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

CS 251, LE 2 Fall MIDTERM 2 Tuesday, November 1, 2016 Version 00 - KEY

Total No. of Questions :09] [Total No. of Pages : 02. II/IV B.Tech. DEGREE EXAMINATIONS, NOV/DEC First Semester CSE/IT DATA STRUCTURES USING C

CSI33 Data Structures

DATA STRUCTURES AND ALGORITHMS

INF2220: algorithms and data structures Series 1

n 2 ( ) ( ) Ο f ( n) ( ) Ω B. n logn Ο

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

Your data structure should implement all operations in logarithmic time (or better) as a function of the size of the queue.

Course Name: B.Tech. 3 th Sem. No of hours allotted to complete the syllabi: 44 Hours No of hours allotted per week: 3 Hours. Planned.

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap

Course Review. Cpt S 223 Fall 2010

Midterm solutions. n f 3 (n) = 3

Analysis of Algorithms

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

E.G.S. PILLAY ENGINEERING COLLEGE (An Autonomous Institution, Affiliated to Anna University, Chennai) Nagore Post, Nagapattinam , Tamilnadu.

DATA STRUCTURE : A MCQ QUESTION SET Code : RBMCQ0305

CLASSIC DATA STRUCTURES IN JAVA

Section 05: Midterm Review

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

CSI33 Data Structures

Test 1 Last 4 Digits of Mav ID # Multiple Choice. Write your answer to the LEFT of each problem. 2 points each t 1

Cpt S 122 Data Structures. Data Structures Trees

! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge

Question Bank Subject: Advanced Data Structures Class: SE Computer

M.C.A. DEGREE EXAMINATION, MAY First Year. Paper I INFORMATION TECHNOLOGY. SECTION A (3 15 = 45 marks) Answer any THREE of the following.

CSE 143 Final Part 1, August 18, 2011 Sample Solution

Binary Search Trees Treesort

MLR Institute of Technology

Final Examination CSE 100 UCSD (Practice)

Second Semester - Question Bank Department of Computer Science Advanced Data Structures and Algorithms...

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

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

Name: 1 stack<int> s; 2 s.push(9) 3 s.push(5) 4 s.push(10) 5 s.push(1) 6 s.pop() 7 s.pop() 8 s.push(0) 9 s.pop() 10 s.pop() 11 s.

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

Code No: R Set No. 1

Computing Science 115 Final Examination April 23, 2002 Section: B2 BASU. Please put student id on last page. Instructions:

DATA STRUCTURES THROUGH C++

1. Stack overflow & underflow 2. Implementation: partially filled array & linked list 3. Applications: reverse string, backtracking

DIT960 Datastrukturer

CSE 373 Spring Midterm. Friday April 21st

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

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

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

Unit 8: Analysis of Algorithms 1: Searching

Quiz 1 Solutions. Asymptotic growth [10 points] For each pair of functions f(n) and g(n) given below:

COMP : Trees. COMP20012 Trees 219

Trees. Eric McCreath

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

Abstract Data Structures IB Computer Science. Content developed by Dartford Grammar School Computer Science Department

CSI33 Data Structures

CS171 Final Practice Exam

Binary Trees

Data Structures Brett Bernstein

Transcription:

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE CSI33 Sample Final Exam NAME Directions: Solve problems 1 through 5 of Part I and choose 5 of the 6 problems in Part II. Use the separate answer booklet to write your answers. You may refer to the textbook, handouts, or notes taken in class, but no calculators, computers or conversation will be permitted. Part I: Solve problems 1 through 5. 1. (10) Indicate whether the following statements are TRUE or FALSE: i. Binary search is never as slow as linear search. ii. A heap structure is not a natural choice to implement a priority queue. iii. Linked lists are useful because insertion and deletion time is faster than it is for an array. iv. An item in a binary search tree can always be found in Θ(log(n)) time. v. A recursive function does not always need a base case. vi. A Python list is a homogeneous container. vii. In languages like Python, the call stack is used to keep track of nested function calls. viii. In a C++ implementation of an Abstract Data Type, a method can be private. ix. The stage of the C++ build process in which #include directives are performed is called the preprocessor stage. x. For a binary search tree to satisfy the AVL property, both subtrees of any given node must have exactly the same height. 1

2. A heap initially has the following binary tree structure: 14 10 7 9 8 5 6 3 0 1 A. (5) Draw the array-based representation of this binary tree. B. (5) Show each change made to this tree in the process of adding the value 12, by drawing the tree as it appears after each stage of the insertion. 3. (10) Represent this directed, unweighted graph as a Python List two ways: as an adjacency matrix and as an adjacency list. Which representation is most efficient for a graph which has very few edges between nodes? A B C D E 4. (10) The integers 11,2,7,4,5,3 and 8 are inserted in that order into a container object. Give the order in which these values are retrieved, if the container is A. a stack, B. a queue, C. a priority queue. 5. a. (5) State the AVL property for binary search trees. b. (5) The sequence of values from the previous problem, in that order, is inserted into an empty AVL tree. (After any insertion, rebalance the tree by performing the appropriate rotation if the tree is unbalanced according to the AVL property.) Draw the tree as it appears after every insertion. 2

Part II: Solve 5 of the 6 problems (6 through 11) in this part. 6. (10) Below is an array with 10 positions which is being used as a hash table to keep customer information. The key to each record is the last 3 digits of the customer s id number. The hash function f is given by f(k) = k%10, that is, the index slot in the array for key k is the remainder of dividing k by 10. The method of collision resolution will be separate chaining. Draw boxes and arrows in the following diagram to give the state of the hash table after the following keys are inserted in this order: (The first three insertions have already been illustrated as a hint.) 716, 623, 046, 770, 879, 862, 764, 445, 787, 357, 154, 944, 843, 261, 238. 0 1 2 3 623 4 5 6 716 046 7 8 9 3

7. (10) Give box-and-arrow diagrams that illustrate the state of the C++ memory model immediately after each of these statements, including the last. What problem will occur if the statement with the delete operation is removed from the program? { } int *a, *b, c; a = &c; b = new int; c = 17; *b = *a + 5; delete b; 8. (10) The following C++ function finds the sum of squares of integers in an array: int sum of squares(int a[], int size) { int i; int sum = 0; for (i = 0; i<size: i++) sum += a[i]*a[i]; return sum; } Rewrite this function as a template function which could be called as sum of squares<int>, sum of squares<double>, or as an instance for any other class which overloads the + and * operators. 4

9. (10) Write the output of preorder, inorder, and postorder traversal when each of them is performed using the following binary tree: I G H E D C F A B 10. (10) Name three methods (member functions) which must be specially coded for any C++ class which allocates and manages dynamic memory. Explain in detail what each method does in terms of allocating and deallocating memory, as well as copying data in existing memory. What memory problems can occur if the default versions of these C++ methods are used instead? 5

11. Sorting a. (5) Perform the Selection Sort algorithm to sort the following list of integers, explaining how each value reaches its final position: [3,7,2,5,1,6,4,8] b. (5) Give the Θ-running time of Selection Sort using n, the number of items being sorted. Then give a clear explanation of why it takes that long to sort n items. 6