Write the worst-case complexity of each of the following sort method Bubble sort
ID: 3885875 • Letter: W
Question
Write the worst-case complexity of each of the following sort method
Bubble sort
Short bubble sort
Insertion sort
Merge sort
What difference would it result if we use
DecimalFormat fmt = new DecimalFormat(“0.##”);
Instead of
DecimalFormat fmt = new DecimalFormat(“00”);
Write the piece of code for the function initValues(). The function should automatically initialize the values of an array with random integers from 0 to 99.
What is the type of contactList[num_entries].notes and contactList[i]
What is the best decalaration for the variable MAXIMUM_OCCPANCY
int MAXIMUM_OCCPANCY
final int MAXIMUM_OCCPANCY
static int MAXIMUM_OCCPANCY
static final int MAXIMUM_OCCPANCY.
Explanation / Answer
Write the worst-case complexity of each of the following sort method
Bubble sort - O(n^2)
Short bubble sort - O(n^2)
Insertion sort - O(n^2)
Merge sort - O(n log n)
---------------------------------------------------------------
DecimalFormat fmt = new DecimalFormat(“0.##”); - round the decimal places to 2 digits.
DecimalFormat fmt = new DecimalFormat(“00”); - it represents the integer values. it just remove omit the decimal places.
-----------------------------------------------------------------
Write the piece of code for the function initValues(). The function should automatically initialize the values of an array with random integers from 0 to 99.
Answer:
initvalues[i] = (int)(Math.random() * 100);
------------------------------------------------------------
What is the type of contactList[num_entries].notes and contactList[i] - vector
------------------------------------------------------------
int MAXIMUM_OCCPANCY - variable with integer data type
final int MAXIMUM_OCCPANCY - value doesnt change
static int MAXIMUM_OCCPANCY - the variable can be accessed directly inside class and in more than one method it can be used.
static final int MAXIMUM_OCCPANCY. - the variable can be used within the entire class
so, the worst case is final int MAXIMUM_OCCUPANCY
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.