CPSC 212-001, Algorithms and Data Structures
Spring 2009
Warning: This page is updated frequently. Check it often!
Text references refer to material in:
-
Mark A. Weiss, Data Structures and Problem Solving Using C++, Third Edition, Addison-Wesley, 2009
- Thursday, January 8, 2009
- Monday, January 12, 2009
- Lecture Topics: Binary Trees, Representation, Binary Search Trees, k-ary trees
- Preparing for class
- Lex 1
- Tuesday, January 13, 2009
- Lecture Topics: Why analyze algorithms? Common Formulas.
- Preparing for class
- Lecture Topics: Analysis of Algorithms, big-Oh, big-Omega, big-Theta, small-oh
- Study Guide: Recommended Textbook Problems
- Wednesday, January 14, 2009
- Special Review Session Lecture Topic: Infix to Postfix
- Expression Trees, Postorder Traversal, Operator Stack
- Infix to Postfix
- Thursday, January 15, 2009
- Read before class: § 4.1 - 4.4 (through AVL trees)
- Notes
- AVL demo
- Monday, January 19, 2009
- Special Review Session Lecture Topic: Postfix to Quadruples
- Expression Trees, Postorder Traversal, Operand Stack
- Tuesday, January 20, 2009
- Read before class: § 4.1 - 4.4 (through AVL trees)
- Notes
- AVL demo
- New Topic: Deleting nodes from a BST
- Thursday, January 22, 2009
- Monday, January 26, 2009
- When you're feeling down ...
- Lab #1: See MessageGrid "CPSC 212 090126"
- Topics: Simple C++ programs, including "Hello World", "Simple Arithmetic Operations", "Loops and arrays", "Palindromes", "Tokens"
- Tuesday, January 27, 2009
- Recursion
- Lecture Topics: Recursion, Trees, Numerical Applications
- Sample Questions
- Towers of Hanoi
- Write recursive pseudocode that ...
- ... returns the number of binary tree nodes that have even value
- ... returns the sum of all leaves of a binary tree
- ... returns the smallest node value in a binary tree
- ... returns a reference to the node with smallest value in a binary tree
- Sample recursion programs
Thursday, January 29, 2009
Monday, February 2, 2009
Tuesday, February 3, 2009
Thursday, February 5, 2009
- Test #1
Answer Key
Coverage: everything covered through February 3, 2009.
Mathematical formulae. Analysis of algorithms. Recursion. Trees. Binary Search Trees. AVL Trees.
- Simple Test Driver
Monday, February 9, 2009
- Lab #3: Test #1 Review
- Intro to Priority Queues (Weiss, Chapter 6), Binary Heaps (Weiss, § 6.3)
Tuesday, February 10, 2009
- Topic: Binary Heaps
- Notes:
- Thursday, February 12, 2009
- Topic: Leftist and Skew Heaps: (Weiss, § 6.6 and 6.7, pp. 229 - 239)
- Topic: Leftist and Skew Heaps: Merge, Insertion, Deletion
- Leftist Heaps, Skew Heaps
- Quzzle
- Monday, February 16, 2009
- GraphPad Exercise: Leftist Heaps: (Weiss, § 6.6 and 6.7, pp. 229 - 239)
- GraphPad Exercise: Skew Heaps: Merge, Insertion, Deletion
- New Topic: Binomial Queues
- Binomial Queues
- Tuesday, February 17, 2009
Thursday, February 19, 2009
Monday, February 23, 2009
Tuesday, February 24, 2009
Thursday, February 26, 2009
Monday, March 2, 2009
Tuesday, March 3, 2009
- Snow Day
- Review Session for Test 2 - 7:00-8:00 pm, McAdams 116
Thursday, March 5, 2009
- Test #2
Coverage: everything covered from Test #1 through Hashing: B-Trees,
Disk storage, hashing, priority queues, binary heaps, leftist heaps, skew heaps, binomial queues
- Test #2
Answer Key
Monday, March 9, 2009
- C++ Basics and Classes
- C++ Examples
- Submit files called StudentManager.cpp, StudentManager.h, and main.cpp that implement and test the StudentManager class described in slide #44 of classes.pdf. Also submit Student.* files as necessary.
- Submit files called String.cpp, String.h, and main.cpp that implement the String class described in slides #64 of classes.pdf.
- Submit files called List.cpp, List.h, and main.cpp that implement the List class described in slides #97 of classes.pdf.
- Submit using:
sendlab.212.1 3 <files>
Tuesday, March 10, 2009
Thursday, March 12, 2009
Monday, March 16, 2009
Tuesday, March 17, 2009
Thursday, March 19, 2009
Monday, March 23, 2009
-
- Program #3: Implement Quicksort as described in Weiss, §7.7. Due 11:59 pm, Thursday, March 26.
- Here is the test driver I will use to evaluate your program.
I may modify it a bit, but it will be very similar. Review the contents and see how it creates
random vectors. Use the code that Weiss provides exactly. That is, your array arguments
should be Comparables.
- It needs a header file called Random.h and a
source file called Random.cpp. Download these now.
- Note that the test driver uses a file uses a file called
Sort.h which you must write.
This file contains Weiss' quicksort routines. Here is the beginning
of file Sort.h.
- Here is sample output. Your output should be similar.
- Before the due date/time, you should submit one file called Sort.h thus:
- O(N^2) sorting algorithms - Bubble, Selection, Insertion
- Be able to write pseudocode for each one
- Be able to analyze each one
- External Sorting
- Heapsort to generate long runs
(on average twice the size of available memory)
- Mergesort (merge long runs in pairs)
- O(N log N) sorting algorithms - Mergesort, Heapsort, Quicksort
- Best case complexity for sorting by comparisons
- Decision tree (build tree for 3 balls, build tree for 4 balls)
- Unusual sorting algorithms:
- Pigeon-hole sort (post office boxes, homing pigeons, direct access array)
- Radix sort (punch cards, IBM card sorter)
- Shellsort (§7.4)
Tuesday, March 24, 2009
Thursday, March 26, 2009
Monday, March 30, 2009
- Dijkstra's Algorithm (Single Source/Multiple Destination Shortest Path)
- Minimum Spanning Tree Algorithms (Prim and Kruskal)
- Program #4: Write a C++ program called "dijkstra" that
- Reads a file representing an adjacency matrix representation of a graph from the command line. The first line contains an int, N, representing the number of nodes in the graph. A sample file is shown
here,
here,
here, and
here.
.
- Prints the adjacency matrix neatly with an appropriate label.
- Prints N final Dijkstra tables representing shortest paths from each node i, 0 ≤ i ≤ N − 1. If there is no path from node i to node j, then the distance to, and previous node of, node j should be "-".
- Submit your program using: handin.212.1 4 <files>
- One file should be labelled, "dijkstra.cpp"
- Deadline: 11:59 pm, Friday, April 3
Tuesday, March 31, 2009
Thursday, April 2, 2009
Monday, April 6, 2009
Tuesday, April 7, 2009
- Travelling Salesman Problem - Wikipedia
- Travelling Salesman Problem Examples
- Program #5: Write a C++ program called "tsp" that
- Reads a file representing an adjacency matrix representation of a graph from the command line. The first line contains an int, N, representing the number of nodes in the graph. A sample file is shown
here, and
here.
Note that the matrix need not be symmetric.
- Prints the adjacency matrix neatly with an appropriate label.
- Prints successively better TSP solutions for the problem represented by the graph. The final solution should be the optimal solution.
- Solutions should be a tour cost followed by a permutation of the integers 0 through (N-1) representing the sequence of cities visited. Remember to include the edge from the last city back to the first in your total cost. For example, a solution:
58 - 5 3 1 2 0 4 means that the tour from city 5 to 3 to 1 to 2 to 0 to 4 and back to 5 costs 58 units.
- To repeat: A solution should be printed if it is better than the previous one printed. The last solution should be the best solution found.
- Note that a "0" in the matrix means that no edge exists. You may interpret this to mean that there is "infinite" cost between the two cities.
- Submit your program using: handin.212.1 5 <files>
- One file should be labelled, "tsp.cpp"
- Deadline: 11:59 pm, Tuesday, April 14
- Knight's Tour Demo
- Knight's Tour (Wikipedia)
Thursday, April 9, 2009
- Huffman Trees, Section 12.1
Monday, April 13, 2009
Tuesday, April 14, 2009
- Knight's Tour, Depth-first search
- Genetic Algorithms
- Review Session for Test #3: today, April 14, 5:00 pm, McAdams 116
Thursday, April 16, 2009
- Test #3
- Coverage: Sorting (N^2: inssertion, selection, bubble, N log N: merge, heap, quick, Unusual sorts: radix, pigeon-hole, shell), Pseudo-code for sorting algorithms, Decision Tree (conclusion regarding lower limit on sorting by comparison), all algorithms associated with any of the sorts, k-ary trees, Graphs (implementation, definitions), Graph algorithms (Topological Sort, Dijkstra, Prim, Kruskal, depth-first, breadth-first), Huffman Trees, Disjoint Sets, Travelling Salesman Problem (TSO), Knight's Tour, induced graphs
Monday, April 20, 2009
Tuesday, April 21, 2009
Thursday, April 23, 2009
Monday, April 27, 2009
Tuesday, April 28, 2009
- Review for Final Exam: 6:00 pm, McAdams 116
Wednesdsay, April 29, 2009
- Final Exam, 8:00 - 10:30 am, Holtzendorf B-003
(pargas@cs.clemson.edu)
Last update:20 December 2008