Final Flashcards

(42 cards)

1
Q

O(1)

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

O(log2n)

A

Called logarithmic time

Used with algorithms that can cut the amount of data to be processed in half

Binary Search would be O(log2N)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

O(N)

A

Called linear time

Adding together the elements of an array is O(N)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

O(N log2N)

A

Called N log N time

Quick sort, Heapsort, merge sort have N log N complexity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

O(N2)

A

Called quadratic time

Some simple sorting algorithms are O(N2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

O(2N)

A

Called exponential time

Are extremely costly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

T or F

LLObjectNode class is a self referential class

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When comparing two objects using the equals method inherited from the Object class, the contents of the objects are being compared

T or F

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

JDK has always contained the Java Collections Framework

T/F

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Stack is FIFO

T/F

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

We allow duplicate elements in our lists

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Final variable

A

Holds a value that cannot be changed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which sequence of operations leaves a stack unchanged?

A

Push and then pop

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The stackunderflowexception could be thrown by which stack methods?

A

Pop and top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The stackoverflowexception can be thrown by

A

The push method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

One method calls another method which calls another method, the activation records are stored in

A

A stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Unchecked exceptions are directly derived from

A

Runtime Exception

18
Q

Which method of the Object class returns a string representing some of the internal system implementation details of the object

A

The toString method

19
Q

Elements of an enum are….

A

Uppercase and constant

20
Q

Pop operation

A

Removes top element of a stack

21
Q

Push operation

A

Adds an element to the top of a stack

22
Q

Java implicitly supplies a reference to each instance. This reference is called…

23
Q

Why does the pop operation from the stack class require no parameters

A

It takes the parameter of the value that was push

24
Q

Difference between checked and unchecked exceptions….

A

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

25
What does O(1) indicate?...
The time taken is constant and not based on the size of the input to the function
26
T/F An iterator allows traversal in both directions
False
27
T/F The equals method belongs to the comparable interface
True
28
Unchecked exceptions are directly derived from which class?
Runtime exception
29
Objects of the Java.lang.String type are________
Constant
30
The natural ordering of a class is defined by which method?
CompareTo
31
Which package does the Java Collections Framework reside in?
Java.util
32
Which method is used to add an element to a queue
The enqueue method
33
The binary search algorithm has a Big-O of .....
O(log N)
34
Which interface is used to traverse a list in both directions....
Listiterator
35
Fully qualified class name containing method toString() and equals()
Java.lang.object
36
If equals method returns "true" compareTo method should return
A 0
37
Programming to the interface
Use abstract methods and be able to set values and overwrite values later
38
What is the Big-O of a search algorithm for an unordered list?...
O(N)?
39
What class would you use when manufacturing a string in a method such as toString()?...
....
40
What is the big-o for insertion
O(1)
41
Natural ordering
Ordering provided by the comparable interface Implement comparable interface Override compareTo method
42
Total ordering
Implement comparator minterface Use compare method