Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
Starting at x = 1, repeatedly apply x -> 3x mod 11. How many steps are needed to return to 1?
- A. 6
- B. 7
- C. 5
- D. 9
Correct answer: C. 5
The multiplicative order of 3 modulo 11 is 5 because 3^5 = 243 = 22 * 11 + 1.
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
- Starting from n = 100, repeat: if n is divisible by 3, divide it by 3; otherwise subtract 1. How many steps are needed to reach 1?
- Which structure finds the k-th largest element of a data stream after each insertion with O(log k) time per element and O(k) space?
- Which method checks in O(n) whether two strings are isomorphic (a one-to-one character mapping turns one into the other)?
- Which technique counts the inversions of an array of n distinct integers in O(n log n) time?
- How many contiguous subarrays of [2, 4, 6, 3, 9] have an odd sum?
- What is the length of the longest proper border of the string aabaaab (the longest proper prefix that is also a suffix)?