Menu

[solved]-Worst Case Average Case Complexity Respectively Following Code Rand K Generates Random Num Q39069779

What are the worst case and average case complexity, respectively, of the following code? (rand() % k generates a random nu

What are the worst case and average case complexity, respectively, of the following code? (“rand() % k” generates a random number in the range 0..k-1 and runs in O(1) time). vector<int> loadVector(int n) vector<int> v; while (rando % n != 0) v.push_back(v.size()); return v; Worst: O(n), average: O(n) worst: O(n), average: O(n) worst: O(n2), average: O(n) worst: O(n2), average: O(n2) worst: O(n), average: 0(1) None of the above Show transcribed image text What are the worst case and average case complexity, respectively, of the following code? (“rand() % k” generates a random number in the range 0..k-1 and runs in O(1) time). vector loadVector(int n) vector v; while (rando % n != 0) v.push_back(v.size()); return v; Worst: O(n), average: O(n) worst: O(n), average: O(n) worst: O(n2), average: O(n) worst: O(n2), average: O(n2) worst: O(n), average: 0(1) None of the above

Expert Answer


Answer to What are the worst case and average case complexity, respectively, of the following code? (“rand() % k” generates a rand… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *