Question: Need answers to these python scenarios. Don't need any code or anything. Thanks. Scenarios (a) (3 points) def search(L, target): # L is a list
Need answers to these python scenarios. Don't need any code or anything. Thanks.




Scenarios (a) (3 points) def search(L, target): # L is a list found = False i = 0 while i b: return 1 elif b> a: return -1 else: return 0 With regard to the function above: What is the size of the input"? What is its big-O time complexity? Very briefly justify your answer. == (d) (3 points) def is-prime (a): # a is an integer if a == == 1: return false elif a == 2 or a 3: return True result = True for i in range (2, a//2): if a % i == 0: result = False return True With regard to the function above: What is the size of the input"? What is its big-O time complexity? Very briefly justify your answer. (e) (3 points) def find_triples (L): # L is a list if len (L) == 0: return 0 L = sorted (L) triples = 0 repeats = 1 prev = L[0] for i in range (1, len(L)): cur = L[i] if cur != prev: repeats = 1 else: repeats += 1 if repeats == 3: triples += 1 prev = cur return triples With regard to the function above: What is the size of the input"? What is its big-O time complexity? Very briefly justify your answer. (f) (3 points) def interleave (L1, L2): # L1 and L2 are lists i = 0 result = [] while i len (L2): longer = 11 else: longer = L2 for j in range (i, len(longer)): result.append(longer[j]) return result With regard to the function above: . What is the 'size of the input"? What is its big-O time complexity? Very briefly justify your answer. (g) (3 points) Consider a single elimination chess tournament. A single elimination format means that as soon as a player loses a single game, they are out of the tournament. Players who win their games keep playing until only a single undefeated player remains. For example, if we had a tournament with 4 players (Godzilla, Mothra, Gigan and Ghidorah), we would need a total of 3 matches to complete the tournament as follows: Match A: Godzilla vs Mothra Match B: Gigan vs Ghidorah Match C: Winner of A vs Winner of B Let time be measured in terms of the number of games needed to complete the tournament. What is the big-o notation for the time needed to complete a single elimination tournament with N players? Briefly justify your answer. (h) (3 points) Consider a round-robin chess tournament. A round-robin format means that every player must play each other player exactly once. For example, if we had a tournament with 4 players (Godzilla, Mothra, Gigan and Ghidorah), we would need a total of 6 matches to complete the tournament as follows: . Godzilla vs Mothra Godzilla vs Gigan Godzilla vs Ghidorah Mothra vs Gigan Mothra vs Ghidorah Gigan vs Ghidorah Let time be measured in terms of the number of games needed to complete the tournament. What is the big-O notation for the time needed to complete a round-robin tournament with N players? Briefly justify your
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
