MM

Quiz Methods & Arrays Preparation


Method parameters of primitive types like int, double, char, cannot be used to return results.
Method parameters of immutable non-primitive types, like String, cannot be used to return results.
Parameters of mutable non-primitive types, like arrays, cannot be used to return the parameter as result.
Parameters of mutable non-primitive types can be used to return results as changes in parameter’s content.
The new operator allocates memory on the heap, a memory region that is NOT freed when exiting the method

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

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

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

Sequential search can be applied on non-sorted arrays.

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

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

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

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

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