Final Flashcards
O(1)
Called bounded time
Amount of work is not dependent on the size of the problem
Adding an item to an array has an order of O(1)
O(log2n)
Called logarithmic time
Used with algorithms that can cut the amount of data to be processed in half
Binary Search would be O(log2N)
O(N)
Called linear time
Adding together the elements of an array is O(N)
O(N log2N)
Called N log N time
Quick sort, Heapsort, merge sort have N log N complexity
O(N2)
Called quadratic time
Some simple sorting algorithms are O(N2)
O(2N)
Called exponential time
Are extremely costly
T or F
LLObjectNode class is a self referential class
True
When comparing two objects using the equals method inherited from the Object class, the contents of the objects are being compared
T or F
False
JDK has always contained the Java Collections Framework
T/F
False
Stack is FIFO
T/F
False
We allow duplicate elements in our lists
True
Final variable
Holds a value that cannot be changed
Which sequence of operations leaves a stack unchanged?
Push and then pop
The stackunderflowexception could be thrown by which stack methods?
Pop and top
The stackoverflowexception can be thrown by
The push method
One method calls another method which calls another method, the activation records are stored in
A stack
Unchecked exceptions are directly derived from
Runtime Exception
Which method of the Object class returns a string representing some of the internal system implementation details of the object
The toString method
Elements of an enum are….
Uppercase and constant
Pop operation
Removes top element of a stack
Push operation
Adds an element to the top of a stack
Java implicitly supplies a reference to each instance. This reference is called…
This
Why does the pop operation from the stack class require no parameters
It takes the parameter of the value that was push
Difference between checked and unchecked exceptions….
Unchecked:
References defects in the program
Errors in code
Subclass of runtime exception
Checked:
Invalid conditions in areas outside the immediate control of the program(user input, database problems)
Subclasses of Exception
What does O(1) indicate?…
The time taken is constant and not based on the size of the input to the function
T/F
An iterator allows traversal in both directions
False
T/F
The equals method belongs to the comparable interface
True
Unchecked exceptions are directly derived from which class?
Runtime exception
Objects of the Java.lang.String type are________
Constant
The natural ordering of a class is defined by which method?
CompareTo
Which package does the Java Collections Framework reside in?
Java.util
Which method is used to add an element to a queue
The enqueue method
The binary search algorithm has a Big-O of …..
O(log N)
Which interface is used to traverse a list in both directions….
Listiterator
Fully qualified class name containing method toString() and equals()
Java.lang.object
If equals method returns “true” compareTo method should return
A 0
Programming to the interface
Use abstract methods and be able to set values and overwrite values later
What is the Big-O of a search algorithm for an unordered list?…
O(N)?
What class would you use when manufacturing a string in a method such as toString()?…
….
What is the big-o for insertion
O(1)
Natural ordering
Ordering provided by the comparable interface
Implement comparable interface
Override compareTo method
Total ordering
Implement comparator minterface
Use compare method