Database-Management-System
July 30, 2024
GATE 2023
July 30, 2024
Database-Management-System
July 30, 2024
GATE 2023
July 30, 2024

GATE 2006

Question 15

Consider the following C-program fragment in which i, j and n are integer variables.

 for (i = n, j = 0; i >0; i /= 2, j += i);  

Let val(j) denote the value stored in the variable j after termination of the for loop. Which one of the following is true?

A
val(j) = θ(logn)
B
val(j) = θ(√n)
C
val(j) = θ(n)
D
val(j) = θ(n logn)
Question 15 Explanation: 
The loop following series is n/2 + n/4 + n/8 + … + 1 = Θ(n).
Correct Answer: C
Question 15 Explanation: 
The loop following series is n/2 + n/4 + n/8 + … + 1 = Θ(n).
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!