Final Flashcards

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…

A

This

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
Q

What does O(1) indicate?…

A

The time taken is constant and not based on the size of the input to the function

26
Q

T/F

An iterator allows traversal in both directions

A

False

27
Q

T/F

The equals method belongs to the comparable interface

A

True

28
Q

Unchecked exceptions are directly derived from which class?

A

Runtime exception

29
Q

Objects of the Java.lang.String type are________

A

Constant

30
Q

The natural ordering of a class is defined by which method?

A

CompareTo

31
Q

Which package does the Java Collections Framework reside in?

A

Java.util

32
Q

Which method is used to add an element to a queue

A

The enqueue method

33
Q

The binary search algorithm has a Big-O of …..

A

O(log N)

34
Q

Which interface is used to traverse a list in both directions….

A

Listiterator

35
Q

Fully qualified class name containing method toString() and equals()

A

Java.lang.object

36
Q

If equals method returns “true” compareTo method should return

A

A 0

37
Q

Programming to the interface

A

Use abstract methods and be able to set values and overwrite values later

38
Q

What is the Big-O of a search algorithm for an unordered list?…

A

O(N)?

39
Q

What class would you use when manufacturing a string in a method such as toString()?…

A

….

40
Q

What is the big-o for insertion

A

O(1)

41
Q

Natural ordering

A

Ordering provided by the comparable interface

Implement comparable interface

Override compareTo method

42
Q

Total ordering

A

Implement comparator minterface

Use compare method