Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
14 Cards in this Set
- Front
- Back
Abstract Class vs Interface |
- An interface is not a class -Abstract classes are meant to be inherited from implementing class is not necessarily strong -An abstract class may provide some methods with definitions
|
|
When to use Abstract Classes vs When to use Interfaces |
- Abstract class is good if you think you will be using inheritance since it provides a common base class implementation to derived classes. - Abstract class good if you want to declare non-public members |
|
Object-Pointer Model for Graphs (Complexities) |
Memory complexity: O(n) where n is the number of objects to represent the graph (1 node = 1 object) O(n^2) number of pointers because each node can have an edge to all other nodes |
|
Object-Pointer Model for Graphs |
- Better for directed graphs because with undirected graphs, pointers would need to be maintained in pairs which may become unsynchronized - Not optimal for weighted-edge graphs because object-pointer model would need to store edge weights in a parallel array which requires synchronization with the pointer array |
|
Matrix Model for Graphs |
- Matrix model is beneficial for weighted-edge graphs because edge weight can be stored in matrix entry (i,j) where i,j <=n where n is the number of nodes in the graph |
|
Matrix Model for Graphs (complexities) |
Memory complexity: O(n^2) because you have n x n entries in the matrix, one entry for each possible edge between node i and j |
|
Adjacency List Model for Graphs |
Collection of unordered lists used to represent a graph.l Each list is associated with a node in the graph. Each link in the list represents the existence of an edge between the node represented by the list and the node represented by the link in the list. |
|
Adjacency List Model for Graphs (complexities) |
Memory: uses memory in proportion to the number of edges. Might save a lot of space if graph being represented is sparse (many real-world graphs are sparse. The internet graph model is sparse). Time: Each list is as long as the degree of a vertex, worse case lookup is O(n). |
|
Function vs Method |
Function is a piece of code that is called by name. It can be passed data to operate on and can optionally return data. All data is passed to a function explicitly Method is a piece of code called by name that is associated with an object. Most cases identical to function except: on which it is called is contained in the class |
|
Object vs Class |
- Class is a mechanism of binding data members and associated methods in a single unit - Object is an instance of a class |
|
Abstract Base Class |
A class in C++ is known as an Abstract Base Class if it has at least one pure virtual function is how you create a pure virtual function (virtual keyword and =0 at the end). |
|
Virtual Function vs. Pure Virtual Function |
Virtual functions provide implementation in the base class. Pure virtual functions do not provide an implementation in the base class. |
|
Multiple Inheritance |
Note that this is only allowed in C++. |
|
C++ vs. Java |
Main differences between the two languages: - Java runs in VM |