Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
How many division steps (modulo operations) does Euclid's algorithm perform on the pair (252, 105) before the remainder becomes 0?
- A. 4
- B. 5
- C. 3
- D. 7
Correct answer: C. 3
The remainders are 252 mod 105 = 42, 105 mod 42 = 21, 42 mod 21 = 0, so there are three modulo steps.
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
- 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…
- How many unordered index pairs i < j in the sorted array [1, 3, 4, 6, 8, 9, 11] satisfy a[i] + a[j] = 12?
- How many distinct non-empty substrings does the string aaaa have?
- An array has only positive integers and you need the longest contiguous subarray whose sum is at most K, with n up to 10^6. Which method…
- How many contiguous subarrays of [3, 1, 4, 1, 5, 9] have a prime sum?
- What is the minimum number of elements to delete from [4, 7, 2, 9, 5] so that the remaining sum is divisible by 3? (The empty remainder is…