题目
题目
单项选择题

Ms_1 Consider the recurrence relation for an algorithm \(T(n)\) given by: \[ T(n) = \begin{cases} \Theta(1) & \text{if } n = 0 \\T\left(\frac{n}{2}\right) + \Theta(1) & \text{otherwise}\end{cases}\] What is the run time for this recurrence relation ? The Master Theorem is provided below. Use it as you see fit:

选项
A.\( \Theta(n^2) \)
B.\( \Theta(\log n) \)
C.\( \Theta(n \log n) \)
D.\( \Theta(n) \)
查看解析

查看解析

标准答案
Please login to view
思路分析
To understand the running time, I’ll examine the given recurrence: T(n) = T(n/2) + Theta(1) with T(0) = Theta(1). First, identify the parameters for the Master Theorem: a = 1 (one recursive call), b = 2 (size halved), and f(n) = Theta(1). Compute the critical exponent: n^{log_b a} = n^{log_2 1} = n^{0}......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!