Sunday, June 14, 2026
HomeData Modelling & AIAlgorithms Quiz | SP Contest 1 | Question 1

Algorithms Quiz | SP Contest 1 | Question 1

How many times is the below loop executed?




for(int i=0; i < n; i++)
{
   for(int j=0; j < (2*i); j+=(i/2))
   {
   cout<<"Hello Geeks";
   }
}


(A) O(n)
(B) Infinite times
(C) O(n2)
(D) O(nlogn)

Answer: (B)
Explanation: At the second iteration of the outer loop, i.e. when i = 1, the inner loop will become an infinite loop as the increment condition is j = j+(i/2) and for i = 1, i/2 = 0.
Quiz of this Question

Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you’re new to coding. Start today and join millions on a journey to improve your skills!Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Commit to GfG’s Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.

Last Updated :
11 Jul, 2018
Like Article
Save Article


Previous

<!–

8 Min Read | Java

–>


Next


<!–

8 Min Read | Java

–>

Share your thoughts in the comments

RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS