1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Yuliya22 [10]
2 years ago
6

How do we find the time complexity for this algorithm?

Computers and Technology
1 answer:
gizmo_the_mogwai [7]2 years ago
8 0

Answer:

For any loop, we find out the runtime of the block inside them and multiply it by the number of times the program will repeat the loop. All loops that grow proportionally to the input size have a linear time complexity O(n) . If you loop through only half of the array, that's still O(n) .

You might be interested in
Create a program with a script that calls the following functions: getinput, calculateGPA, createBor, and printResults. The prog
Licemer1 [7]

Answer:

The script is given below

Explanation:

%%driver

[grades , num_semester ] = getInput( ) ;

gpa = calculateGPA(grades , num_semester) ;

printResult( gpa) ;

createBar( num_semester , grades ) ;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [grades , no_semester] = getInput()

no_semester = input("How many semesters in college " );

for i = 1: no_semester

grades(i) = input( " Enter semester GPA ") ;

if( grades(i) > 4 && grades(i) < 0 )

disp( " Entered Grades are out Of Bounds ") ;

end

 

end

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function GPGA = calculateGPA(grades , no_semester )

sum = 0 ;

for i = 1 : no_semester

 

sum = sum + grades(i) ;

 

end

 

GPGA = sum/( no_semester);

 

 

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function bargraph = createBar( semester_num , grades )

 

bargraph = bar( grades, semester_num) ;

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function f = printResult( gpga )

 

fprintf( " Your GPGA is : %d \n " , gpga);

 

if( gpga >= 3 && gpga <=4 )

fprintf( " exception good work ") ;

 

end

if( gpga >= 2 && gpga <= 3)

fprintf( " You are average " ) ;

end

if( gpga >= 1 && gpga <= 2 )

fprintf( " you FAIL" ) ;

end

end

8 0
3 years ago
Which sequence represents the hierarchy of terms, from smallest to greatest?
Anni [7]

Answer:

b

Explanation:

7 0
3 years ago
How to run angular project from github.
sergiy2304 [10]

Answer:

i have no ideaaaaaaaaaaaaaaaaaaaaaa

Explanation:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa kill me

6 0
3 years ago
Revenue xls en excel
igor_vitrenko [27]
Whast does this mean

5 0
3 years ago
What is one advantage of using object-oriented programming?
maxonik [38]
That answer would be B hope it helps
6 0
3 years ago
Read 2 more answers
Other questions:
  • Why is it that even though there aren't the max number of answers on a question, (or sometimes even NO answers) When I click the
    11·1 answer
  • Sarah is working on a project in which she needs to record all the extracurricular activities in her college. Her college teache
    5·1 answer
  • Which of the following provides astronomical evidence for the age of the earth?
    11·1 answer
  • Explain how touch-tone dialing sends digits to the switch and write the name given to define touch-tone dialing.
    10·1 answer
  • Which item is most important for a successful website design?
    6·2 answers
  • A web application is an example of:
    7·1 answer
  • WILL GIVE BRAINLIEST ANSWER!!!<br><br> How do you manage your screen time?
    8·2 answers
  • The way a student prepares for a test or reviews academic material is referred to as
    8·2 answers
  • What are two benefits of defining a function?
    14·1 answer
  • 8. Choose the 3 correct statements for the code below.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!