Lecture Outline for Week 13 I. Relation between new/delete and malloc/free - steps of new 1. call malloc to allocate necessary memory 2. call the constructor if it exists - steps of delete 1. call deconstructor if it exists 2. after deconstructor returns, call free to deallocate memory - we can take advantage of this in our code - see count_words.cpp as an example of using the destructor to free a linked list II. Streams - a stream is an abstract data type - a stream is an infinite sequence of data - 2 common streams: standard input and standard output - any potentially infinite file can be considered a stream - a filter is a module that can be placed on the stream to modify or block the data on the stream - example: Sieve of Eratosthenes - a 2000 year old algorithm to find the prime numbers - start with a stream which gives the natural numbers starting with 2 - repeat the following - get the next number from the stream, this is the the next prime number - place a filter on the stream blocking any multiples of this number - see streams.cpp as an example of streams III. Review of the main topics of this course - basic C - strings - arrays and multidimensional arrays - pointers - functions - structures - memory management - procedure stack - heap - allocating and freeing memory (rules!) - abstract data types - C++ - objects and classes - classes vs. structures, copying objects & structures - constructors, deconstructors - other topics - references, memory management, exceptions - floating point numbers - representation - arithmetic - addition, subtraction, multiplication - guard digit, full multiplication - rounding: biased vs. unbiased - precision issues with addition and subtraction - how accurate are floating point numbers - logarithmic distribution - numerical methods - types of error - round off, truncation, approximation - relative vs. absolute error - round off error - unit round off error - analyzing round off error - approximation error - rates of convergence - significant digits - stability of computations - condition number - dynamic programming - strategies - how to go from a recursive algorithm to a dynamic programming algorithm - examples: Knapsack, matrix multiplication, pickup sticks, Optimal Binary Search Tree - comparison with other algorithms - greedy method - divide & conquer - memoization - graphs - definitions - how are graphs represented in a computer - depth first search & breadth first search - shortest path algorithms - Dijkstra, Floyd-Warshall all-pairs, general all-pairs - modeling and simulation - classifications of model and simulator types - parts of a simulator - statistics - random numbers and pseudorandom numbers - probability distributions - the different types of distributions - how to convert one to another - output statistics - sample mean, sample variance, confidence interval - repeated squaring - priority queues - implementation using a heap - streams