Skip to the content of the web site.

Lecture materials

IEEE Spectrum Magazine    MIT Technology Review    Wired Magazine    EDN Network    EE Times    Skeptic's Guide to the Universe

Author: Douglas Wilhelm Harder, Prof. Hiren Patel, and Prof. Werner Dietl

To view the previous slides and topic material, please see the 2018-19 directory.

Many of the examples of programs shown in the lectures are also made available on replit.com. This web site provides an on-line editor and file-storage system together with a C++ compiler. If you create an account at this web site and start developing your own code, be sure sure to choose C++11 as your language. Please see this site for additional information about using replit.com in ECE 150.

All exercises marked with an asterisks (*) should be attempted within a day or two of the topic covered.

  1. Course welcome (PPTX) and YouTube
  2. Programming fundamentals
  3. Addresses and pointers
  4. Algorithms
  5. Classes
  6. Linked lists
  7. Inheritance and polymorphism

1. Programming fundamentals

Topic Video Time PDF Week Required exercises
1 Hello world! YouTube 20:11 PDF
PPTX
1 Using replit.com in this course
Hello world
Finding a bug A *
Finding a bug B
Finding a bug C *
Finding a bug D
Finding a bug E *
Finding a bug F
Printing without IO Streams (optional—not on final)
2 Anatomy of a program YouTube 19:00 PDF
PPTX
1 n/a
3 Literal data YouTube 20:00 PDF
PPTX
1 Literal data *
Exercise at finding a bug *
4 Identifiers YouTube 11:25 PDF
PPTX
1 Exercise at finding a bug
5 Local variables YouTube 9:33 PDF
PPTX
1 n/a
6 Initialization and assignment YouTube 8:16 PDF
PPTX
1 Uninitialized local variables *
Default values *
Initializing local variables *
Assigning to local variables *
7 Arithmetic operators YouTube 24:43 PDF
PPTX
1 Order of operations
Evaluating a polynomial *
Properties of a sphere
Approximating the square root
Integer division and remainder *
Integer division and rounding up
Rational division *
Exercise at finding a bug
Exercise at finding a bug
8 Conditional statements and comparison operators YouTube 18:14 PDF
lecture
PPTX
1 Absolute value
Maximum of two values
Is a value even or odd? *
Calculating commission
Price based on the amount sold *
A simple arithmetic test
Rounding to the closest kilometer *
Is a value positive, zero or negative?
Clipping a value
The tent function
The square wave
A fast Euclidean distance calculator
Calculating income tax
Finding the second-largest of four (hard)
Printing a complex number
A simple calculator
A rational calculator
A complex number calculator
Unit names
The shortest distance between two points
Exercise at finding a bug
9 Logical operators YouTube 28:49 PDF
lecture
PPTX
1 Unit pulse function *
Eligibility to vote
Calculating a difference of years *
Maximum of three
Short-circuit evaluation *
Conditions for passing a course
Do two intervals overlap?
Leap years
Past a specified date
Exercise at finding a bug *
Exercise at finding a bug
Exercise at finding a bug
Week 1 Assignment
10 Assignment operators YouTube 12:11 PDF
lecture
PPTX
2 Swapping two local variables *
Automatic assignment
Rational division (continued) *
Exercise at finding a bug
11 For-loops YouTube 37:28 PDF
lecture
PPTX
2 A simple for loop *
Summing n integers
A for loop: 1 *
A for loop: 2
A for loop: 3
A for loop: 4
A for loop: 5
Calculating integer powers of a number
Calculating a factorial *
Calculating a double factorial
Summing a range of numbers
Finding the greatest common factor
Finding the least common multiple
Is n prime? *
A better is n prime?
Verifying a mathematical formula
Is a Social Insurance Number valid?
Finding the maximum of a quadratic polynomial on a range
Selling stock options
Loops within loops: 1 *
Loops within loops: 2
Loops within loops: 3
Loops within loops: 4
Loops within loops: 5
Loops within loops: 6
Stars in the canton
Plotting an inequality
Integer solutions of an equation
Patterns for for-loops
Problem solving 1.11a
Problem solving 1.11b
12 Scope of local variables YouTube 17:02 PDF
lecture PPTX
2 Scope of a loop variable *
Scope of local variable exercise *
Exercise at finding a bug *
Exercise at finding a bug
13 Break statements YouTube 22:58 PDF
lecture PPTX
2 Enter an increasing sequence *
Finding the integer square root *
Finding a sum of squares
Exercise at finding a bug *
Exercise at finding a bug
14 While loops YouTube 45:55 PDF
PPTX
2 Entering a bounded integer *
Guess a number game
Factoring an integer *
Counting digits in an integer
The Collatz conjecture
Calculating the greatest common divisor *
Writing a number backwards
Writing significant powers of 10
Rational division (continued)
Calculating the floor and ceiling of a base-2 logarithm
15 The structured programming theorem YouTube 17:07 PDF
PPTX
2 Taylor series in C++ *
Taylor series in C *
Taylor series in Scheme
Taylor series in Python *
Taylor series in Ruby
Taylor series in Kotlin
Taylor series in Rust
Taylor series in C#
Taylor series in Java
Taylor series in JavaScript
Taylor series in Haskell (to be written)
16 The call stack YouTube 13:07 PDF
PPTX lecture
2 Example at pythontutor.com *
17 Libraries and calling functions YouTube 31:21 PDF
lecture PPTX
3 Properties of a sphere *
Mathematical constants *
18 Writing functions YouTube 42:16 PDF
lecture PPTX
3 The sine function *
The absolute value function
A cubic spline function *
Maximum and minimum function
The factorial function *
Calculating integer powers of a number
Root finding
Calculating the sum of divisors
Problem solving #1 *
Problem solving #2
18a Functions tutorial YouTube 58:01 PDF
PPTX
- When to write a function (printing time) *
When to write a function (printing significant digits) *
When to write a function (factoring integer polynomials) *
18b Compiler errors YouTube PDF
PPTX
- n/a
19 Assertions YouTube 16:08 PDF
PPTX
3 The factorial function with assertions *
Sine approximations with splines *
Alternative blocks with assertions *
Weierstrass functions
Blancmange curve
20 Code development strategies YouTube 15:50 PDF
PPTX
3
21 Writing tests YouTube 22:47 PDF
PPTX
3
22 Writing comments YouTube 11:20 PDF
PPTX
3
23 Logging YouTube 13:14 PDF
PPTX
3 Logging to find a bug *
24 Debugging YouTube 19:36 PDF
PPTX
4
25 Binary and hexadecimal numbers YouTube 35:26 PDF
PPTX
4 Counting in binary *
Counting in hexadecimal *
Binary and hexadecimal at CS 50 (Harvard)
26 Integer data types YouTube 44:34 PDF
PPTX
4 Binary and hexadecimal representations *
Adding two shorts
Multiplying two shorts *
Clamping an integer value
Clamping with templates (advanced)
Limits of integer data types *
Standardized integer data types (optional—not on final)
27 Bitwise and bit-shift operators YouTube 28:43 PDF
PPTX
4 Bit-wise operations *
Bit-shift operations *
Changing individual bits
Counting 1 bits *
Finding the leading 1 bit
Calculating integer powers of a number *
Power-of-two greater than or equal to
Longest run of 1s, of 0s, and longest run
Guessing a long integer
Select and shift
Accessing, setting, flipping and clearing bits
Is a power of two?
Switching between little and big endian
Clearing the least significant 1
Swapping without temporary variables
Calculating positive powers of an integer
How long to get all four?
Exercise at finding a bug *
Exercise at finding a bug
28 Floating point primitive data types YouTube 9:52 PDF
PPTX
4
29 The const keyword YouTube 9:10 PDF
PPTX
4 Constant local variables *
Constant parameters *
30 Default values of parameters YouTube 8:40 PDF
PPTX
4 An add and a mul function *
Splines with default values *
Sums of powers of divisors
Default address
Exercise at finding a bug *
31 Reference variables, pass-by-reference, and aliases YouTube 27:02 PDF
PPTX
5 Swapping two arguments *
A bounded increment function *
Resetting a local variable while returning the original value *
32 Arrays YouTube 30:29 PDF
PPTX
5 Problem solving #3
Problem solving #4
Problem solving #6
33 More on arrays YouTube 31:19 PDF
PPTX
5 The sum and product of array entries *
Printing array entries
Inputing array entries
Is a value in an array? *
The count, first and last of a value in an array
Checking the result of count, first and last
Finding a least-squares best-fitting line
Is a value in a sorted array?
Is an array sorted? *
Finding the gcd of n integers
Calculating an inner product
Copying an array
Copying part of an array to another
Are two arrays equal?
Is an array within another array?
Find the maximum unreturned entry in an array
The maximum common entry between two arrays
Is an array sorted, reverse sorted, both or neither?
Running sum of an array *
Finding the second-largest unique entry in an array (two loops)
Finding the second-largest unique entry in an array (one loop)
Select non-negative integers
Select unique integers
Partition even-and-odd entries Disjoint sets
Sieve of Eratosthanese
Reversing the entries of an array
The heat equation
Exercise at finding a bug *
Exercise at finding a bug
34 Main memory YouTube 24:12 PDF
PPTX
5
35 Call stack YouTube 25:38 PDF
PPTX
5 Going outside array bounds
36 C-style strings YouTube 27:07 PDF
PPTX
5 Are two strings equal? *
The Hamming distance between strings *
Exercise at finding a bug *
Exercise at finding a bug
A simple hash function
A better hash function
Bit-shifting hash functions
Finding a substring of unique characters
37 Section 1 summary YouTube 7:42 PDF
PPTX
5

