If x is an n-bit integer. What is the size (in bits) of x^{2}?

I think the answer is O(n); is that correct? The way I thought about it is adding a number to itself that number amount of times means that there will be n operations, therefore O(n). Is my understanding correct?

Let's suppose x has n bits. This means x = Θ(2^{n}). Therefore, x^{2} = Θ(2^{n} · 2^{n}) = Θ(2^{2n}), so the number now has about twice as many bits as before. This means that if there were n bits to begin with, there are now about 2n = Θ(n) bits.

While the answer you gave of O(n) is correct, your reasoning is invalid. Note that the question isn't asking for how long it takes to compute x^{2}, but rather the number of bits it contains. The time to compute x^{2} is a different question.

Hope this helps!

Similar Questions

hi i want to know how to calculate steps taken using the Accelerometer. Actually i calculate acceleration and use this code to count step length = sqrt(x * x + y * y + z * z); if(length>=2){ stepco

This question already has an answer here: numpy boolean array with 1 bit entries 3 answers I need a 2d n by n boolean array that uses as close to n^2 bits of memory as possible. The operations

*I'm using assembly 8086 (x86-32) The deal is very simple, I have a byte-sized number in register AL (8 bits), now, I need to exchange between bit 1 (the second from right) and bit 4 (the fifth from r

I'm trying to count the number of variables that are set to 'yes' using PHP and then output the count. So for example, I have the following variables: $facebook = $params->get('facebook'); $twitter

Given an directed unweighted acylic graph, I am trying to adapt Floyd-Warshall algorithm to count the number of paths between 2 vertices. My code currently looks like this: for all k in 1 to n for all

Possible Duplicate: Best algorithm to count the number of set bits in a 32-bit integer? Hi , I came across this question in an interview. I want to find the number of set bits in a given number in a

I know how to find out how many bits are on in a given number (or how many elements are true in a boolean arra), using a mask and bitwise operators, going over all bits checking if they are on. Assumi

I need to have a fast way to count the number of set bits for an index interval for a bit vector. For example, given 10000100100011000 and index interval [2, 5], the return is 2. The index starts with

I need to count the number of files in a directory using Python. I guess the easiest way is len(glob.glob('*')), but I also count the directory as file. Is there any way to count only the files in a d

This question already has an answer here: Display float value w/o scientific notation 4 answers I have a large number [987654321999999] that i wanna pass it to jquery but it return large number

I am converting expressions with only function calls and integers from Infix notation to Postfix notation (only letters,digits,commas,brackets and no spaces). For example, add(add(1,2),add(3,4)) to 1

In Rails 3.1, how can I get a count of the number of attributes an object has? For instance, I have an object called Projects and I would like to know how many attributes (columns) it has.

I want to know how to toggle alternative bits in a number? for eg if number is 1100 1001 the result should be 1001 1100

What is the best method of generating a number with 256 random bits? Does concatenating random bytes work? byte[] data = new byte[32]; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); r

On my midterm, there was a question stating: Given the decimal values, what is the minimum number of bits required to represent each number in Two's Complement form? The values were: -26, -1, 10, -1

I have an assignment in which I need to create a function that tells you how many 1's are in the binary notation of a integer. I did this already by creating my own algorithm. The second step is to us

I couldn't find anything in man mib2c.conf. Is there something like $var.length/$var.size by any chance?

I am given a start and end date. i want to count the number of weekdays between those 2 dates. then in a table of dates, i want to count those in a similar fashion to to pick weekends only. Could some

a = [1, 2, 9, 5, 1] b = [9, 8, 7, 6, 5] I want to count the number of duplicates between the two lists. So using the above, I want to return a count of 2 because 9 and 5 are common to both lists. I t

I'm dealing with timestamps in Lua showing the number of microseconds since the Epoch (e.g. 1247687475123456). I would really like to be able to print that number in all its terrible glory, but Lua

Imagine that I have the class Imaginary(x) and the class Real(y) in Scala. Is there a way to do ComplexNumber = 3 + 2i instead of doing ComplexNumber = Real(3) + Imaginary(2) ? Thanks.

I am trying to count the number of links in a textarea so I can limit the user to no more than three links. The code below is what I have so far, but it's not working. I am thinking the html is encode

If i take a uint value = 2921803 (0x2C954B), which is really a 4 byte package (4B 95 2C 00) and i want to get the 16 least significant bits of the byte version of it using bitarray, how would i go abo

