• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 64 pages
Other

Reference for Introduction to the Theory of Computation CSC236 — 2026 Fall - Complete A+ Guide.

Document preview thumbnail
Preview 4 out of 64 pages

Reference for Introduction to the Theory of Computation CSC236 — 2026 Fall - Complete A+ Guide - Gary Baumgartner.

Content preview

Reference
for
Introduction to the Theory of Computation
CSC236 — 2026 Fall



Gary Baumgartner

,
, Contents

Chapter 1. Tracing Recursion — Review 4
1.1. More Exercises 9
1.2. Solutions 15

Chapter 2. Correctness of Recursions 25
2.1. Review: Designing a Recursive Algorithm 25
2.2. Review: Correctness of Algorithms 26
2.3. Review: Correctness of Recursive Algorithms 26
2.4. Component: Valid Recursive Structure 27
2.5. Template: Valid Recursive Structure 30
2.6. Algorithm: Greatest Common Divisor 30
2.7. Component: Correct Return Value 31
2.8. Template: Correct Return Value 33
2.9. Component: Valid Non-Recursive Calls 33
2.10. Algorithm: Prime-Factorization 34
Exercises 36
Solutions 38

Chapter 3. Complete Induction 42
3.1. Change-Making Revisited 42
3.2. Prime Factorization Revisited 44
3.3. Induction on a Measure 44
3.4. The Principle of Complete Induction (Optional) 48
Exercises 49
Solutions 51

Chapter 4. Recursive Data 54
4.1. Structural Set Definition 54
4.2. Structural Inductions 55
4.3. Derivational Ambiguity 57
4.4. Binary Trees, Structurally 58
Exercises 60
Solutions 62




3

, CHAPTER 1



Tracing Recursion — Review

In this course we will prove the correctness of recursive algorithms, apply recursive proof techniques, prove properties of
recursively defined data, and determine the running times of recursive algorithms.
The recursive algorithms we will consider will typically be designed to return a value, and not modify objects nor perform I/O.
We assume that in a prerequisite course you learned to trace the execution of (i.e., manually execute) any call of any algorithm,
line by line, step by step. So, in particular, for a call of a recursive algorithm you can list:
All the recursive calls that occur during execution:
· in order
· with their arguments
· and their returned values
And the returned value of the entire call itself.
In a previous course1 you traced the following algorithm:
# Precondition: L is a non-empty sequence of comparable elements.
def S (L):
if len(L) == 1: return (L[0],)
else: return M ( S (L[0 : len(L)//2]) , S (L[len(L)//2 : len(L)]) )

# Return a tuple containing the elements of LL and LR, sorted together.
def M (LL, LR): # implementation omitted

Regardless of whether you recognize it or saw it in this form, make sure you can reliably trace such a small algorithm, and
practice (1.1) enough tracing to do it quickly:

Exercise 1. List all the recursive calls that occur during execution of call S ((8, 0, 1, 4)), in the order they occur, with their
arguments and returned values, and the final returned value.




When we ask for the trace of a call of a recursive function this is the information from your manual execution that we are
asking for, organized as shown in our solution to this Exercise (see section §1.2). This includes indentation showing which calls
are children of which parent. (We will remind you of this form and the other tracing forms on tests)
With the indentation, if you look at the trace sideways it looks much like the call tree of a call of a recursive function (you drew
this kind of tree in a previous course2, in particular to understand the execution and running time of the previous algorithm):

S((8, 0, 1, 4)) = (0, 1, 4, 8)

S((8, 0)) = (0, 8) S((1, 4)) = (1, 4)

S((8, )) = (8, ) S((0, )) = (0, ) S((1, )) = (1, ) S((4, )) = (4, )

1https://www.teach.cs.toronto.edu/~csc110y/fall/notes/18-sorting/05-mergesort.html
2https://www.teach.cs.toronto.edu/~csc148h/notes/recursion/branching_recursion.html#branching-recursion



4

Document information

Study
Uploaded on
October 21, 2026
Number of pages
64
Written in
2026/2027
Type
Other
Person
Unknown
$20.26

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

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.
elam17799
3.0
(4)
Sold
25
Followers
1
Items
222
Last sold
3 weeks ago



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