+1 vote
735 views
in Cryptograph & Network Security by (60.0k points)
The time required to convert a k-bit integer to its representation in the base 10 in terms of big-O notation is

(a) O(log2 n)

(b) O(log n)

(c) O(log2 2n)

(d) O(2log n)

This question was posed to me in an online interview.

This question is from Symmetric Cipher Models and Elementary Number Theory topic in portion Classical Encryption Techniques of Cryptograph & Network Security

1 Answer

+1 vote
by (1.2m points)
selected by
 
Best answer
Correct answer is (a) O(log2 n)

The best explanation: Let n be a k-bit integer in binary. The conversion algorithm is as follows. Divide 10 = (1010) into n. The remainder – which will be one of the integers 0, 1, 10, 11, 100, 101, 110, 11 1, 1000, or 1001 – will be the ones digit d0. Now replace n by the quotient and repeat the process, dividing that quotient by (1010), using the remainder as d1 and the quotient as the next number into which to divide (1010). This process must be repeated a number of times equal to the number of decimal digits in n, which is [log n/log 10] +1 = O(k).

We have O(k) divisions, each requiring O(4k) operations (dividing a number with at most k bits  by the 4 bit number (1010)). But O(4k) is the same as O(k) (constant factors don’t matter in the  big-0 notation, so we conclude that the total number of bit operations is O(k). O(k) = 0(k2). If we  want to express this in terms of n rather than k, then since k = O(1og n), we can write

Time(convert n to decimal) = 0(log2n).

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Most popular tags

biology – class 12 biology – class 11 construction & building materials chemistry – class 12 electronic devices & circuits network theory data structures & algorithms ii cell biology ic engine insurance finance money computational fluid dynamics engineering physics i discrete mathematics chemistry – class 11 aerodynamics casting-forming-welding i engineering mathematics operating system casting-forming-welding ii engineering drawing mysql engineering geology digital circuits wireless mobile energy management electrical measurements digital communications cyber security analytical instrumentation embedded systems electric drives cytogenetics computer fundamentals life sciences basic civil engineering advanced machining iot design of electrical machines physics – class 12 applied chemistry dairy engineering basic chemical engineering cloud computing microprocessor bioinformatics aircraft design aircraft maintenance software engineering drug biotechnology digital signal processing biochemistry data structures & algorithms i automotive engine design avionics engineering material & metallurgy energy engineering cognitive radio unix electrical machines biomedical instrumentation object oriented programming electromagnetic theory power electronics analog communications bioprocess engineering civil engineering drawing engineering metrology physics – class 11 mathematics – class 12 engineering chemistry i basic electrical engineering unit processes mongodb signals and systems cryptograph & network security hadoop mathematics – class 11 engineering physics ii html control systems engineering mechanics antennas analog circuits computer network java sql server javascript concrete technology chemical process calculation artificial intelligence design of steel structures c++ database management computer architecture engineering chemistry ii corrosion engineering chemical technology dc machines
...