CSCI 261E/F: Programming Concepts

Fall/Winter 2010

Lecture Notes & Examples

Dec 6: Lecture 29, Final Exam Review

no slides. See final exam tips.

How do I ace the final exam?

Homework: Finish final project and study for the final exam.

Dec 6: Lecture 28, Dynamic Programming, Randomness, Random ("Drunkard's") Walk, Additional C++ features, Other Languages

no slides.

What is the big deal with "overlapping sub-problems" that often occur in recursive algorithms?

What is Dynamic Programming?

What are stochastic models?

What is the Random Walk problem?

C++: do/while, switch

What is the difference between an interpreted vs. a compiled program?

What does it mean for a language to be considered Turing-complete ?

Other language examples (Ruby, Python, PHP, Java).

Homework: Finish assignment FluPolicy and Final Project.

Dec 3: Lab 11, FluPolicy, Final Project

no slides

Homework: Continue assignment FluPolicy and Final Project.

Dec 1: Lecture 27, A Mind-Bending Journey into Computer Memory, Pointers, Algorithms, Recursion, Finding and Sorting, and Asymptotic Notation

no slides. example code

What is a variable identifier, really?

Where do values actually 'go' when they are assigned to a variable?

What is a memory address?

What is a pointer?

Why do pointer types matter?

Why is it important to be able to find things in constant time?

What is asymptotic ("Big-O") notation? What does it represent?

What do real world problems have to do with algorithms?

How can you compare algorithms and determine if one is "good" vs. "bad"?

Homework: Continue final project and FluPolicy.

Nov 29: Lecture 26, Recursion, Dynamic 1d Arrays

no slides. example code

Bonus: What is recursion?

What is meant by "dynamic memory allocation?"

How do you tell the computer to allocate memory for you? (new)

How do you tell the computer to release allocated memory? (destroy)

How can you dynamically allocate memory for an array of objects?

Homework: Read section 9.4 and complete assignment AllocatedTriangles.

Nov 22: Lecture 25, Midterm Results, Overloading I/O Operators, TrianglePrep

no slides

How do you overload i/o operators (<< and >>)?

Homework: Complete assignment FluVaccine.

Nov 17: Lecture 24, Midterm Review

How do you ace the midterm?

Homework: Study for midterm, complete assignment TrianglePrep.

Nov 15: Lecture 23, Classes & Objects Review, Operator Overloading

slides, friend function example, solid-friend-operator.cpp, CubeClass.h, CubeClass.cpp

Classes review, MonthClass review.

What is operator overloading and why is it convenient?

How do you overload operators?

What is a friend function and how do you use one?

Homework: Read 10.1 & 10.2, complete assignment SolidFriendOperator.

Nov 12: Lab 10, MonthClass

no slides. see SimpleMonthTest.cpp.

Homework: Complete assignment MonthClass and FluSimulation.

Nov 10: Lecture 22, Classes IV (Yong absent)

see Professor Hellman's slides.

const integer data members

Arrays as data members

arrays of objects

returning anonymous objects

Homework: Complete assignment FluSimulation.

Nov 8: Lecture 21, Classes & Objects Review, Accessor Functions, I/O Functions

no slides. see accessors and class I/O.

Let's review functions, scope, classes and objects, yay!

What are accessor methods and what pattern do they almost always follow?

What common pattern should you remember for a class' I/O functions?

Homework: Complete assignment PlayerClass.

Nov 5: Lab 9, Getters, Setters, const functions, StudentFlu

no slides

What are getters and setters?

What canonical pattern do typical getters and setters follow?

Homework: complete assignment StudentFlu.

Nov 3: Lecture 20, Classes & Objects

slides

code: solid-class.cpp, CubeClass.h, CubeClass.cpp

What is an object? How do we program with real-world objects?

What are some general properties of objects?

How do you use the dot operator?

What is a class? (How do you tell a computer what your real-world object is like?)

What do keywords private and public do?

How do I define a class? How do I implement member functions?

What is a constructor? How do I declare one? How do I use one?

Homework: Re-Read 8.1, 8.2, 8.4, 8.7 Complete assignment SolidBeginningsClass.

Nov 1: Lecture 19, Intro to Classes and Objects, WeekSchedule

no slides

What is an object? How do we program with real-world objects?

What are some general properties of objects?

How do you use the dot operator?

What is a class? (How do you tell a computer what your real-world object is like?)

