Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Cmpt225_MidTerm_2_Fall_2019_SOLUTION Simon Fraser University CMPT 225

Rating
-
Sold
-
Pages
7
Grade
A+
Uploaded on
09-04-2023
Written in
2022/2023

Simon Fraser University Computing Science 225 Fall 2019 Midterm Examination 2 Time: 50 minutes Circle the campus you attend most often: Burnaby Surrey Vancouver Last/Family Name (please, print): First Name (please, print): Student Number: Signature: Instructor: Anne Lavergne This examination has 7 pages.  No books, cheat sheets, calculators, computers, cell phones, or other materials may be used.  Read each question carefully before answering it.  List any assumptions you make when answering a question.  ADT means Abstract Data Type.  BST means Binary Search Tree.  Always comment your code.  The marks for each question are given in [ ]. Use this to manage your time:  1 mark corresponds to 1 minute of work.  Do not spend more time on a question than the number of marks assigned to it Part 1 – [2 marks each – No part marks!] Answer each question in its box. 1. In our Assignment 3, we were introduced to the exception throwing mechanism of C++. List all the files used in this assignment in which we would be expecting to find try/catch block statements? BankSimA PriorityQueue.h (Queue/BinaryHeap/PriorityQueue Test Drivers – but these files are not officially part of Assignment 3 – Bank Simulation as they as testing tools) 2. Imagine a List ADT class implemented as follows: class List { private: unsigned int arraySize; Patient * elements; public: /* Public method declarations here. */ /* There are no public attributes. */ } Using the Big O notation, express the time efficiency of determining the number of elements stored into an object of this List ADT class. O(n) Since there is no “elementCount” data member, in order to determining the number of elements stored into an object of this List ADT class, one would have to traverse the List object, counting each element. 3. Consider a Binary Search Tree ADT class. Using the Big O notation, express the space efficiency of the worst case scenario of its insertion if this operation is implemented recursively. O(n) The worst case scenario of a BST is a degenerate BST (long linked list). Therefore, the worst case scenario of its insertion operation is O(n) in which one would have to go all the way down to the leaf level in order to insert an element. If this insertion is recursively implemented (called at each level of the BST), there will be a stack frame (stack memory) associated with each call made to this recursive insertion method (given to each exec

Show more Read less
Institution
Course

Content preview

Simon Fraser University
Computing Science 225
Fall 2019
Midterm Examination 2

Time: 50 minutes


Circle the campus you attend most often: Burnaby Surrey Vancouver

Last/Family Name (please, print):

First Name (please, print):

Student Number:

Signature:


Instructor: Anne Lavergne
# Marks
This examination has 7 pages.


 No books, cheat sheets, calculators, computers, Part 1
cell phones, or other materials may be used.
/ 24
Q. 1 to 12
 Read each question carefully before answering it.
Part 2
/ 4
 List any assumptions you make when answering a Q. 1
question.
Part 2
 ADT means Abstract Data Type. / 8
Q. 2
 BST means Binary Search Tree.
Part 2
 Always comment your code. / 8
Q. 3
 The marks for each question are given in [ ].
Use this to manage your time: Part 2
 1 mark corresponds to 1 minute of work. / 6
Q. 4
 Do not spend more time on a question
than the number of marks assigned to it.
Total / 50



Good luck!
This study source was downloaded by 100000850872992 from CourseHero.com on 04-09-2023 03:12:35 GMT -05:00


https://www.coursehero.com/file/58846898/Cmpt225-MidTerm-2-Fall-2019-SOLUTIONpdf/

, Name Student Number


Part 1 – [2 marks each – No part marks!] Answer each question in its box.


1. In our Assignment 3, we were introduced to the exception throwing mechanism of C++.
List all the files used in this assignment in which we would be expecting to find
try/catch block statements?

BankSimApp.cpp
PriorityQueue.h
(Queue/BinaryHeap/PriorityQueue Test Drivers – but these files are not officially part of
Assignment 3 – Bank Simulation as they as testing tools)


2. Imagine a List ADT class implemented as follows:
class List {

private:
unsigned int arraySize;
Patient * elements;
public:
/* Public method declarations here. */
/* There are no public attributes. */
}
Using the Big O notation, express the time efficiency of determining the number of
elements stored into an object of this List ADT class.

O(n)
Since there is no “elementCount” data member, in order to determining the number of
elements stored into an object of this List ADT class, one would have to traverse the List
object, counting each element.

3. Consider a Binary Search Tree ADT class. Using the Big O notation, express the space
efficiency of the worst case scenario of its insertion if this operation is implemented
recursively.

O(n)
The worst case scenario of a BST is a degenerate BST (long linked list).
Therefore, the worst case scenario of its insertion operation is O(n) in which one would have
to go all the way down to the leaf level in order to insert an element.
If this insertion is recursively implemented (called at each level of the BST), there will be a
stack frame (stack memory) associated with each call made to this recursive insertion
method (given to each execution of this method) -> O(n) stack frames.

This study source was downloaded by 100000850872992 from CourseHero.com on 04-09-2023 03:12:35 GMT -05:00 Page 2 of 7


https://www.coursehero.com/file/58846898/Cmpt225-MidTerm-2-Fall-2019-SOLUTIONpdf/

Written for

Course

Document information

Uploaded on
April 9, 2023
Number of pages
7
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$9.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
beckyfawcet Rasmussen College
Follow You need to be logged in order to follow users or courses
Sold
112
Member since
4 year
Number of followers
19
Documents
599
Last sold
2 days ago
GradesBooster

Verified eBooks available for a Quick and Easy Download at Affordable rates I OFFER: -Study Guides -eBooks -ATI Test Prep, Assignments -WGU Papers, \"Task\" Assignments (Complete RN BSN Curriculum), Rubric & Task Info for Each Course -HCI College Nursing Associates Program -NCLEX Prep *ALL WORK HAS PASSED WITHOUT NEEDING REVISIONS AND BY THE RUBRIC.

4.2

26 reviews

5
18
4
2
3
2
2
1
1
3

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions