Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Estimate the big - O complexity for each of these algorithms, and justify your answer. To confirm your calculations, answers are provided at the end

Estimate the big-O complexity for each of these algorithms, and justify your answer.
To confirm your calculations, answers are provided at the end of the rubric. Your justification can be mathematical or written, formal or informal.
1)
for (int i =0; i <10; i++){
sum++;
}
Big-O Category
Justification (why did you pick the way you did?)
2)
String strVar =Hello;
Int length = strVar.length();
for (int j =0; j < length; j++){
System.out.println(strVar.charAt(j));
}
Big-O Category
Justification (why did you pick the way you did?)
3)
list : array of items
n : size of list
for (i =1; i < n; i++){
/* set current element as minimum*/
min = i
/* check the element to be minimum */
for (j = i+1; j < n; j++){
if list[j]< list[min] then
min = j;
}
/* swap the minimum element with the current element*/
if indexMin != i then
swap list[min] and list[i]
}
Big-O Category
Justification (why did you pick the way you did?)
4)
k=1;
while (k <20){
sum++;
avg++;
k++;
}
Big-O Category
Justification (why did you pick the way you did?)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Guidelines for Informative Speeches?

Answered: 1 week ago