• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/55

Click to flip

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;

55 Cards in this Set

  • Front
  • Back
Liskov's Substitution Principle
Any method that expects an object of type superclass must be able to use in its place an object of any subclass.
When do we need to be careful about using inheritance?
Anytime we start to override we are probably violating the substitution principle, be careful with overriding.
What is type specific code, and how is it overcome
Type specific code is code is writen for different data types. This is overcome by writing generic methods.
What is an object's state? What is a stable state?
An object's state is the value of it's attributes. An object is in a stable state when the values of its attributes make the invariants true.
What is a class invariant and loop invariant.
Class invariant - the loosest definition of a data structure that must always be true for the object to be legal.
Loop invariant - something which must be true before and after each iteration of a loop is run.
Difference between static and dynamic arrays?
Static size is set at compile time, its memory is permanetly bound, and its size is fixed. Dynamic can be given at runtime if necessary.
Specialization and generalization in relation to inheritance
We specialize when we move from a superclass to a subclass. We generalize when we move from a subclass to a superclass
Polymorphism, static polymorphism, and dynamic polymorphism?
Polymorhpism - a single thing can take on more than one form.
Static polymorphism - compile time, implemented in method overloading.
Dynamic polymorphism - based on inheritance and the substitution principle. This can include dynamic (or late) binding.
Deep copy and shallow copy
Deep copy is a clone. A shallow is an alias. Deep copy is equivilant and a shallow copy is identical
Sorting contract
Selection sort - definition, or idea behind it
Named selection sort because we select the largest item in the unsorted part of the array and move it to the front of the sorted part. Invariant : Everything in the sorted part is greater than everything in the unsorted part
What is the time complexity of selection sort?
n^2
Insertion sort - definition, or idea behind it
we take the first element of the unsorted part and look through the sorted part to find the position where this new element is to be inserted, such that the sorted part remain sorted.
Insertion sort, time complexity
n^2
Stages of software, the irony behind it
Design
implementation
component testing
release
maintenance
Initially it was though that, for large projects, design and implementation would take the longest and be the most expensive, but it turns out that maintenance of the code is the most expensive.
Single responsibilty principle
Each things should do one thing and do it well. It states that every object should have a single responsibility, and that all its services should be narrowly aligned with that responsibility. The principle forms part of cohesion, a concept widely used in software development.
Dependency inversion
rely on abstraction, not implementation
Early binding, late binding, pros of each
Early Binding, is done at compile time.
Pros: Simple.
Fast.

Late binding, done at execution times.
Pros: Flexible.
For each loops
how the fuck do these work?
Apparent type and actual type, definitinons and for z.draw()
apparent type is the type at compile time. Actual type is the type at build.

for them to be different,apparent type must be an interface or superclass.
At early binding, z is a shape, so the apparent type is shape. At late binding, z is either a square/rectangle/circle/star, so the actual type is one of these things.
Big Oh of F(n) when F(n) = n^4 + 2^n + log(n)
O(2^N)
Describe the difference between a recursive and iterative function
An iterative function uses looping and works through the method only once. A recursive function calls itself in the body of the function, and works on a smaller set of data with each call of the function. Creates a new instance in the activation record with each call
What are the two main parts of a recursive algorithm?
The base case and the recursive case.
What is a recursive definition?
Is one in which the thing being defined is part of the definition.
Questions to ask when choosing a java collection
Are duplicates allowed? If not, then choose set.
Do the elements need to be kept in a fixed, stable order? If so, use a list.
Do the elements need to be accessed by a general key? Then use a map.
Elements accessed by an int (index)? Then use a list
Or by it's value? Then use a set or collection.
What is the effect of applying indirection?
It reduces coupling. Also allows for fewer duplicate copies by adding link nodes.
What are the naming conventions for the following:

Class, Method or data member, Constant Data Member, local variable, package
Class: Timer
Method: ensureCapacity
Consant MAX_CARDS
Local Variable: count or houseNumber
Package: all lowercase
Stack memory and heap memory
Stack memory only contains the activation records, and local variables (these are contained within the activation record). Heap Memory contains the objects used by member functions.
What is in the activation record?
The parameters, local variables, etc, that define the member function
What is a loop invariant?
A loop invariant is a condition that is necessarily true immediately before and immediately after each iteration of a loop
What is the operation time for get in a binary search tree?
O(log n)
What is the operation time for set in a binary search tree?
σ(log n)
What is the operation time for insert in a binary search tree?
σ(log n)
What is the operation time for delete in a binary search tree?
σ(log n)
What is a binary search tree?
A binary search tree is a binary tree whose elements are ordered such that for any node in the tree, all elements to the left are less than the node and all elements to the right are greater than the node.
The left and right subtrees are also binary search trees.
Describe insertion sort.
The element at the end of the unsorted list is picked and puts it in the right spot in the sorted portion.
Describe selection sort.
Picks the largest value in the unsorted list and puts it at the beginning of the sorted portion.
What is the operation time for get in an array?
O(1)
What is the operation time for set() in an array?
O(1)
What is the operation time for insert in an array?
O(n)
What is the operation time for delete in an array.
O(n)
What is the operation time for get in a linked list or linked set?
O(n)
What is the operation time for set() in a linked list or linked set?
O(n)
What is the operation time for insert in a linked list or linked set?
O(1)
What is the operation time for delete() in a linked list or linked set?
O(1)
What is a tree?
A tree is a hierarchical structure consisting of a collection of nodes, one of which is the root. All nodes, except for the root, have a single predecesssor called the parent, and zero or more children
On a tree, what is a node with no children called?
A leaf or external node
In a tree, what nodes with common parents are called:
Siblings
In a tree, what is the degree of a node?
The number of children that it has
In a tree, what is the degree of the tree?
Also called it's arity, it is the largest degree of all it's nodes.
In a tree, what is a path and path length?
A path is a sequence of unique, connected nodes. The path length is the number of nodes it contains. The depth of a node in a tree is the length of the path from the tree's root to the node.
In a tree, what is the height of a node?
The length of the longest path from the node to a leaf descendant.
What are the three binary tree traversals and how to they work?
Preorder: If a node is not null, then it visits the node. The it recursively calls the function on the node's left child. Then it recursively calls the method on the node's right child

InOrder: If the node is not null, then the method is called recursively on the node's left child. Then it visit's the node. Then it recursively calls the method on the node's right child.

Postorder: If the node is not null, then it recursively calls the method on the node's left child. Then it recursively calls the method on the node's right child. Then it visits the node
What is the invariant of a balanced BST?
The height difference between a left and right node can only be 1.
What is the implementation of a recursive height function for a Binary Search Tree?
int heightRec (BSTNode node) {
return 1 + max (heightRec(node.getLeft()), heightRec(node.getRight());
}