What is the Big O Notation (Time Complexity) of an array declaration? - big-o

I was wondering what the time complexity for this line would be in Big O notation.
Any help would be greatly appreciated!
int arr[] = new int[10];
Sorry if this is a super easy question I'm fairly new to Big O notation.

Related

Shorten a big O notation

I am working for a project of my class and would like some check/help to see if my shortening of Big O notation is right:
n*O(log(n)) + n * O(log((n)) = 2n*O(log(n)) = n*O(log(n))
n*O(1) + n * O(n) = n*O(n)
Is my shortening correct? and are these can be further shortened?
I would really appreciate any help.
Since n is O(n), the first one is O(nlogn) and the second one is O(n^2).
The proof for n being O(n) can be done using the definition of O(n).

Big O, Theta, and big Omega notation

Based on my understanding, big O is essentially similar to theta notation but can include anything bigger than the given function (e.g. n^3 = O(n^4), n^3 = O(n^5), etc.), and big Omega includes anything smaller than the given function (n^3 = Ω(n^2), etc.).
However, my professor said the other day that n^0.79 = Ω(n^0.8), while he was doing an exercise that involved the master theorem.
Why/how is this true when n^0.8 is larger than n^0.79?
You have big O and big Omega backwards. Big O is everything the "same" or smaller than the function.

Calculating Algorithm Efficiency and Complexity

My instructor taught us how to calculate the computational complexity of an algorithm, but she only did so very briefly and not so well. More specifically, could someone help me calculate the computational complexity of the following:
While (PLength > 0)
chartest = sHex(i)
ascvalue = Strings.Asc(chartest)
decvalue = Convert.ToDecimal(ascvalue)
shiftdecvalue = decvalue + 1
asc = ChrW(shiftdecvalue)
emptychararray(i) = asc
i = i + 1
PLength = PLength - 1
End While
They way I've thought about it, it just comes out to be T(n)= C_1*n+C_2*(n-1)+C_3*(n-1)+C_4*(n-1)+C_5*(n-1)+C_6*(n-1)+C_7*(n-1)+C_8*(n-1)+C_9*(n-1)+C_10*(n-1)
But I feel like I might be oversimplifying it. Furthermore, how do I get the big O notation for this? I've been looking online for resources on how to teach myself this, so if you have any recommendations, those would be greatly appreciated. Thank you in advance.
First note that T(n) can be rewritten as T(n) = C1 * n + C2. Then note that big O notation ignores constants, so the complexity is O(n).

Rules of Big O - Question

If I have the following closed form solution for a recurrence relation, how can I simplify it under big O:
f(n) = 3^n + n.9^n
I would hazard a guess at:
f(n) is a member of O(9^n) -> Am not sure if this right? Could someone please let me know how to simplify the above equation under big O and also state which rule you used...
Thanks in advance
http://en.wikipedia.org/wiki/Big_O_notation
If f(x) is a sum of several terms, the one with the largest growth rate is kept, and all others omitted.
So O(n * 9^n), assuming that with n.9^n you meant n * 9^n.
Simple relations which helps you is:
O(1) < O(log(N) < O(N^Epsilon)<O(N)<O(N logN)<O(N^c)<O(c^n)<O(n!)<O(n^n)
for c >1 and 0 < Epsilon <1.
See big O in wiki for better understanding

How To Calculate Complexity?

I am a beginner in algorithms and I don't know how to calculate complexity.
Example:
int x=10,y;
y = x;
What is the complexity in example above?
Thanks
That should be O(1) if you refer to the O-Notation.
In the Big O Notation this corresponds to O(1) which basically means that the run-time of the operation is constant or at least is less than a certain constant. Ergo, the run-time does not depend on the input you have. As you may infer from what I wrote, the Big O Notation only gives an upper bound of the operation. There is also other notations which give a lower-bound and so on.
An example of a case where it does depend on the input could be:
int res = 0;
int[] arr = getSomeArray();
foreach (int i in arr)
res = res + i;
Here the run-time depends on how big the array is, and if we give the length of the array the variable n then this will be O(n). Again, the Big O Notation does not specify exactly how long it will take to execute but, in this case, just says that we can multiply n by some constant and then it will be finished within n*some s.
A more detailed explanation is given here: What is a plain English explanation of "Big O" notation?

Resources