Time Complexity & Big O notation
Time complexity is the time taken by an algorithm as a function of the length of of of input. This
is time complexity in these three lines. Time complexity means an algorithm. Just as you
increase its length of input then how does that algorithm perform ? How does that algorithms
behave ? How do you use their constraints and tell which algorithm is to be used here ? Time
complexity has been invented and it basically tells us that which is the better algorithm among
the two ? And there comes in use - The Big O Notation. This Big O notation works to quantify
the time complexity of an algorithm. It tells that the this algorithm will take this much time
according to this length of input. Big O notation takes in account the bigger power and nothing
other than that. For any n which one is greater, obviously n is greater. Even if the constant is
large we 'll assume it as O ( 1 ) Even if there is a very large no. with n^2 then we 'will still
consider it O (n^2 ) If you will make the graph of n will be something like this.
Big O notation is mostly used in computer science because we remain safe by finding through
Big O notations for multiple algorithms. We constrain in THETA notation. OMEGA
NOTATION tells that what will be the lower bound of the algorithm. THETA and OMEGA
notation are other notations that tell us what is the time complexity of algorithms. Using the tree
method, we 'll try to find with the. tree method so that you can easily find the time complexity of
recursive functions. First of all, you write the non-recursive part in this way- n c. after that the.
recursive part is T ( n/2 ) and the. recursion part. After adding them then you 'll have n c
operations performed. You have to see the no. of operations performed at each step. If you want
to tell which algorithm is better according to the constraint in the online judges. Then what is the
method. I have already told you about this in a previous video. But if you still want to know then
I 'll tell you. Try finding their time complexities and tell me what did you find. I'll put their
answers in my telegram channel.
You just need to check that 10^8 operations rule is being followed and you can easily find if time
constraint is given to me then what will be the algorithm. Similarly if its given between 15-18
then this type of complexity will be accepted. If its given 100 then you can go till ( n^4 ) If 400 is
given, the you can then go till n^3. If you found that its - n log n , then the algorithms based on
it , you should strike at that time. It means I cab either apply sorting- it might be solved after
sorting or such an operation that can be don in - log n I can perform that operation n times , you
can
SO if it's given between 15-18,, then this type of complexity will be accepted. IF. It's given 100,
then you can go till (N^4). IF 400 is given, the you can go till (N^3), simple you can try it by
yourself, right!.
, Bit Manipulation Algorithms Part 1
DSA One course will study Bit manipulation, Bit magic and Bitwise operators. Bits are actually
very important from Competitive programming point of view. If your submission differs by just
few microseconds, then it affects your rank as well If you would be using BITWISE concepts ,
then your submission will be very fast. We will learn such tips and tricks in bits. You can convert
any decimal number to binary using this method. Addition/subtraction works in the same way as
they work in decimal numbers. In binary numbers, digits are from 0-9 but they go from 0 to 1 in
binary numbers. You will get use to it when you will practice it more So this is how your binary
number works. The main question is how to find the negative inverse of any number in binary is
2 's compliment. Negative inverse of a number which we have to subtract and then we will add it
to the other number to get our answer. The last carry will keep on making all the extra set bits as
0 and this carry will be discarded.
In micro-processors, all the additions/subtractions are done using this way only There is no
operation as Subtraction. We find the 2 's compliment and then add it with the other number.
You just have to inverse all the bits and add 1. Right shift operator shifts the bits towards right.
We use tilt ( ~ ) symbol to present inverse operation. We have left shift operator. When you have
to perform left shift by 2 , then you will shift all the bits towards left by 2 and it will get
converted to this We can replace the empty bits by zeroes This number equals to 48. We can use
it whenever we need to divide a number by 2 multiple times. This is how we use to find whether
a number is ODD or even. We will see more power of XOR in its 3rd video. In next video, we
will see bit masking and see what we can do with the help of Bit masking. The power of the
XOR operator is a very simple concept by computationally it is bit faster.
Time complexity is the time taken by an algorithm as a function of the length of of of input. This
is time complexity in these three lines. Time complexity means an algorithm. Just as you
increase its length of input then how does that algorithm perform ? How does that algorithms
behave ? How do you use their constraints and tell which algorithm is to be used here ? Time
complexity has been invented and it basically tells us that which is the better algorithm among
the two ? And there comes in use - The Big O Notation. This Big O notation works to quantify
the time complexity of an algorithm. It tells that the this algorithm will take this much time
according to this length of input. Big O notation takes in account the bigger power and nothing
other than that. For any n which one is greater, obviously n is greater. Even if the constant is
large we 'll assume it as O ( 1 ) Even if there is a very large no. with n^2 then we 'will still
consider it O (n^2 ) If you will make the graph of n will be something like this.
Big O notation is mostly used in computer science because we remain safe by finding through
Big O notations for multiple algorithms. We constrain in THETA notation. OMEGA
NOTATION tells that what will be the lower bound of the algorithm. THETA and OMEGA
notation are other notations that tell us what is the time complexity of algorithms. Using the tree
method, we 'll try to find with the. tree method so that you can easily find the time complexity of
recursive functions. First of all, you write the non-recursive part in this way- n c. after that the.
recursive part is T ( n/2 ) and the. recursion part. After adding them then you 'll have n c
operations performed. You have to see the no. of operations performed at each step. If you want
to tell which algorithm is better according to the constraint in the online judges. Then what is the
method. I have already told you about this in a previous video. But if you still want to know then
I 'll tell you. Try finding their time complexities and tell me what did you find. I'll put their
answers in my telegram channel.
You just need to check that 10^8 operations rule is being followed and you can easily find if time
constraint is given to me then what will be the algorithm. Similarly if its given between 15-18
then this type of complexity will be accepted. If its given 100 then you can go till ( n^4 ) If 400 is
given, the you can then go till n^3. If you found that its - n log n , then the algorithms based on
it , you should strike at that time. It means I cab either apply sorting- it might be solved after
sorting or such an operation that can be don in - log n I can perform that operation n times , you
can
SO if it's given between 15-18,, then this type of complexity will be accepted. IF. It's given 100,
then you can go till (N^4). IF 400 is given, the you can go till (N^3), simple you can try it by
yourself, right!.
, Bit Manipulation Algorithms Part 1
DSA One course will study Bit manipulation, Bit magic and Bitwise operators. Bits are actually
very important from Competitive programming point of view. If your submission differs by just
few microseconds, then it affects your rank as well If you would be using BITWISE concepts ,
then your submission will be very fast. We will learn such tips and tricks in bits. You can convert
any decimal number to binary using this method. Addition/subtraction works in the same way as
they work in decimal numbers. In binary numbers, digits are from 0-9 but they go from 0 to 1 in
binary numbers. You will get use to it when you will practice it more So this is how your binary
number works. The main question is how to find the negative inverse of any number in binary is
2 's compliment. Negative inverse of a number which we have to subtract and then we will add it
to the other number to get our answer. The last carry will keep on making all the extra set bits as
0 and this carry will be discarded.
In micro-processors, all the additions/subtractions are done using this way only There is no
operation as Subtraction. We find the 2 's compliment and then add it with the other number.
You just have to inverse all the bits and add 1. Right shift operator shifts the bits towards right.
We use tilt ( ~ ) symbol to present inverse operation. We have left shift operator. When you have
to perform left shift by 2 , then you will shift all the bits towards left by 2 and it will get
converted to this We can replace the empty bits by zeroes This number equals to 48. We can use
it whenever we need to divide a number by 2 multiple times. This is how we use to find whether
a number is ODD or even. We will see more power of XOR in its 3rd video. In next video, we
will see bit masking and see what we can do with the help of Bit masking. The power of the
XOR operator is a very simple concept by computationally it is bit faster.