Using our Stack class
We dont care how the information is stored as long as this code
The call stack stores information about the active functions or
subroutines in a program.
stk = Stack()
Midterm 2 Solutions
Part (a) [2 marks]
This subquestion is about binary search trees. Draw the tree that results after inserting the following
items in the given order into an empty binary search tree.
5, 9, 6, 8
ADTs in Python
Object-oriented analysis (OOA)
Python: you can define a new type by writing a class
Sometimes, using the built-in ones like str would be too inconvenient
Classes encapsulate data and provide methods to operate on that
Midterm Test 1 Solutions
Remeber that type(v) returns vs type, and you can compare that result to int, str, or any other type
using =. For example, type(3) = int evaluates to True.
Part (a) [6 marks]
A survey: who are you?
Transfer credit for CSCA08?
Want to do a CSC minor?
Want to do a CSC major?
Want to do a CSC specialist?
Dont want to do a CSC program?
Small and relatively uncomplicated
Well mark your exercise submissions lots of times
We hope you all get full marks on all the exercises
Marking is automatic
Again: the biggest problem is not reading (and re-re
What's a heap?
a complete binary tree
It has no holes; it is
filled row by row,
from left to right.
satisfies the heap property
The value at each node is smaller than that of both
(This is a min heap. In a max heap each n
Announcements: on Piazza
We post course announcements on Piazza
First exercise will be posted at the end of the week.
marked with tag #utsc_announcement
Due a week from Friday (at noon).
These are required reading
Reminders: must w
Exam period office hours: will be posted
Check your marks!
A1, E1, E2, E3, labs, midterms all posted
Will post to Piazza when E4 and A2 marks available
Report errors before the final exam
Fill out course
Objects are modular entities that have both state (data) and
behaviour (methods) bundled together, much like verbs and
nouns work together.
Objects and classes
Object-oriented programming uses objects and their interactions as
Abstract Data Types (ADTs)
Abstract Data Types:
Discovery and Design
Existing in thought or as an idea but not having a physical or concrete
the quantities, characters, or symbols on which operations are performed by
-Exercise 0 is out
-Logging into MarkUs
Wing vs Python
-Python is both a programming language, and the program that interprets/run your code
-python is the program if you