Lecture Notes on
Spanning Trees
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 26
April 26, 2011
The following is a simple example of a connected, undirected graph
with 5 vertices (A, B, C, D, E ) and 6 edges (AB , BC , CD, AE , BE ,
Lecture Notes on
Search in Graphs
(Partial Draft)
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 24
November 27, 2012
1
Introduction
In this lecture we introduce graphs. Graphs provide a uniform model for
many structures, for example,
Lecture Notes on
Programs as Data: The C0VM
15-122: Principles of Imperative Computation
Thomas Cortina
Notes by Frank Pfenning
Lecture 23
November 20, 2012
1
Introduction
A recurring theme in computer science is to view programs as data. For
example, a c
Lecture Notes on
Generic Data Structures
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 22
November 15, 2012
1
Introduction
Using void* to represent pointers to values of arbitrary type, we were able
to implement generic stacks in tha
Lecture Notes on
Tries
15-122: Principles of Imperative Computation
Thomas Cortina
Notes by Frank Pfenning
Lecture 21
November 8, 2012
1
Introduction
In the data structures implementing associative arrays so far, we have needed
either an equality operatio
Lecture Notes on
Memory Management
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 20
November 6, 2012
1
Introduction
Unlike C0 and other modern languages like Java, C#, or ML, C requires programs to explicitly manage their memory. All
Lecture Notes on
Polymorphism
15-122: Principles of Imperative Computation
Frank Pfenning, Rob Simmons
Lecture 19
November 1, 2011
1
Introduction
In this lecture we will start the transition from C0 to C. In some ways, the
lecture is therefore about knowl
Lecture Notes on
AVL Trees
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 18
October 30, 2012
1
Introduction
Binary search trees are an excellent data structure to implement associative arrays, maps, sets, and similar interfaces. The
Lecture Notes on
Binary Search Trees
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 17
October 25, 2012
1
Introduction
In the previous two lectures we have seen how to exploit the structure of
binary trees in order to efciently implem
Lecture Notes on
Restoring Invariants
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 16
October 23, 2012
1
Introduction
In this lecture we will implement operations on heaps. The theme of this
lecture is reasoning with invariants that
Lecture Notes on
Priority Queues
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 15
October 18, 2012
1
Introduction
In this lecture we will look at priority queues as an abstract type and discuss several possible implementations. We th
Lecture Notes on
Interfaces
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 14
October 16, 2012
1
Introduction
The notion of an interface to an implementation of an abstract data type or library is an extremely important concept in com
Lecture Notes on
Hash Tables
15-122: Principles of Imperative Computation
Frank Pfenning, Rob Simmons
Lecture 13
October 11, 2012
1
Introduction
In this lecture we re-introduce the dictionaries that were implemented as a
part of Clac and generalize them a
Lecture Notes on
Unbounded Arrays
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 12
October 4, 2012
1
Introduction
Most lectures so far had topics related to all three major categories of learning goals for the course: computational t
Lecture Notes on
Stacks
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 10
September 27, 2012
1
Introduction
In this lecture we introduce another commonly used data structure called
a stack. We practice again writing an interface, and
Lecture Notes on
Queues
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 9
September 25, 2012
1
Introduction
In this lecture we introduce queues as a data structure and linked lists that
underly their implementation. In order to impleme
Lecture Notes on
Quicksort
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 8
September 20, 2012
1
Introduction
In this lecture we rst sketch two related algorithms for sorting that achieve
a much better running time than the selection
Lecture Notes on
Sorting
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 7
September 18, 2012
1
Introduction
We begin this lecture by discussing how to compare running times of functions in an abstract, mathematical way. The same under
Lecture Notes on
Binary Search
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 6
September 13, 2012
1
Introduction
One of the fundamental and recurring problems in computer science is to
nd elements in collections, such as elements in
Lecture Notes on
Linear Search
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 5
September 11, 2012
1
Introduction
One of the fundamental and recurring problems in computer science is to
nd elements in collections, such as elements in
Lecture Notes on
Arrays
15-122: Principles of Imperative Computation
Frank Pfenning, Andr Platzer
e
Lecture 4
September 6, 2012
1
Introduction
So far we have seen how to process primitive data like integers in imperative programs. That is useful, but cert
Lecture Notes on
Ints
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 3
September 5, 2012
1
Introduction
Two fundamental types in almost any programming language are booleans
and integers. Booleans are comparatively straightforward: th
Lecture Notes on
Contracts
15-122: Principles of Imperative Computation
Frank Pfenning
Lecture 2
August 30, 2012
1
Introduction
For an overview the course goals and the mechanics and schedule of the
course, please see course Overview. In these notes we re
15-122: Principles of
Imperative Computation
Lecture 1: Frank Pfenning & Ananda Gunawardena
Lecture 2: Thomas Cortina & Rob Simmons
http:/www.cs.cmu.edu/~fp/courses/15122-f12
http:/c0.typesafety.net
Overview
Goals of this course
Interactions
Lectures,
15-122 Assignment 7
Page 1 of 12
15-122 : Principles of Imperative Computation
Fall 2012
Assignment 7, Update 1
(Theory Part)
Due: Tuesday, November 20, 2012 at the beginning of lecture
Name:
Andrew ID:
Recitation:
The written portion of this weeks homewo
15-122 Assignment 6
Page 1 of 8
15-122 : Principles of Imperative Computation
Fall 2012
Assignment 6
(Theory Part)
Due: Thursday, November 8, 2012 at the beginning of lecture
Name:
Andrew ID:
Recitation:
The written portion of this weeks homework will giv
15-122 Assignment 5
Page 1 of 11
15-122 : Principles of Imperative Computation
Fall 2012
Assignment 5
(Theory Part)
Due: Tuesday, October 30, 2012 at the beginning of lecture
Name:
Andrew ID:
Recitation:
The written portion of this weeks homework will giv
15-122 Assignment 4
Page 1 of 12
15-122 : Principles of Imperative Computation
Fall 2012
Assignment 4
(Theory Part)
Due: Thursday, October 18, 2012 at the beginning of lecture
Name:
Andrew ID:
Recitation:
The written portion of this weeks homework will gi
15-122 Assignment 3
Page 1 of 12
15-122 : Principles of Imperative Computation
Fall 2012
Assignment 3
(Theory Part)
Due: Thursday, October 4 at the beginning of lecture.
Name:
Andrew ID:
Recitation:
The written portion of this weeks homework will give you
15-122 Assignment 2
Page 1 of 12
15-122 : Principles of Imperative Computation
Fall 2012
Assignment 2
(Theory Part)
Due: Tuesday, September 25, 2012 at start of lecture
IMPORTANT: See last page for a change log of post-release notes.
Name:
Andrew ID:
Reci