Question
Problem 1. (15 points) (1) What is time complexity of fun()? int fun(int n) { int count = 0; for (int i = n; i
Problem 1. (15 points)
(1) What is time complexity of fun()? int fun(int n) { int count = 0; for (int i = n; i > 0; i /= 2) for (int j = 0; j < i; j++) for (int k=1; k count += 1; return count; } (A) O (n) (B) O (n^2) (C) O (n^3) (D) O (2n) |
(2) Given that there are n elements in a one-dimensional array, the average time complexity of reading the i-th array element is () (A) O (1) (B) O (n^2) (C) O (n) D) O (2n)
|
(3) Given that F(n) is a Fibonacci number, if F(0) =1, then the 9th numbers in the series is ( ) (A) 13 (B) 21 (C) 34 (D) 55
(4) The following sequences are used to construct a binary sorted tree, which is different from the results of the other three sequences () A. 100, 80, 90, 60, 120, 110, 130 B. 100, 120, 110, 130, 80, 60, 90
C. 100, 60, 80, 90, 120, 110, 130 D. 100, 80, 60, 90, 120, 130, 110
(5) The basic elements of the greedy algorithm is () A. Overlapping subproblems
B. Constructing optimal solutions
C. Locally optimal solutions
D. Greedy choice property
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started