Question

PYTHON: Im stuck here, big O notation and runtime. What is it and Why are they those? Please look at the pic, need help as Im confused. Thank You!def method3(n): for i in range(n): for j in range(100): for k in range(n): print(i+j+k) What is the runtime (tightest/closest

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

Ans: O(100 *n2)

1 2 def method3(n): for i in range(n): # here this will run n times for j in range (100): # here this will run exactly 100

2.

Ans: O(n2/2)

1 def method4(n): 2 for i in range(n): # this will execute n times 3 for j in range(n,0,-2): # this will execute n/2 time

Add a comment
Know the answer?
Add Answer to:
PYTHON: Im stuck here, big O notation and runtime. What is it and Why are they...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON this implementation is really hard, Im stuck especially with the requirements they give. PLEASE HELP!...

    PYTHON this implementation is really hard, Im stuck especially with the requirements they give. PLEASE HELP! THANK YOU! RECURSIVE! Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define...

  • PYTHON please help! im stuck on this homework question, THANK YOU! please follow the rules! Give...

    PYTHON please help! im stuck on this homework question, THANK YOU! please follow the rules! Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define new functions or helper...

  • PYTHON Im kinda stuck here for this question, could use some help! Python please, and please...

    PYTHON Im kinda stuck here for this question, could use some help! Python please, and please follow the requirements. 09 5 Points Al and Bob are arguing about their algorithurs. Al claims his Oinlogn time method is always faster than Bob's O(n^2)-time method. To settle the issue they perform a set of experiments. To Al's dismay, they find that if n < 100 the On/2)-time algorithm runs faster and only when na 100. O(nlog n)-time one runs faster. Explain how...

  • What is the runtime of each method? Give answer in Θ(big Theta) notation as a function...

    What is the runtime of each method? Give answer in Θ(big Theta) notation as a function of n, give a brief explanation. A. public static int method1(int n){ int mid = n/2; for (int i = mid; i >= 0; i--) System.out.println(i); for (int i = mid + 1; i <= n; i++) System.out.println(i); return mid; } B. public static int method2(int n){ for (int i = n; i >= 0; i / 3){ System.out.println(i ); } return mid; }...

  • PYTHON I need help with this Python problem, please follow all the rules! Please help! THANK...

    PYTHON I need help with this Python problem, please follow all the rules! Please help! THANK YOU! Bonus Question Implement an efficient algorithm (Python code) for finding the 11th largest element in a list of size n. Assume that n will be greater than 11. det find 11th largest numberlissy Given, lissy, a list of n integers, the above function will return the 11th largest integer from lissy You can assume that length of lissy will be greater than 11....

  • Python 3 5. (16 points) Determine the big-O running time of each of the following functions:...

    Python 3 5. (16 points) Determine the big-O running time of each of the following functions: def pi (a) for i in range(len (a)): print (a[i]) for i in range(len(a)): print (ali]) def p2(a): for i in rangeClen(a)): for j in a: print (ati].j) def p3(a): for i in a: for j in a: print (i,j) def p4(a): for i in range(len(a)): pi(a) def p5(a): for i in range(len(a)): p3 (a) def p6(a): for i in range(len(a)): p5(a) def p7...

  • Determine the runtime complexity of the following. Use O() notation, but the function that you place within the parenthe...

    Determine the runtime complexity of the following. Use O() notation, but the function that you place within the parentheses of O() should be the upper bound on the runtime of the algorithm or function. Unless otherwise specified, N is the problem size or the number of elements in the container (even if N does not appear in the code or algorithm you are given), and all other values are constants. For graphs, use |V| and |E| for the size of...

  • PYTHON Im stuck, this is one line of code but I just cant remember it... Please...

    PYTHON Im stuck, this is one line of code but I just cant remember it... Please Help! Thank YOU! LIST COMPREHENSION Create a python list, that stores exactly [0,'hi', 2, thi', 4, thi', 6, 'hi', 8, thi') using python list comprehension. You can write one line of python code directly below (in the text box) or you can upload a python file having only one line of code. Write your solution (one line of python code) here. Enter your answer...

  • ## python oop creating a large number of instances ## im trying to create a large...

    ## python oop creating a large number of instances ## im trying to create a large number of instances for a class. could you show me a way to make it work import math import random class soldiers: def __init__(self,x,y): self.x = x self.y = y def get_target(self,x,y,number_red_soldiers,number_blue_soldiers): pass # self.target = def aiming_angle(self,x,y,target,enemy_x,enemy_y): dy = self.y-enemy_y[target] dx = self.x-enemy_x[target] angle =math.atan(dy/dx) a = 0 number_blue_soldiers= 10 number_red_soldiers = 10 for i in range(number_blue_soldiers): blue_x = random.randint(0,100,10) blue_y = random.randint(0,100,10)...

  • PYTHON Stuck with this problem with these implementation requirements. PLEASE HELP! THANK YOU! PYTHON Q7 16...

    PYTHON Stuck with this problem with these implementation requirements. PLEASE HELP! THANK YOU! PYTHON Q7 16 Points Give a python implementation of the following function: def without_Vowels(listi): The above function gets a list of positive integers and English letters, list1. When called, it should remove all the vowels from list1, and keep only the consonants and integers. The Order of the remaining consonants and integers does not matter. For example, if list1 = ['a', 'b', 5, 'c', 'o', 2, 'e',...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT