Home Assignments Lecture Blog Resources Discussion Group

All lectures may be reviewed using the Echo360 system:

Note: Right-click on any image to open it in hi-res.

Meeting 38, Fri May 2

  • cross-cutting (across PS's) discussion of Algorithms, Libraries, and Tools/Testing
  • discussion of PS5 – PS7

Meeting 37, Wed Apr 30

  • discussion of PS0 – PS4

Meeting 36, Mon Apr 28

Meeting 35, Fri Apr 25

Meeting 35, Wed Apr 23

Meeting 34, Fri Apr 18

  • using regex's in find and grep:
    find . -name "<filespec>" -print0 | xargs -0 ls -l
    find . -name "<filespec>" -print0 | xargs -0 grep <regex>
    (-print0 and -0 allow filenames with spaces in them)
  • PS7b assigned

Meeting 33, Wed Apr 16

Meeting 32, Mon Apr 14

  • PS7a assigned - first half of Kronos assignment
  • Attach:stdin_boost.cpp handed out
  • interactive experimentation with regex's – figured out smatch submatch operation

Meeting 31, Fri Apr 11

  • James Forance, Kronos
  • introduction to InTouch time clock

Meeting 30, Wed Apr 9

Meeting 29, Mon Apr 7

  • demonstration of working Markov model code
  • discussion of C++ map API
  • looking up a value using subscript operator or at operator creates the kvp in the map; use find or count methods to check for its existence without creating it

Meeting 28, Fri Apr 4

  • there are 4 weeks left in the semester
  • PS6 will be due next Wednesday
  • PS7? will be in collaboration with Kronos; visitor on next Friday
  • We'll do one more Princeton PS (TSP or atomic nature of physics?)
  • Rest of dicussion: how to implement the PS6 Markov model

Meeting 27, Wed Apr 2

Meeting 26, Mon Mar 31

Meeting 25, Fri Mar 28

  • review of PS5b and implementation notes
  • discussion of final project portfolios

Meeting 24, Wed Mar 26

  • guest lecture Derrell Lipman on key events and map

Meeting 23, Mon Mar 24

  • guest lecture Derrell Lipman on PS5b

Meeting 22, Fri Mar 14

  • exception handling for ring buffer PS5a
  • if you don't catch an exception, program terminates and dumps core
  • generic exception is std::exception
  • you can have more specialized exceptions; see (e.g.) http://www.tutorialspoint.com/cplusplus/cpp_exceptions_handling.htm
  • when throwing these exceptions, you can give an error message, which is available in the exception's what method
  • how to catch and print out an exception
  • for ring buffer:
    • passing constructor an invalid arg (input less than 1) should result in a std::invalid_argument exception
    • dequeuing or peeking from an empty ring, or enqueuing to a full one, should yield a std::runtime_error exception
  • Boost can trap exceptions (or verify they're not being thrown) with BOOST_REQUIRE_THROW(code, exception) and BOOST_REQUIRE_NO_THROW(code)
  • PS5a starter code

Meeting 21, Wed Mar 12

Meeting 20, Mon Mar 10

  • re-graded exam 1 handed back; new avg is 29.4 with stddevp of 8.70
  • we are starting the Princeton guitar hero assignment
  • the 1D wave equation
  • for Friday: have the RingBuffer class implemented, along with unit tests using Boost and exception handling for contract violations on constructor, or attempts to enqueue() into a full buffer or call dequeue() or peek() on an empty buffer.


  • makeup class will be scheduled

Meeting 19, Wed Mar 5

  • correct file behavior on PhotoMagic—don't overwrite your starting file
  • old-fashioned error handling is terrible
    • file operations return a null pointer on error
    • main function returns a -1 on error
  • the new way: exceptions
  • you try to execute some code;
    it might throw an exception;
    then you catch it.
  • this is called exception handling
  • http://www.cplusplus.com/doc/tutorial/exceptions/
  • libraries should publish a contract for allowable inputs
  • then they can throw exceptions if called with illegitimate inputs
  • let's think this through for our LFSR class.

Meeting 18, Mon Mar 3

  • Rest of the semester:
    March-April-May 2014
    Su Mo Tu We Th Fr Sa
     2[ 3] 4  5  6  7  8  wk 07 LFSR part B
     9 10 11 12 13 14 15  wk 08 Guitar Hero: ring buffer
    16 17 18 19 20 21 22  spring break
    23 24 25 26 27 28 29  wk 09 Guitar Hero: rest of it
    30 31  1  2  3  4  5  wk 10 TSP
     6  7  8  9 10 11 12  wk 11 TSP/Kronos
    13 14 15 16 17 18 19  wk 12 Kronos
    20 21 22 23 24 25 26  wk 13 Atomic nature
    27 28 29 30  1 [2]    wk 14   of matter
  • Talked about portfolio assessment instead of final
  • Attach:test.cpp Boost unit tests for LFSR starter file
  • Attach:pixels.cpp SFML image load, manipulation, display, and save
  • Went over a Makefile for test.cpp (and sample main.cpp)—see lecture capture
  • PS4b is assigned, due Fri Mar 7

Meeting 17, Fri Feb 28

  • overview of whole assignment:
    • LFSR is initialized with string of 1s and 0s and tap position; these become password for recovering image
    • LFSR generates a series of pseudo-random #s
    • take each byte and XOR with RGB bytes from image
    • this makes encrypted image
    • re-seed LFSR with same init string and tap
    • redo process on encrypted image to recover original
  • manually simulating an 5-bit LFSR with a tap at pos'n 2 to generate a byte

Meeting 16, Wed Feb 26

  • Exam 1 handed back (w/answer key).
    • Thirty students sat the exam.
    • Average was 27.1 (out of a possible 40) and stddevp was 8.01.
    • High score was 37.
  • Extended discussion about each problem. Submit petitions for partial credit to me on Friday.
  • more about how LFSR works.

Meeting 15, Mon Feb 24

  • Echo360 poll
  • efficiencies in vectors vs arrays (including whether allocated or also initialized)
  • when vectors are accessed using subscript, no bounds checking (faster/less safe)
  • discussion of an Edit Distance solution
  • intro to Princeton linear feedback shift register problem

Meeting 14, Fri Feb 21

  • Exam 1

Meeting 13, Wed Feb 19

  • quiz review

Meeting 12, Tue Feb 18

  • implementation notes for EditDistance, including;
  • why should we use classes anyway, if we're only instantiating one object?
  • how to do opt matrix—e.g., a Vector of Vectors vs. C-style array
  • space and time measurement
  • using iSENSE to store time performance data

Meeting 11, Fri Feb 14

Meeting 10, Wed Feb 12

  • PS3 assigned; due Wed Feb 19
  • DNA substring matching formalized as calculation of “edit distance”
  • rules for matching: perfect match=0, mismatch char=1, insert gap=2
  • play with some manual substring problems
  • discussion of dynamic programming approach

Meeting 9, Mon Feb 10

Meeting 8, Fri Feb 7

  • Analytic geometry of triangle poll
  • Sierpinski triangle coding poll
  • talked through analytic geometry using sf::ConvexShape (Matt: also can be done inscribing a triangle in sf::CircleShape)
  • talked through class structure
  • should you initialize a recursive data structure once when your program boots up, or dynamically recurse each time you draw it? This is a matter of taste. Fred prefers the latter, but either is fine.
  • you want something that is called in your main SFML loop as window.draw(sierpinksi);
  • how to have your own class that has a draw method so that the above will work
  • how to submit PS2
  • how to upload your images for PS2 Images

Wed Feb 5

Meeting 6, Mon Feb 3

  • Everyone should work to the best of their abilities
  • We'll have a chance to refactor old projects
  • Looked at Jon's LineSegment implementation
  • Discussion of dimensionality of Sierpinski triangles
  • PS2 is assigned

Meeting 5, Fri Jan 31

Meeting 4, Wed Jan 29

  • http://en.wikipedia.org/wiki/Friend_function (we didn't actually talk about this)
  • N-Body progress poll
  • decided to call the celestial objects Body
  • they each have instance variables: pos_x, pos_y, vel_x, vel_y, mass, texture, sprite
  • could collapse x,y into a vector
  • there's a Universe class that includes radius, timestep, time
  • need a fcn to map from SI meters to pixels (also need window dimensions to do this)
  • as you go through the n^2 of each Body pulling on each other, should you:
    • calculate all of the forces and then move everything at once after all are calculated?
    • do it pairwise and allow slop as the bodies individually move through the update loop?
probably the former is better, but the latter might be easier to code, and Fred believes would still work
  • where does the fcn live that takes a pair of bodies and calculates forces? Universe class

Meeting 3, Mon Jan 27

  • SMFL event loop—only do one update in the loop (don't loop through all your updates, just do one)
  • rest of the physics—figuring out what the leapfrog means; we update the velocity first and then use the updated velocity in the position update
  • principle of superposition
  • initial OO designs for overall implementation

Meeting 2, Fri Jan 24

Meeting 1, Wed Jan 22