Given: xvalues = [0.0, 1829.0, 3658.0, 5487.0] and nodesF = [[1, 0, 0, 0], [2, 0.5, 0, 0], [3, 5487, 0, 0]] I want to loop over nodesF and return x1 and x2 values which every x of nodesF lie between

I found the following code to count the number of 1-bits in binary representation for given integer. Can anyone explain how it works? And how are the bit masks chosen for such task? Thanks. int count_

I'm looking for a commonly understandable notation to define a fixed point number representation. The notation should be able to define both a power-of-two factor (using fractional bits) and a generic

I want to print scientific notation number with same scale in python. For example I have different numbers (1e-6, 3e-7, 5e-7, 4e-8)so now I want to print all these numbers with e-6 notation (1e-6, 0.3

I want to count the number of occurrences of each character in a given string using JavaScript. For example: var str = I want to count the number of occurances of each char in this string; Output

Test case : 35000 -> a normalized scientific notation of the number would be 3.5 * 10E4 -> the engineering notation would be 35 * 10E3 A simple algorithm that does this would keep dividing the

I've been doing some questions but answers not provided so I was wondering if my answers are correct a) given that a[i....j] is an integer array with n elements and x is an integer int front, back; wh

I have a file which contains title written in it many times. How can I find the number of times title is written in that file using the sed command provided that title is the first string in a l

How can I iterate and evaluate the value of each bit given a specific binary number in python 3? For example: 00010011 -------------------- bit position | value -------------------- [0] false (0) [1]

I have been writing apps for my Droid x2 using the new Android update 2.3.4. The layout with of a simple test app show a margin on the left, right, and buttom side of the screen. How do I get the full

I am currently trying to write an algorithm that determines how many bits are necessary to represent a number x. My implementation will be in c. There are a few catches though, I am restricted to pret

In networking, what is the relationship between the number of bits and a packet? In other words, how many bits are there in a packet? Is this number constant? If not, what does it depend on? (protocol

I need to get total number of months in select query. My table name is Customers and column name is Createddate. I need to calculate number of months between Createddate to current date. Thanks

I should count the number of set bits of a __m128i register. In particular, I should write two functions that are able to count the number of bits of the register, using the following ways. The total

I want to know the number of bits really used in the long datatype in Java. For instance: long time = System.currentTimeMillis(); System.out.println(java.lang.Long.toHexString(time)); Output: 12c9516

1 = 0b1 -> 1 5 = 0b101 -> 3 10 = 0b1010 -> 4 100 = 0b1100100 -> 7 1000 = 0b1111101000 -> 10 … How can I get the bit size of an integer, i.e. count the number of bits that are necessary

Here is a beginner's question. What does this XPath expression /.. mean? Does it always select an empty node-set? I've noticed that this pattern is used extensively in FXSL library, for example: <x

The title says it all. I tried looking through the API but couldn't find a convenient function. I've thought of a number of ways to do this. I could call find() and count the number of records in the

Say I have two positive numbers a and b. How many bits must be inverted in order to convert a into b ? I just want the count and not the exact position of the differing bits. Lets assume a = 10 ( 1010

I would like to know if there is any way of counting the number of tuples in a table without actually using the COUNT function? A B C XXXX YYYY IIII XXXX SSSS PPPP RRRR TTTT FFFF KKKK AAAA BBBB If I

unsigned reverse_bits(unsigned input) { //works on 32-bit machine input = (input & 0x55555555) << 1 | (input & 0xAAAAAAAA) >> 1; input = (input & 0x33333333) << 2 | (inpu

I am having some trouble getting pointers to how to perform what appears to be a deceptively easy task: Given an audio stream, how do you count the number of words that have been spoken, in real-time?

How can i count number of times the iframe has redirect with AngularJS? I do so far with this code, but no luck. I found if using JQuery can done like this. Any help would be greatly appreciated!

I am using name-spacing with object literal notation. I would like to use prototype object inheritance so that Scene is subclass of Snippet. I am not able to initiate Scene object properly. console.

I have a function to give me the factorial of a number class Integer def fact (1..self).reduce(:*) || 1 end end I'd like to know how can I call this method using the Mathematical notation of Factoria

I am using VS 2010 - WPF - C# I can't find out how to specify the number of bits that will be reserved for the string when its printed on the screen. Back in Pascal we used to do Writeline(some strin

Possible Duplicate: Best algorithm to count the number of set bits in a 32-bit integer? Finding out the no. bits sets in a variable is easier. But how could we perform the same operation in fastest