Midterm Examination 2
CPSC 101: Connecting with Computer Science
The University of British Columbia
2013 Winter Term 1
Hassan Khosravi
Sample Solution
You have 45 minutes to solve the problems on this exam.
1. Each candidate must be prepared to produce, u
Types of analysis of algorithms,
Asymptotic notations
JamesHiller
CPSC101Notes
1
Week 2: Insertion Sort
Insertion sort pseudocode (recall)
InsertionSort(A) *sort A[1.n] in place
for j 2 to n do
key A[j] *insert A[j] into sorted sublist A[1.j 1]
while (i >
Applications to Cryptograph and Proofsby
Induction
JamesHillier
CPSC101Notes
1
Theorem: 2 is irrational.
Proof:
By way of contradiction, assume that 2 is rational, i.e.
Without loss of genrality, we assume that a and b do not have any
commont factors othe
Heapsort, Quicksort Notes
JamesHiller
CPSC101Notes
1
Week 4: Heaps
Heaps data structure (recall):
An array A[1.n] of n comparable keys
either or
An implicit binary tree, where
A[2j] is the left child of A[j]
A[2j + 1] is the right child of A[j]
A[
j2
Solving recurrences, Heaps
JamesHiller
CPSC101Notes
1
Divide and Conquer and recursive programs
A useful design technique for algorithms is divide-and-conquer
These algorithms are often recursive and consist of the following three steps:
Divide: If the i
CPSC 101: Connecting with Computer Science
Midterm Exam, 2012 February 7
SAMPLE SOLUTION
1
Cooking Up a Computer Question [5 marks]
Which part of our course denition of a computer makes clear that a human chef cooking a dish from a typical
recipe is not a
CPSC 101/WMST 201 Midterm
Friday October 19th, 2012
[9] 1. Each of the following screenshots violates one of the four interface design principles discussed in class. In each case, specify the principle that is most obviously violated (aim for
familiarity
CPSC 101: Midterm
- 80 minutes -
6 Feb 2014
Problem 0: Student Information [1 mark]
a.
Name:
b. Student #:
ANSWER KEY
c.
Lab section (circle one):
A (W15-18)
B (Tu11-14) C (Tu14-17) D (W9-12)
E (Tu17-20)
F (W12-15)
d. Signature:
(Your signature indicates
Midterm Examination
CPSC 101: Connecting with Computer Science
The University of British Columbia
2013 Winter Term 1
Hassan Khosravi
Sample Solution
You have 45 minutes to solve the problems on this exam.
1. Each candidate must be prepared to produce, upo