1. Programming fundamentals: optional topics

Topic Video Time PDF Week
A The ternary conditional operator YouTube 13:09 PDF
PPTX
n/a

2. Addresses and pointers

Topic Video Time PDF Week Required exercises
1 Addresses and pointers YouTube 23:58 PDF
PPTX
6 Addresses *
Swapping values and addresses *
Resetting a local variable while returning the original value *
2 Dynamic memory allocation YouTube 22:53 PDF
PPTX
6 The first-fit memory allocation algorithm
Implementation of first-fit at replit.com
Sum of powers of divisors *
List of prime numbers *
3 Dynamic allocation of arrays YouTube 13:10 PDF
PPTX
6 Exercise at finding a bug
4 Lifetime of dynamically allocated memory YouTube 21:48 PDF
PPTX
6 -
5 Problems with pointers YouTube 2:31 PDF
PPTX
6 -
5.1 Wild pointers YouTube 11:36 PDF
PPTX
6 -
5.2 Dangling pointers YouTube 13:31 PDF
PPTX
6 Dangling pointers
5.3 Memory leaks YouTube 11:59 PDF
PPTX
6 Exercise at finding a bug
6 Using dynamic memory allocation YouTube 21:16 PDF
PPTX
6 Exercise at finding a bug
7 Protecting pointers with const YouTube 9:04 PDF
PPTX
6 -

