A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

Discussion Forum

Que. Let A[1, ..., n] be an array storing a bit (1 or 0) at each location, and f(m) is a unction whose time complexity is θ(m). Consider the following program fragment written in a C like language:

counter = 0;
for (i = 1; i < = n; i++)
if (A[i] == 1)
else {
counter = 0;

The complexity of this program fragment is
a. Ω(n^2)
b. Ω(nlog n) and O(n^2)
c. θ(n)
d. O(n)
Confused About the Answer? Ask for Details Here
Know Explanation? Add it Here

Similar Questions: