Final Flashcards
er one complete pass through the array the largest value in the array will end up in the _____element. (T!)
last
how many comparisons of values are made in one pass of a bubble sort? (T!)
number of comparisons is (array.length – 1)…one less than the number of elements. If there are 5 elements, we make (5-1) or 4 comparisons. (T!)
how many passes do you have to make in a bubble sort to completely sort an array of ‘n’ elements? (T!)
Number of passes to completely sort an array of ‘n’ elements is equal to ‘n-1’. (T!)
bigest problem with basic bubble sort :
it processes the same number of elements on each pass. (T!)
each pass results in one less element to look at during the next pass. (T!)
yes
Can a method call itself?
yes recursive
Characteristics of recursion(T!)
All problems/solutions involving recursion have the following characteristics:
1) One or more base cases (AKA stopping cases) are used to stop the method from making a recursive call.
2) For fibonacci, the two base cases are when n=1 or n=0…if n=1 we return 1, or if n = 0 we return a zero. In all other cases we call the method recursively.
3) Every recursive call reduces the original problem one step closer to the base case(s)
When a method that returns a value is called, it is placed on the memory area called _______ (T!)
the method call stack.
anu path string that begins with ______ or root prefix is known as an ABSOLUTE path (T!), i.e: “C:\Temp2\notes.txt”
a drive letter
Confessing using a throws clause will let your program compile properly, but it gives no protection if the exception is actually thrown. Your program will ____ . (T!)
crash
benefit of a class method…
YOU DO NOT HAVE TO CREATE AN OBJECT OF THE CLASS IN WHICH THE METHOD IS DEFINED IN ORDER TO CALL THE METHOD. (
ample of a class method we have recently used is the Math.random() method for generating random numbers.
To call this method, we use the ClassName.methodName() syntax (T!)
a offers a shortcut way to declare, create and populate an array all at once by enclosing the data values inside curly braces. (T!)
ng [ ] monthsArray = {“Jan”,”Feb”,”Mar”,”Apr”,”May”,”Jun”,”Jul”,”Aug”,”Sep”,”Oct”, ”Nov”,”Dec”}
ArrayList is not restricted to holding values of just one data type like an array.
t is heterogeneous, because it holds the references to the memory addresses of objects rather than the objects themselves. (T!)