Home /
Expert Answers /
Computer Science /
select-the-matching-big-o-efficiency-for-each-of-these-code-snippets-for-i-in-range-n-f-pa510
(Solved):
Select the matching Big-O efficiency for each of these code snippets: for i in range \( (n) \) : f ...
Select the matching Big-O efficiency for each of these code snippets: for i in range \( (n) \) : for \( j \) in range \( (n) \) : \( \cdots \) for \( k \) in range \( (n) \) : ifor i in range \( (n) \) : for \( j \) in range(i, \( n) \) : \( \ldots \) \( \ldots \) \( \ldots \) \( \ldots \) 1. \( \mathrm{O}(1) \) for i in range \( (n) \) : for \( j \) in range \( (n) \) : 2. \( \bigcirc(\log n) \) for i in range \( (n) \) : 3. \( \mathrm{O}(\mathrm{n}) \)
5. \( O\left(n^{2}\right) \)
ANSWER : 1. a. In the given example there is two for loops mention. They both run differently then their Big-O efficiency is O(n). b. In example there is while loop used in that they also run code till length of input. Then It is Big-O efficiency is