Data Structures & AlgorithmsHardGATE CS · ICPC regional
What is 2^100 mod 9?
- A. 7
- B. 8
- C. 9
- D. 11
Correct answer: A. 7
The powers of 2 mod 9 repeat with period 6, and 100 mod 6 = 4, so 2^100 is congruent to 2^4 = 16, which is 7 modulo 9.
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 12-hour clock shows 1:30 p.m. Ignoring seconds, what hour (1 to 12) is shown 500 minutes later?
- Starting at x = 1, repeatedly apply x -> 3x mod 11. How many steps are needed to return to 1?
- 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?