Data Structures & AlgorithmsVery hardGATE CS · Codeforces Div2 B
What is the sum of floor(i / 2) for i = 1 to 10?
- A. 26
- B. 25
- C. 27
- D. 29
Correct answer: B. 25
Pairs of consecutive i share the same floor value, so the sum is 0 + 1 + 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 = 25.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- What is the smallest positive integer that has exactly 6 positive divisors?
- How many integers n in [1, 100] have both n and n + 2 prime?
- What is gcd(2^12 - 1, 2^8 - 1)?
- How many integers in [2, 20] are neither divisible by 2 nor by 3?
- How many division steps (modulo operations) does Euclid's algorithm perform on the pair (252, 105) before the remainder becomes 0?
- A binary search on the sorted array 1, 2, ..., 100 looks for 37 using mid = (lo + hi) // 2 with lo = 0 and hi = 99. How many comparisons…