Final

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/88

flashcard set

Earn XP

Description and Tags

Methods-Array, Sorting, Recursive SelSort

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

89 Terms

1
New cards

Method parameters of primitive types like int, double, char, cannot be used to return results.

True

2
New cards

Method parameters of primitive types like int, double, char, can be used to return results.

False

3
New cards

Method parameters of immutable non-primitive types, like String, can be used to return results.

False

4
New cards

Method parameters of immutable non-primitive types, like String, cannot be used to return results.

True

5
New cards

Parameters of mutable non-primitive types, like arrays, cannot be used to return the parameter as result.

True

6
New cards

Parameters of mutable non-primitive types, like arrays, can be used to return the parameter as result.

False

7
New cards

Parameters of mutable non-primitive types can be used to return results as changes in parameter’s content.

True

8
New cards

Parameters of mutable non-primitive types cannot be used to return results as changes in parameter’s content.

False

9
New cards

The new operator allocates memory on the heap, a memory region that is NOT freed when exiting the method

True

10
New cards

The new operator allocates memory on the heap, a memory region that is freed when exiting the method

False

11
New cards

After a method terminates, the memory allocated to non-static local variables is de-allocated, since they are on the stack.

True

12
New cards

After a method terminates, the memory allocated to static and non-static local variables is de-allocated, since they are on the stack.

False

13
New cards

Static local variables and members are allocated in global memory, outside stack and heap, and are allocated during the whole program execution.

True

14
New cards

Sequential search is efficient if special knowledge of the problem instance confirm we are close to the best case.

True

15
New cards

Sequential search can be applied on non-sorted arrays.

True

16
New cards

Binary search can be applied on non-sorted arrays.

False

17
New cards

Arrays.equals() is the preferred way to check equality between arrays

True

18
New cards

System.arraycopy() is an optimized method to shallow-copy a range of items between two arrays of same type.

True

19
New cards

== on arrays only succeeds if an array is checked against itself, as only addresses are compared

True

20
New cards

Sequential search average case cost is generally worse that the worst case for binary search

True

21
New cards

Binary Search has a cost bounds given by O(log n), namely some_constant*log(n)

True

22
New cards

Binary Search has a cost bounds given by O(n), namely some_constant*n

False

23
New cards

A Java method may have at most one vararg parameter and it must be the last one.

True

24
New cards

Insert Sort has a best case cost bounds given by O(n), namely some_constant*(n)

True

25
New cards

getopt command line parameters supports parsing groups of one character options starting with a dash

True

26
New cards

== check on arrays only succeeds if an array is checked against itself, as only addresses are compared.

True

27
New cards

The row i of a 2D ragged array of integers can be emptied with row[i] = rew int[0]

True

28
New cards

Bubble Sort has a best case cost bounds given by O(n), namely some_constant*(n)

True

29
New cards

Recursive Fibonacci series are always implemented with two recursion calls in its body

False

30
New cards

charAt(0) is the first character of a string

True

31
New cards

The maximum number of dimensions that a Java array can have is theoretically unlimited (practically 225).

True

32
New cards

Variable declaration is the process of instructing the compiler on allocating space for a variable

True

33
New cards

Insert Sort has a worst case cost bounds given by O(n^2), namely some_constant*(n^2)

True

34
New cards

Bubble Sort has a worst case cost bounds given by O(n^2), namely some_constant*(n^2)

True

35
New cards

0< is used to redirect the standard input of a program from a file.

True

36
New cards

Bubble Sort can be implemented recursively

True

37
New cards

A for loop update section containing an “i++” behaves differently from one containing only a “++i”.

False

38
New cards

int[] A; A[0]=0; //does not create an array with the first element set to 0;

True

39
New cards

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

40
New cards

equals() is a method used to test equality for class types

True

41
New cards

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

42
New cards

The worst case costs of Insert Sort and Bubble Sort scale similarly with size, up to a constant ratio depending on machine 

True

43
New cards

Unidirectional Bubble Sort best case is  whenever the array is almost sorted already

False

44
New cards

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

45
New cards

Insert Sort best case is when the array is almost sorted already.

True

46
New cards

Recursion is a programming and mathematical tool

True

47
New cards

Recursive methods are always more efficient than equivalent non-recursive methods.

False

48
New cards

Recursive methods are not always more efficient than equivalent non-recursive methods.

True

49
New cards

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

50
New cards

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

51
New cards

A stack frame (also known as a stack allocation record) is placed on the run-time stack whenever any method is called

True

52
New cards

A stack frame contains the values of static local variables and parameters

False

53
New cards

A stack frame contains the values of non-static local variables and parameters

True

54
New cards

A (correctly written) recursive Java method typically has at least one basis case

True

55
New cards

Tail recursion is when the recursion call is the last operation of a method

True

56
New cards

Recursion is used because it is easier for humans to think with it.

True

57
New cards

Recursion is not used because it is harder for humans to think with it.

False

58
New cards

Select Sort is inefficient because it does not exploit already sorted sequences

True

59
New cards

SelectionSort can be implemented recursively

True

60
New cards

Recursive Fibonacci series is NOT always implemented with two recursion calls in its body

True

61
New cards

Recursive Fibonacci series is always implemented with two recursion calls in its body 

False

62
New cards

Binary Search has a cost bounds given by O(log n), namely some_constant*log(n)

True

63
New cards

substring is a method for finding the first occurrence of a text in another text

False

64
New cards

2> /dev/null is used to filter out error messages such that you see only successful output.

True

65
New cards

A conditional operator expression can be nested.

True

66
New cards

int[] a = {32, 16, 4, 91, 12}; // This both allocates the space for the array and initializes it on heap

True

67
New cards

Parameters of mutable non-primitive types can be used to return changes in content of parameter as result.

True

68
New cards

In a two-dimensional array A, the number of columns is given by A.length

False

69
New cards

In a two-dimensional array A, the number of rows is given by A.length

True

70
New cards

An int can be assigned to a double variable

True

71
New cards

An char can be assigned to an int variable

True

72
New cards

An int can be assigned to a char variable

True

73
New cards

A double can be assigned to an int variable

False

74
New cards

A double can be assigned to a char variable

False

75
New cards

A double can be assigned to a String variable

False

76
New cards

An int can be assigned to an String variable

False

77
New cards

A String can be assigned to an int variable

False

78
New cards

A String can be assigned to a double variable

False

79
New cards

A String cannot be assigned to a char variable

True

80
New cards

A char can be assigned to a String variable

False

81
New cards

A char can be assigned to a double variable

True

82
New cards

An int divided by a double is a double

True

83
New cards

The expression 9/2 is evaluated to 4.5

False

84
New cards

The % result can be a negative number

True

85
New cards

The % operation can be used for distributing numbers to buckets

True

86
New cards

The % operator can be used to test whether number x is even with (x%2=1)

False

87
New cards

The % operator can be used to test whether number x is odd with (x%2=1)

True

88
New cards

Operator = is left associative and returns the value assigned to the memory location on its right-hand side

False

89
New cards

Java is right-associative for most operators

False