Homework: Read 8.1, 8.2, 8.4, 8.7 and complete assignment WeekSchedule.

Oct 29: Lab 8, OverloadedInputValidation

no slides

Homework: Choose your final project partner and complete assignment OverloadedInputValidation.

Oct 27: Lecture 18, Functions IV, Passing and Returning stream Objects, Function Overloading

no slides. see function overloading

What is function overloading and how do you do it?

What is the proper return type for functions that return stream-related objects?

Homework: Choose your final project partner and complete assignment ThresholdDataFunction.

Oct 25: Lecture 17, Functions III, rand()omness

slides

What is special about computers and randomness?

What is a random seed value and why might you always need one?

How do you use rand() and srand() properly?

Why should objects always be passed by reference?

Fisher-Yates shuffling algorithm review.

Final Project announcements.

Homework: Choose final project partners, Read 5.5 and complete assignment ShuffleWords.

Oct 22: Lab 7, LetterFrequencyByFunction, ShiftCipherByFunction

no slides

Homework: Complete assignments LetterFrequencyByFunction and ShiftCipherByFunction.

Oct 20: Lecture 16, More FUNctions, BubbleSort Algorithm

slides

How do you declare a function that doesn't return anything?

How do you declare a function that doesn't require any input?

How should you declare const parameters?

What are static const global variables and how do you declare them?

How are array arguments passed?

How do you declare a formal parameter that is an array? (1d, 2d)

What is the BubbleSort algorithm?

Homework: Review slides and complete assignment BubbleSort.

Oct 15: Lab 6, QuadraticRoots, VoidReferenceSolidMetrics

no slides

Homework: Complete assignments QuadraticRoots and VoidReferenceSolidMetrics.

Oct 13: Lecture 15, Functions II, Exam Review

slides and sample code

Functions review

How do you use a header (.h) and implementation (.cpp) file to define your functions?

What is scope?

What is pass-by-value? What is pass-by-reference?

Homework: Read 5.3 and complete assignment ReferenceSolidMetrics

Oct 11: Lecture 14, Functions

slides

What is a function, in general?

What is a function in C++?

What are the parts of a function?

What is a user-defined function? What is a library function?

What is a formal parameter? What is an argument?

How do you declare, implement and use a function in your program?

What is a header file?

Homework: Read 5.1 & 5.2 and complete assignment SolidBeginningsFunction.

Oct 6: Lecture 13, Review

no slides

How do I ace the midterm?

Homework: Study for exam 1.

Oct 4: Lecture 12, A Brief Intro to Classes, Objects, and the string Class

slides and string API

Who is Ivan Sutherland?

What is "Object-Oriented Programming?"

What is the difference between a class and an object?

How does a string object behave (what functions does a string object provide)?

Homework: Complete assignment NamePrinter.

Oct 1: Lab 5, LetterFrequency, BinarySearchWords

no slides

Homework: review chapters 6.1, 7.1 & 6.9 and complete assignments LetterFrequency and BinarySearchWords.

Sep 29: Lecture 11, Multi-dimensional Arrays

slides

Scan of problem 7.6.

Array review

What is a two-dimensional array?

What are some ways to envision the structure of a 2D array?

How do you access and assign values in a 2D array?

How do you typically loop over a 2D array?

Homework: read chapter 6.9 and complete assignment PowerPlantMax.

Sep 27: Lecture 10, Arrays, Binary Search Algorithm

slides

What data structure can you use to hold multiple values of a particular type?

What is an array?

How do you declare and initialize an array?

How can you assign a value to one position in an array?

Why does array size matter?

How can you create a loop to access/manipulate all values in an array?

Homework: read chapter 6.1 & 7.1 and complete assignment ThresholdData.

Sep 24: Lab 5, SutureRejects, CodeAdvice

no slides.

Scan of Page 179.

How can you get a whole line of text using getline()?

What unwanted behavior happens when you try to open both an ifstream and an ofstream on a file simultaneously?

How can you capture more than one line of input from cin?

Homework: Complete assignments SutureRejects and CodeAdvice.

Sep 22: Lecture 9, File I/O in Detail, ShiftCipher

slides

What is the general boilerplate code for basic file I/O?

How can you tell your program to create a file?

How do datatypes affect the behavior of reading input streams?

Homework: Complete assignment ShiftCipher.

Sep 20: Lecture 8, File I/O Basics, IntegerChars

slides

How do you tell your program to open and close a file?

How can you get your program to work with the contents of a file?