3. Algorithms

3. Introduction to algorithms (PDF/PPTX)

Topic Video Time PDF Week Required exercises
1 Seaching an array YouTube 14:41 PDF
PPTX
7 Searching an array
2 Sorted arrays YouTube 15:55 PDF
PPTX
7 Sorted arrays
Exercise at finding a bug
What does this function do?
Is an array strictly increasing?
3 Binary search YouTube 36:24 PDF
PPTX
7 Binary search ASCII art
4 Selection sort YouTube 25:24 PDF
PPTX
7 Selection sort
An alternative selection sort
Exercise at finding a bug
5 Insertion sort YouTube 25:04 PDF
PPTX
7 Insertion sort
Problem solving #5
Insertion sort
6 Introduction to recursive algorithms YouTube 27:30 PDF
PPTX
7 TBD
7 Recursive mathematical functions YouTube 26:15 PDF
PPTX
7 Recursive mathematical functions
Asymptotic growth 1
Asymptotic growth 2
Asymptotic growth 3
Asymptotic growth 4
Asymptotic growth 5
The Ackermann function
Integer partitions
Integer partitions with distinct parts
8 Solving problems recursively YouTube 68:59 PDF
PPTX
8 Recursive selection sort
Recursive insertion sort
Recursive printing a number in binary
Recursive binary search
Recursive printing of subsets
Calculating integer powers of a number
The Levenshtein distance
Calculating Stirling numbers of the first kind
Calculating Stirling numbers of the second kind
Calculating multinomial coefficients
Recursive merge sort
The Cantor function
Efficient Fibonacci calculations
Efficient integer partitions with distinct parts calculations
9 Rotating an array to the left using reverse (optional—not on final) YouTube 15:52 PDF
PPTX
8 Rotate using reverse
10 Polynomial algorithms (optional—not on final) 8 Polynomial algorithms
11 Arithmetic and geometric sequences (optional—not on final) 8 Sequences
12 Function pointers (optional—not on final) 8 Function pointers
13 Reduce (optional—not on final) PDF
PPTX
8 Reduce
14 Scan (optional—not on final) 8 Scan
15 Partition (optional—not on final) PDF
PPTX
8 Partition
16 Transform-reduce (optional—not on final) PDF
PPTX
8 Transform and reduce
17 Inner product (optional—not on final) PDF
PPTX
8 Inner product
18 Adjacent difference (optional—not on final) PDF
PPTX
8 Adjacent difference
21 Catalan numbers (optional—not on final) PDF
PPTX
8 Catalan numbers
Fuss-Catalan numbers
22 Binomial coefficients (optional—not on final) 8 Binomial coefficients
23 Equal-to-index (optional—not on final) 8 Equal to index
24 Disjoint sets (part 2) (optional—not on final) 8 Disjoint sets (part 2)
25 A non-binary partition (optional—not on final) PDF
PPTX
8 Non-binary partitions
26 Swapping between arrays (optional—not on final) PDF
PPTX
8 Swapping between arrays

4. Classes

4. Introduction to classes (PDF/PPTX) (12:52)

