1/88
Methods-Array, Sorting, Recursive SelSort
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Method parameters of primitive types like int, double, char, cannot be used to return results.
True
Method parameters of primitive types like int, double, char, can be used to return results.
False
Method parameters of immutable non-primitive types, like String, can be used to return results.
False
Method parameters of immutable non-primitive types, like String, cannot be used to return results.
True
Parameters of mutable non-primitive types, like arrays, cannot be used to return the parameter as result.
True
Parameters of mutable non-primitive types, like arrays, can be used to return the parameter as result.
False
Parameters of mutable non-primitive types can be used to return results as changes in parameter’s content.
True
Parameters of mutable non-primitive types cannot be used to return results as changes in parameter’s content.
False
The new operator allocates memory on the heap, a memory region that is NOT freed when exiting the method
True
The new operator allocates memory on the heap, a memory region that is freed when exiting the method
False
After a method terminates, the memory allocated to non-static local variables is de-allocated, since they are on the stack.
True
After a method terminates, the memory allocated to static and non-static local variables is de-allocated, since they are on the stack.
False
Static local variables and members are allocated in global memory, outside stack and heap, and are allocated during the whole program execution.
True
Sequential search is efficient if special knowledge of the problem instance confirm we are close to the best case.
True
Sequential search can be applied on non-sorted arrays.
True
Binary search can be applied on non-sorted arrays.
False
Arrays.equals() is the preferred way to check equality between arrays
True
System.arraycopy() is an optimized method to shallow-copy a range of items between two arrays of same type.
True
== on arrays only succeeds if an array is checked against itself, as only addresses are compared
True
Sequential search average case cost is generally worse that the worst case for binary search
True
Binary Search has a cost bounds given by O(log n), namely some_constant*log(n)
True
Binary Search has a cost bounds given by O(n), namely some_constant*n
False
A Java method may have at most one vararg parameter and it must be the last one.
True
Insert Sort has a best case cost bounds given by O(n), namely some_constant*(n)
True
getopt command line parameters supports parsing groups of one character options starting with a dash
True
== check on arrays only succeeds if an array is checked against itself, as only addresses are compared.
True
The row i of a 2D ragged array of integers can be emptied with row[i] = rew int[0]
True
Bubble Sort has a best case cost bounds given by O(n), namely some_constant*(n)
True
Recursive Fibonacci series are always implemented with two recursion calls in its body
False
charAt(0) is the first character of a string
True
The maximum number of dimensions that a Java array can have is theoretically unlimited (practically 225).
True
Variable declaration is the process of instructing the compiler on allocating space for a variable
True
Insert Sort has a worst case cost bounds given by O(n^2), namely some_constant*(n^2)
True
Bubble Sort has a worst case cost bounds given by O(n^2), namely some_constant*(n^2)
True
0< is used to redirect the standard input of a program from a file.
True
Bubble Sort can be implemented recursively
True
A for loop update section containing an “i++” behaves differently from one containing only a “++i”.
False
int[] A; A[0]=0; //does not create an array with the first element set to 0;
True
Insert Sort can be implemented recursively, in each recursion reducing the unsorted array by one value, which is added to the already sorted values.
True
equals() is a method used to test equality for class types
True
Bubble Sort best case is when the array is almost sorted already and only a few elements are before their sorted position in the array (in the direction of the bubbling).
True
The worst case costs of Insert Sort and Bubble Sort scale similarly with size, up to a constant ratio depending on machine
True
Unidirectional Bubble Sort best case is whenever the array is almost sorted already
False
The best case costs of Selection Sort, Insert Sort and Bubble Sort does scale similarly with size, up to some constant ratios that depend on machine and implementation.
False
Insert Sort best case is when the array is almost sorted already.
True
Recursion is a programming and mathematical tool
True
Recursive methods are always more efficient than equivalent non-recursive methods.
False
Recursive methods are not always more efficient than equivalent non-recursive methods.
True
In a recursive mathematical definition, any recursive reference(s) will NOT always be on a larger value (as eventually it has to reach the base case).
True
In a recursive mathematical definition, any recursive reference(s) will always be on a larger value (as eventually it has to reach the base case).
False
A stack frame (also known as a stack allocation record) is placed on the run-time stack whenever any method is called
True
A stack frame contains the values of static local variables and parameters
False
A stack frame contains the values of non-static local variables and parameters
True
A (correctly written) recursive Java method typically has at least one basis case
True
Tail recursion is when the recursion call is the last operation of a method
True
Recursion is used because it is easier for humans to think with it.
True
Recursion is not used because it is harder for humans to think with it.
False
Select Sort is inefficient because it does not exploit already sorted sequences
True
SelectionSort can be implemented recursively
True
Recursive Fibonacci series is NOT always implemented with two recursion calls in its body
True
Recursive Fibonacci series is always implemented with two recursion calls in its body
False
Binary Search has a cost bounds given by O(log n), namely some_constant*log(n)
True
substring is a method for finding the first occurrence of a text in another text
False
2> /dev/null is used to filter out error messages such that you see only successful output.
True
A conditional operator expression can be nested.
True
int[] a = {32, 16, 4, 91, 12}; // This both allocates the space for the array and initializes it on heap
True
Parameters of mutable non-primitive types can be used to return changes in content of parameter as result.
True
In a two-dimensional array A, the number of columns is given by A.length
False
In a two-dimensional array A, the number of rows is given by A.length
True
An int can be assigned to a double variable
True
An char can be assigned to an int variable
True
An int can be assigned to a char variable
True
A double can be assigned to an int variable
False
A double can be assigned to a char variable
False
A double can be assigned to a String variable
False
An int can be assigned to an String variable
False
A String can be assigned to an int variable
False
A String can be assigned to a double variable
False
A String cannot be assigned to a char variable
True
A char can be assigned to a String variable
False
A char can be assigned to a double variable
True
An int divided by a double is a double
True
The expression 9/2 is evaluated to 4.5
False
The % result can be a negative number
True
The % operation can be used for distributing numbers to buckets
True
The % operator can be used to test whether number x is even with (x%2=1)
False
The % operator can be used to test whether number x is odd with (x%2=1)
True
Operator = is left associative and returns the value assigned to the memory location on its right-hand side
False
Java is right-associative for most operators
False