Which C++ library do you need to work with filestreams?

Homework: Complete assignment IntegerChars.

Sep 17: Lab 4, LoopRunTimes, TimberRegrowthYears

Homework: Complete assignment LoopRunTimes and TimberRegrowthYears.

Sep 15: Lecture 7, Flow Control (for loops)

slides

How do you use a for loop?

How can you escape from a loop?

Homework: Complete assignment FindPrimes.

Sep 13: Lecture 6, Flow Control (while loops)

slides

How do you use a while loop?

What is an infinite loop?

What is the difference between while and do while?

In general, when should you use a while loop rather than a for loop?

Homework: Read 3.4. Complete assignment FiveModSum.

Sep 10: Lab 3, if, else if, InputValidation, PaperScissorsRock

slides

How do you use an if statement? (review)

Homework: Complete assignments InputValidation and PaperScissorsRock.

Sep 8: Lecture 5, Flow Control

slides

What do we mean by procedural?

How do you use an if statement?

How are ints and bools related?

How do cin and cout treat bool values?

What are ASCII numeric codes for characters?

Homework: Read 3.3 (skip 'conditional operator' and switch). Complete assignment AsciiExplorations.

Sep 6: Lecture 4, Boolean Expressions

slides

Who is George Boole?

How can I use screen specs, flowcharts, and pseudocode to guide my construction of a program?

What do the weird flowchart symbols mean?

What is a boolean expression?

Remember: expressions get evaluated and yield a value

What are the boolean operators and how do they work?

Homework: Read 3.1, 3.2. Complete assignment BooleanExpressions.

Sep 3: Lab 2, Variable Types and Casting

What happens when you have operations with different variable types? (p50 - 51 "mixed operations")

What is casting? (p51)

Refer to (p50- 51) "mixed operations", (p51) casting. Review on Monday 9/6.

Homework: Complete assignment TKtoTF and AminoAcidAverageWeight.

Sep 1: Lecture 3, C++ Fundamentals Continued

slides

Who is Alan Turing? What is a Universal Machine?

Comments, case sensitivity, variable names, types, variable declaration syntax, constants, operators, increment/decrement, cmath library, functions (in brief).

Simple text formatting with cout (see pages 58 - 62).

Homework: Finish reading chapter 2.1 - 2.4, 2.7. Complete assignment VolumeOfSphere.

Aug 30: Lecture 2, C++ Fundamentals

slides and supplement

Who is Bjarne Stroustrup?

What are some "cool" things programs can do?

How would you describe the programmer's typical toolchain?

What is the difference between a syntax error and a logic error?

C++ program structure, preprocessing directives, main(), code blocks, variables, types, I/O, CIN, COUT.

Homework: Read chapter 2.1 - 2.4, 2.7. Complete assignment MilesToKilometers.

Aug 27: Lab 1, Setting up Dev-Cpp

slides

Set up your development environment.

Compile and run a program.

Understand what we just did.

Homework: Finish chapter 1 (skip 1.4). Complete assignment SolidBeginnings.

Aug 25: Lecture 1, Introduction

slides

Introductions

What's a modern computer system? What is hardware? Software?

What do we mean by abstraction?

What is a computer program?

Who is Ada Lovelace?

Why are computer languages so weird?

Why program?

Administrivia.

Homework: Read chapter 1 (skip 1.4). Enroll in blackboard course. Read and understand the syllabus.

more fun stuff

Syntax Poem

< > ! * ' ' #
^ " ` $ $ -
! * = @ $ _
% * < > ~ # 4
& [ ] . . /
| { , , SYSTEM HALTED

Waka waka bang splat tick tick hash,
Caret quote back-tick dollar dollar dash,
Bang splat equal at dollar under-score,
Percent splat waka waka tilde number four,
Ampersand bracket bracket dot dot slash,
Pipe curly-brace, comma comma CRASH.

Fred Bremmer and Steve Kroese, 1990 Infocus

Cool Graphics Programming?

.


Social Network or Systemic Isolation?

Justin Hall's breakdown video.


Relics from _why

Nobody Knows Shoes

Whys Poignant Guide to Ruby


Programming as Performance Art

A description of Live Coding at Shunt Lounge 1 Oct 2009


Programming as a Passion

Highly recommended viewing (not just about Archaeopteryx).

How to Be a Programmer

If Giles postmodern programmer-bum story is too much for you, here's a more pragmatic essay.