Topic Video Time PDF Week Required exercises
1 The class data structure YouTube 24:46 PDF
PPTX
8 n/a
2 Namespaces, std::cout and std::ostream YouTube 14:53 PDF
PPTX
8 Using namespaces
The std::endl function
3 Functions on objects YouTube 42:09 PDF
PPTX
8 A 3-d vector class
A rational number class
An array class
4 Operator overloading YouTube 21:42 PDF
PPTX
9 A 3-d vector class with operator overloading
A rational number class with operator overloading
An array class with operator overloading
5 Issues with member variables YouTube 18:34 PDF
PPTX
9
6 Using member functions YouTube 20:16 PDF
PPTX
9 Using the std::set class
7 Throwing and catching exceptions YouTube 24:37 PDF
PPTX
9
8 Classes, encapsulation and constructors YouTube 58:11 PDF
PPTX
9 A Rational class with private member variables
An increment-only counter
An increment-only counter with operator overloading
Specifying a date class
Implementing a date class
A solution to the date class
9 Classes and the need for encapsulation YouTube 17:44 PDF
PPTX
9 A color class
10 Copies, assignment and the destructor YouTube 53:36 PDF
PPTX
10 Exercise at finding a bug
An increment-only counter with defaults deleted
A class for interger sequences
An improved class for interger sequences
11 Classes, arrays and dynamic allocation of objects YouTube 41:29 PDF
PPTX
10 A safe array
A cyclic array
An n-based safe array
Disjoint sets (part 3)
Specifying a polynomial class
Designing a polynomial class
Implement a polynomial-using-arrays class
Solution to a polynomial-using-arrays class
Non-zero-based array indexing
12 A character set class (optional—not on final) PDF
PPTX
10 A character set skeleton
Design 1
Design 2
Design 3
Design 4
13 Privacy is not security (optional—not on final) 10 Privacy is not security
Privacy is really not security

5. Linked lists

Topic Video Time PDF Week Required exercises
1 Issues and weaknesses with arrays YouTube 11:07 PDF
PPTX
10
2 Introduction to linked lists YouTube 18:53 PDF
PPTX
10
3 A linked list class with dynamic memory allocation YouTube 60:00 PDF
PPTX
10 A linked list class with dynamic memory allocation
4 Adding a list size member variable YouTube 9:27 PDF
PPTX
11 A linked list class with a list-size member variable
5 Adding a tail pointer member variable YouTube 22:38 PDF
PPTX
11 A linked list class with a tail pointer member variable
6 Concatenating two linked lists YouTube 29:05 PDF
PPTX
11 Swapping this linked list with another
Reversing the nodes in a linked list
Checking if a linked list is sorted
Merging two sorted linked lists
Comparison operators on two linked lists
7 The copy and move constructors, and assignment and move operators (optional—not on final) YouTube ??:?? PDF N/A A complete array class
A complete linked list class

6. Inheritance and polymorphism

Topic Video Time PDF Week Required exercises
1 Inheritance YouTube 28:05 PDF
PPTX
11 A linked list class with size
A tailed linked list class
A class derived from std::out_of_range
2 A base linked list class YouTube 13:38 PDF
PPTX
11 A base linked list class
3 A window class for graphical user interfaces YouTube 15:13 PDF
PPTX
11
4 Exception classes and polymorophism YouTube 25:22 PDF
PPTX
11 Extending and using an exception class
Inheritance and polymorphism abstract example
5 A widget class for graphical user interfaces YouTube 21:44 PDF
PPTX
11

The course material for ECE 150 ends here.

7. Additional and optional topics

These topics may have presentations put up prior to the end of the term, but these topics will not be covered on the final examination. If these presentations are not up by the end of the term, keep your eyes on this page over the Winter term, as we will attempt to create at least a few of these in a reasonable time period.

You will know that a video has been uploaded if the Time feild is not ??:??.

Topic Video Time PDF Week Required exercises
1 Pseudo-random numbers YouTube ??:?? PDF
PPTX
12
2 The conditional operator YouTube ??:?? PDF
PPTX
12
3 Static member variables YouTube ??:?? PDF
PPTX
12
4 Templates YouTube ??:?? PDF
PPTX
12
5 Counting sort YouTube 28:14 PDF
PPTX
12 Counting sort
6 this YouTube ??:?? PDF
PPTX
12
7 More Standard Template Library classes YouTube ??:?? PDF
PPTX
12
8 An iterator class for linked lists YouTube ??:?? PDF
PPTX
12
9 A doubly linked list class YouTube ??:?? PDF
PPTX
12
10 Slicing YouTube ??:?? PDF
PPTX
12
11 Multiple inheritance YouTube ??:?? PDF
PPTX
12
12 Enumerated types YouTube ??:?? PDF
PPTX
12
13 The switch statement YouTube 16:51 PDF
PPTX
12