CSCA48H3 Midterm: CSCA48 Term Test 1 2013 Winter

303 views12 pages
16 Oct 2018
School
Course
Professor
CSC A48 Term Test # 1 11 February 2013
Duration: 45 minutes
Aids Allowed: None
Student Number:
Last (Family) Name(s):
First (Given) Name(s):
Do not turn this page until you have received the signal to start.
In the meantime, please read the instructions below carefully.
This term test consists of 3 questions on 12 pages (including this
one), printed on both sides of the paper. When you receive the signal
to start, please make sure that your copy of the test is complete, fill
in the identification section above, and write your name on the back
of the last page.
Answer each question directly on the test paper, in the space
provided, and use one of the “blank” pages for rough work. If you
need more space for one of your solutions, use a “blank” page and
indicate clearly the part of your work that should be marked.
Marking Guide
# 1: /10
# 2: /15
# 3: /25
TOTAL: /50
Good Luck!
Page 1 of 12
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 12 pages and 3 million more documents.

Already have an account? Log in
CSC A48 Term
Use the space on this “blank” page for scratch work, or for any solution that did not fit elsewhere.
Clearly label each such solution with the appropriate question and part number.
Page 2 of 12
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 12 pages and 3 million more documents.

Already have an account? Log in
Test # 1 11 February 2013
Question 1. [10 marks]
Write the body of the function below so that it satisfies its docstring. Assume that module stack.py
defines a class Stack that provides the usual methods: is_empty(),push(item),pop().
For full marks, your code must not depend on any details of the implementation of class Stack. In
other words, the only thing you can do with a Stack object is to call some of its methods.
from stack import Stack
def size(stk):
"""(Stack) -> int
Return the number of items on Stack stk, *without* modifying stk.
(It’s OK if the contents of stk are modified during the execution of this
function, as long as everything is restored before the function returns.)
"""
# Hint: You can use more than one stack.
Page 3 of 12
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 12 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Do not turn this page until you have received the signal to start. In the meantime, please read the instructions below carefully. This term test consists of 3 questions on 12 pages (including this one), printed on both sides of the paper. When you receive the signal to start, please make sure that your copy of the test is complete, ll in the identi cation section above, and write your name on the back of the last page. Answer each question directly on the test paper, in the space provided, and use one of the blank pages for rough work. If you need more space for one of your solutions, use a blank page and indicate clearly the part of your work that should be marked. Write the body of the function below so that it satis es its docstring. Assume that module stack. py de nes a class stack that provides the usual methods: is_empty(), push(item), pop().

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents