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;
78 Cards in this Set
- Front
- Back
How many comparisons will the linear search algorithm make if the search key is not in an array of 10 elements?
|
10
|
|
Which of the following is not a name for a big O run time?
|
Variable run time.
|
|
What is the efficiency of linear search?
|
O(n)
|
|
What is the maximum number of comparisons required to find a search key in a sorted 31-element array?
|
5 |
|
Which of the following is a negative of binary search?
|
The data must be in sorted order.
|
|
What is the term used for binary search’s run time?
|
Logarithmic run time.
|
|
What does the first pass of selection sort do?
|
Locates the smallest element in the array and swaps it into the zeroth position.
|
|
What does each iteration of the insertion sort algorithm do?
|
Each iteration takes the next element in the unsorted portion of the array and inserts it into the sorted portion.
|
|
How much faster is insertion sort with a 15-element array than with a 60-element array?
|
19 times
|
|
What is the base case for the recursive merge sort algorithm?
|
A one-element array
|
|
Which of the following sorting algorithms is the fastest?
|
Merge sort
|
|
When a recursive method is called to solve a problem, the method actually is capable of solving only the simplest case(s), or ___________
|
base case(s).
|
|
When the recursion step executes:
|
the original call to the method is still active.
|
|
Which of the following statements about recursion are true?
|
Recursion uses a termination test.
Recursion can occur infinitely. |
|
The recursion step should:
|
call a fresh copy of the recursive method to work on a smaller problem.
|
|
Which of the following is false?
|
The value 1 can be implicitly converted to a BigInteger.
|
|
The number of calls to recursively calculate the Fibonacci value of 7 is
|
41
|
|
The operands of an operator are evaluated ________
|
from left to right.
|
|
The current method executing is always the method whose activation record is ________
|
at the top of the stack
|
|
Recursion is often less efficient than iteration because ________
|
it can cause an explosion of method calls.
|
|
All of the following are true for both recursion and iteration except ________
|
they have a base case.
|
|
Recursion often is preferable to iteration because ________.
|
it models the problem more logically.
|
|
Fractals that yield an exact copy of the original when a portion of the original image is magnified are called _______ fractals.
|
strictly self-similar.
|
|
Each time a fractal’s pattern is applied to it, the fractal is said to be at a new ________.
|
order.
|
|
After a fractal’s pattern is applied several times, the shape of the fractal will generally become ________.
|
stabilized and more detailed.
|
|
In recursive backtracking, if one set of recursive calls does not result in a solution to the problem, what happens?
|
The program returns to a previous decision point and makes a different decision.
|
|
The basic generic functional interface ________ in package java.util.function contains method get that takes no arguments and returns a value of type T
|
UnaryOperator
|
|
By default, method sorted uses ________.
|
the natural order for the stream's element type
|
|
Interface Stream (package java.util.stream) is a generic interface for performing stream operations on objects. The types of objects that are processed are determined by the Stream’s ________.
|
source
|
|
The basic generic functional interface ________ in package java.util.function contains method apply that takes a T argument and returns a value of type R. Calls a method on the T argument and returns that method’s result.
|
Function
|
|
Terminal operations are eager; they perform the requested operation when they are called.
|
eager
|
|
You can declare that an interface is a functional interface by preceding it with the @FunctionalInterface annotation. The compiler will then ensure that the interface contains ________; otherwise, it’ll generate a compilation error.
|
only one abstract method
|
|
Stream method ________ eliminates duplicate objects in a stream.
|
different
|
|
The basic generic functional interface ________ in package java.util.function contains method apply that takes two T arguments, performs an operation on them (such as a calculation) and returns a value of type T.
|
BinaryOperator
|
|
________ is a method reference for an instance method that should be called on a specific object. It creates a one-parameter lambda that invokes the instance method on the specified object—passing the lambda’s argument to the instance method—and returns the method’s result.
|
System.out::println
|
|
An ________ (package java.util.stream) is a specialized stream for manipulating int values.
|
IntStream
|
|
The intermediate Stream operation ________ results in a stream containing only the unique elements.
|
distinct
|
|
Interface Stream (package java.util.stream) is a generic interface for performing stream operations on objects. The types of objects that are processed are determined by the Stream’s ________.
|
source
|
|
________ is a method reference for an instance method of a class. It creates a one-parameter lambda that invokes the instance method on the lambda’s argument and returns the method’s result.
|
String::toUpperCase
|
|
Class Array’s ________ method is used to create a Stream from an array of objects.
|
stream
|
|
________ is a constructor reference. It creates a lambda that invokes the no-argument constructor of the specified class to create and initialize a new object of that class
|
TreeMap::new
|
|
The classes and interfaces which comprise the collections framework are members of package ________
|
java.util.
|
|
A(n) __________ allows a program to walk through the collection and remove elements from the collection.
|
Iterator
|
|
Interface Collection contains __________ operations (i.e., operations performed on the entire collection)
|
bulk
|
|
Iterator method __________ determines whether the Collection contains more elements
|
hasNext
|
|
Java SE 7 supports type inferencing with the <> notation in statements that declare and create generic type variables and objects. For example, the following lineList< String > list = new ArrayList< String >();can be written as:
|
List< String > list = new ArrayList<>();
|
|
LinkedList method listIterator returns a(n) __________.
|
bidirectional iterator.
|
|
The collections framework algorithms are __________, i.e., each of these algorithms can operate on objects that offer given interfaces without concern to the underlying implementations
|
polymorphic
|
|
Collections method sort that accepts a List as an argument sorts the elements of a List, which must implement the __________ interface.
|
Comparable
|
|
Collections method ___________ returns a Comparator object that orders the collection's elements in reverse order.
|
reverseOrder.
|
|
Comparator method compare should return ________ if the first argument is greater than the second argument.
|
a positive int value.
|
|
Algorithm __________ randomly orders a List's elements
|
shuffle.
|
|
Method shuffle is a member of __________
|
class Collections.
|
|
Class Collections provides algorithms for reversing, filling and copying ________.
|
Lists
|
|
To find the smallest and largest element of a Collection, use Collections methods _________ and __________.
|
least, greatest.
|
|
If the desired Object is not found, binarySearch returns __________.
|
a negative value
|
|
Collections method __________ returns true if two Collections have no elements in common.
|
disjoint
|
|
Stack method __________ looks at the top element of a stack without removing that element
|
peek
|
|
If no elements are in the Stack, method pop throws an __________
|
EmptyStackException.
|
|
PriorityQueue method __________ inserts an element at the appropriate location in the queue.
|
offer
|
|
__________ methods enable a program to view a portion of a collection.
|
Range-view.
|
|
Maps allocate keys to values and cannot contain duplicate keys, i.e., the key-to-value mapping is a __________ mapping.
|
one-to-one.
|
|
Which statement about hashing is false?
|
A load factor of 1.0 usually results in good hashing performance, but less efficient utilization of memory.
|
|
Map method ________ is used to determine whether a map contains a mapping for the specified key.
|
containsKey.
|
|
A Properties object is a __________ Hashtable object.
|
persistent
|
|
Most objects in Java can now be output and input with Java's object __________
|
Serialization.
|
|
The collections framework provides various __________ collection interfaces from which the programmer can quickly "flesh out" complete customized implementations.
|
abstract.
|
|
Which of the following is not an abstract implementation provided by the collections framework?
|
AbstractTree.
|
|
Relative paths normally start from which directory?
|
The directory in which the application began executing
|
|
How do methods setIn, setOut and setErr affect the standard input, output and error streams?
|
They redirect the standard input, output and error streams.
|
|
Which of the following is arranged in increasing size order?
|
bit, field, record, file.
|
|
What does the following statement do? Scanner scanner = new Scanner( new File( "test.txt" ) );
|
Opens a text file for input.
|
|
Records in a sequential file are not usually updated in place. Instead:
|
the entire file is usually rewritten.
|
|
A serialized object is:
|
an object represented as a sequence of bytes used to store the object’s data in a file.
|
|
Which JFileChooser method returns the file the user selected.
|
getSelectedFile
|
|
Instance variables that are not to be output with a Serializable object are declared using which keyword?
|
transient
|
|
Relative paths normally start from which directory?
|
The directory in which the application began executing.
|
|
What does the following statement do? Scanner scanner = new Scanner( new File( "test.txt" ) );
|
Opens a text file for input.
|