Basics Flashcards
What three properties makes a program good?
- It works
- easy to modify
- reasonably efficient
What does an ADT stand for?
Abstract Data Type
What does an ADT separate?
Specification and implementation, which improves the reusability
What is specification in this context, and where does it lie?
“What kind of program we are looking at” & in the public external part
What is implementation in this context, and where does it lie?
“How the operations are performed” & in the private internal part
What does unboxing convert between?
Wrapper class(like Integer) to primitives(like int)
What does boxing convert between?
Primitives like double to wrapper class(Double)
What is an exception?
An event that occurs that disrupts flow of execution
What are the general steps of dealing with a potential in exception?
- )method causes exception
- )throws exception
- )handles exception
What are the steps of throwing?
method on call stack where error happens throws exception then can be handled or passed down the call stack for later handling
What types of methods forward the exception?
Ones without an exception handler
What two types of exception handlers are there?
- )try/catch/finally block
2. )throws @ method header with throw new exception object
What three types of exceptions are there?
- unchecked/runtime
- error
- checked
What is the difference between checked and unchecked exceptions?
unchecked are checked at runtime while checked are not
For a sub and super class, which direction is generalization happening?
creating a super class from a sub class is an example of generalization?
Changing a wrapper class to a generic type E is an example of what?
generalization
commenting improves what?
clarity and thus reusability
What is a data structure?
A way to organize data
when instantiating an object with a superclass what two ways are correct?
Subclass x = new Subclass() Superclass x = new Subclass(), if the method requires a variable of type superclass
What is the difference between a reference type and a primitive type?
a primitive type is Boolean, int, double.. and is the actual data, whereas a reference type is a pointer to a class or other piece of data
Out of the three basic data structures, arrays, lists and trees, which are dynamic?
arrays, since they can’t change in size
What is aliasing?
Two references that refer to the same piece of data
What is the difference between performance and complexity?
performance is how much actual space is being taken up, while complexity is how much space/time is taken as the problem size grows
What are basic operations and what are their complexities?
-arithmetic operations
-assignments
-writes
O(1)
What is the worst case complexity?
The largest complexity an algorithm can have
How is complexity expressed?
By big-O notation
What doesn’t affect big-O?
low order terms, scaling and constants
How is the exact complexity expressed?
T(N)
When is a function T(N), O(F(N))?
if for c and all values of N greater than n, T(N) <= c * F(N)
What is the average & best case complexity?
The usual complexity and the smallest that an algorithm can have, respectively
What two different searches are there for an array?
- ) binary search
2. ) sequential search
What is the time complexity of a sequential search?
O(N)
When an array is sorted what search improves the complexity?
binary search with a complexity of O(logN)