Presentation is loading. Please wait.

Presentation is loading. Please wait.

Today: Office hours –No tomorrow. M/T- 3-on. Overloading operators Inheritance Review.

Similar presentations


Presentation on theme: "Today: Office hours –No tomorrow. M/T- 3-on. Overloading operators Inheritance Review."— Presentation transcript:

1 Today: Office hours –No tomorrow. M/T- 3-on. Overloading operators Inheritance Review

2 Inheritence Weiss: “Any serious use of inheritance requires pointers and heap memory allocation.” –Makes it look more like Java, except you have to worry about garbage collection. –This is why many people say Java is better for object-oriented programming than C++. class Student : public Person {…}; More next time. Chapter 6.

3 Review: Object-oriented design Generics Asymptotics, O notation, recursion Sorting Lists Stacks and Queues Binary Structures OrderedList, OrderedVector Priority Queues, Heaps, Heap Sort Search Trees, Maps, Hash Tables Graphs – thoughts on how to implement C++ - syntax, generics, we built a toolbox.

4 Sorting Insertion / Selection Idea of Quicksort Idea of Mergesort Idea of Heapsort In what situation is insertion sort the best? Why?

5 Lists Write a method that computes __________ about a List (e.g., sum the elements) Write a method that does __________ to a List (e.g., insert a node in the appropriate place).

6 Stacks and Queues Solve depth-first, breadth-first problems using… –We’ve seen three examples: web crawler, post-fix notation, recursion.

7 Binary/Recursive Structures In a method _____, use the methods BT left(), BT right(), and boolean isEmpty() to compute ________ about a BT root. We have seen recursive structures BT and LinkedList. Consider an InfiniteBox, where a particular InfiniteBox contains a Vector of Integer and also an InfiniteBox. put places a number in the InfiniteBox box, either in its Vector or its InfiniteBox, depending on whether the number is a single digit long…write put.

8 Priority Queues, Heaps What is the idea of a priority queue? PriorityVector uses a Vector to implement the idea of a priority queue. How?

9 Maps and Hashtables What’s the idea behind a map? Consider a Hashtable…Here is some hash function. Why is this a poor hash function for the Hashtable? How might you make it better?

10 Graphs We spent some time on the adjacency matrix idea, where the indices correspond to vertices and the elements of the matrix are edges (non-null if there is an edge). How would you use this matrix to determine whether there is a path between vertex i and vertex j? Write the recursive method returning a boolean. –(This would use the visited method to set vertices to visited and prevent infinite recursion).

11 C++ Here is a mostly completed class definition. Fill in the missing method bodies. What additional functionality would be necessary if we were to use this class for _______? Implement this functionality. Provide the values of the variables after the following code executes. –May use pointers, referencing, etc.

12 Practice Questions Ch. 1 –1,2,3,5,6,7,8,10,11. –6 in C++ (I would provide most of the implementation), 7 (assume gcd), 13. Ch. 5 –6, (which of the following methods outperforms the others and why) –3,5,7,11,17, 24, 26, 27 (like prove the sum(i = 1, n) 2*i = n(n+1), use induction)

13 Practice Questions Ch 6 –2,3 –worst, best, average cases for sorts Ch 9 –Self-check problems are about inheritance –5 Ch10 –5,6,7 –We’ve discussed many of the odd probs.

14 Practice Questions Ch 12: –All the self-check problems –1, 7, 9, 11 (see the relation to C++), 12 (see this in the heap idea later, though it’s exponential storage), 20, 21 is a good thought problem to practice for the final. Ch 13: –3,5 –1,2,3,4,6,10,11 Ch 14: –We did the self-check problems in class –1,2,3,11

15 Practice Questions Ch 15: –1,2,4,5,6,7 –1,3, 4, 5 (answer may come as explanation in the test) Ch 16: –1,2,4 –1 and 2 (just the adjacency matrix)


Download ppt "Today: Office hours –No tomorrow. M/T- 3-on. Overloading operators Inheritance Review."

Similar presentations


Ads by Google