9,207 views
51 votes
51 votes

Exponentiation is a heavily used operation in public key cryptography. Which of the following options is the tightest upper bound on the number of multiplications required to compute $b^n \bmod{m}, 0 \leq b, n \leq m$ ?

  1. $O(\log n)$
  2. $O(\sqrt n)$
  3. $O\Biggl (\frac{n}{\log n} \Biggr )$
  4. $O(n)$

3 Answers

Best answer
59 votes
59 votes

Correct Option: A

We need to divide $n$ recursively and compute like following:

$C_1 = b^{\frac{n}{2}} \times b^{\frac{n}{2}}$. In this, we need to calculate $b^{\frac{n}{2}}$ only once.

$C_2 = b^{\frac{n}{4}} \times b^{\frac{n}{4}}$

$\vdots$

$C_k = b^2 \times b^2 \qquad \Bigg \{k = \log n$

Recurrence relation: $T(n) =T \Bigl (\frac{n}{2} \Bigr ) + O(1)$

$T(n) = O(\log n)$

edited by
28 votes
28 votes

Answer is (A)

1. First find out b^2 which will require 1 multiplication(b*b)..store the value of b^2(say in variable 'a') for further use...

2. b^4 can be find out  using a*a ie 1 multiplication, therefore total of 2 multiplication (including step 1). Store the value of b^4 in variable 'c' for further use.

3. Similarly b^8 can be calculated by c*c i.e 1 multiplication and total of 3 multiplication (including step 2)....and so on. Therefore O(log n) is the complexity for the no. of multiplications required.

edited by
6 votes
6 votes
Or You can start from $b^1$ and keep squaring  :   $ b^1 b^2 b^4 b^8 ...  b^n $

where each squaring operation is a multiplication, which is asked in the question. $= O(logn)$
edited by
Answer:

Related questions

6.6k
views
6 answers
43 votes
Ishrat Jahan asked Oct 30, 2014
6,592 views
Let $P_1, P_2,\dots , P_n $be $n$ points in the $xy$-plane such that no three of them are collinear. For every pair of points $P_i$ and $P_j$, let $L_{ij}$ ... $\Theta\left(n^2\right)$
14.1k
views
11 answers
52 votes
Ishrat Jahan asked Oct 29, 2014
14,143 views
A depth-first search is performed on a directed acyclic graph. Let $d[u]$ denote the time at which vertex $u$ is visited for the first time and $f[u]$ the time at which the DFS call to the ... < d[v]$d[u] < f[v]$f[u] < f[v]$f[u] > f[v]$
11.8k
views
4 answers
34 votes
Ishrat Jahan asked Oct 29, 2014
11,764 views
Consider a weighted, undirected graph with positive edge weights and let $uv$ be an edge in the graph. It is known that the shortest path from the source vertex $s$ to $u$ has weight ... $(u,v) = 12$Weight $(u,v) \geq 12$Weight $(u,v) > 12$
19.1k
views
5 answers
47 votes
Ishrat Jahan asked Oct 30, 2014
19,074 views
Consider the $B^{+}$ tree in the adjoining figure, where each node has at most two keys and three links.Keys $K15$ and then $K25$ are inserted into this ... ) and (iii) are trueStatements (iii) and (i) are trueAll the statements are false