@@hetaeramancer the problem is same as the previous one shown in the tutorial, just changed the log loop order. However, finally we need to multiply it, so we the answer O(n)×O(logn)×O(n)= O(n²logn)
Yes please im also searching for the answers to verify. I think it would be better if @ neso academy provides the answers. However the work done by neso is absolutely awesome.
@@charankumar4267 The time complexity of nested loops can be determined by analyzing the number of iterations each loop performs. Let's break down the given nested loops: ``` for (i = n/2; i
solve many problems in time complexity which are often used in programs it will be helpful and thank you no other video in youtube has this much clear explanation
I think in the homework problem, there is a mistake! It maybe be j=2*j. Otherwise, for 2*j, It will go into an infinite loop and therefore, there is no "algorithm time complexity" for an infinite loop. for j=2*j, The time complexity is O(logn). So the answer is: O(n^2logn)
after going through 3 to 4 dsa playlist on youtube undoubtly i can say that this is the best dsa playlist available in youtube , thanks neso academy for this wonderful explanation
@@manuelconte623 its simple....becuase Its the most basic foundation of programming complexity in accordance with memory, time and everything.....programming is not only about programming but also with these things....hope you understood...
@@kirtitung4877 No, because we have 3 nested loops for the first one is O(n) and the second one is O(log n) then the last one is O(n) so the answer is O(n×log n×n)=O(n² log n)
Solution of HW problem is: upper bound is infinite. Since there is no modification in j value. J always remains 1 and if n>1 then second for loop would be executing infinitely. J is just multiplied by 2. Not assigned to j again.
The time complexity of nested loops can be determined by analyzing the number of iterations each loop performs. Let's break down the given nested loops: ``` for (i = n/2; i
I have a doubt. Many of them are saying the answer to the Homework problem as O(n^2 * log2(n)), but in the second for loop, there is no update statement. 2*j isn't updating the value of j, which makes j constant and hence, the for loop becomes an infinite loop. Isn't time complexity O (Infinity)?
Here third loop will take 2N unit time because there is count statement If loop run 2 times then count++ also 2 times here total 4 unit of time is consumed and if last loop run 3 times count++ also run 3 times so here 6 unit of time is consumed so 2*N unit of time is consumed in last loop n/2×logn×2n=n^2(logn or log2n) i think this the way
Sir Neso at the 2nd for loop of the homework problem, the loop control variable j does not get updated simply with 2*j You must mean j *= 2 or j = 2*j. Nonetheless, great lecture as always.
I think the answer will be O(infinite) Because in the second for loop the value of j is not incrementing so one the program enters the second for loop then the for loop condition will never get wrong and hence it will keep running
If we consider above same code then the time complexity would be O(n^3 ) as most of you confused in 2nd loop that there is mistake i don't think so like if there is not written j=j×2 its written j×2 this means the value of j is incrementing by double of its value like the time complexity of this will calculated by 1+2(k-1) =n so its will be N/2
Home work, we can consider two cases, one where input is less than one that and input greater than one. less than one the growth rate is O(n), but if its n>= n. the algorithm fails and there is no defined time complexity.
But lets say j has address 1000, and if j is 1 initially and then multiplied by 2, the answer will be stored in same address, not a different one so it is assigned,,,,correct me if i am wrong
thanks for such amazing content sir!..one doubt ..that when we declare a function or rather initialize a function....how do we account for the time complexity of that?
I checked out 2-3 courses on data structures but felt that they’re not explaining concepts properly but the way you explain is amazing👌🏻
Teaching is very excellent👏👏👏.
Answer is O(n^2 logn).
Answer for Homework Problem is O(n^2 logn)
1st for loop O[n]
2nd for loop O[logn]
3rd for loop O [n]
the loop parameter in 2nd loop is not changing
@@thirumal1086 whats the correct answer then?
@@hetaeramancer the problem is same as the previous one shown in the tutorial, just changed the log loop order. However, finally we need to multiply it, so we the answer O(n)×O(logn)×O(n)= O(n²logn)
@@FaAbYorker the second loop isn't updating tho
I check my answer in the comments but what I see everyone is thanking neso academy. I thank them too to give us these precious video lectures 🙏
Yes please im also searching for the answers to verify. I think it would be better if @ neso academy provides the answers. However the work done by neso is absolutely awesome.
@@charankumar4267 The time complexity of nested loops can be determined by analyzing the number of iterations each loop performs.
Let's break down the given nested loops:
```
for (i = n/2; i
@@workwiseonline the log should be in base 2 in the final answer right?
Right
@@workwiseonline thanks for the fast reply
solve many problems in time complexity which are often used in programs it will be helpful and thank you no other video in youtube has this much clear explanation
I think in the homework problem, there is a mistake! It maybe be j=2*j.
Otherwise, for 2*j, It will go into an infinite loop and therefore, there is no "algorithm time complexity" for an infinite loop.
for j=2*j, The time complexity is O(logn). So the answer is: O(n^2logn)
Yes bro
it's O(n^logn*n) isn't it? cmiiw
I got O(n^2 * log(n)) as well.
ye but thats the same as O(n² log(n)) @@mfahmifachrozi2728
It will not go in infinite loop when after p iterations 2^p-1 = n, then the loop will stop. Answer is O(n²logn)
after going through 3 to 4 dsa playlist on youtube undoubtly i can say that this is the best dsa playlist available in youtube , thanks neso academy for this wonderful explanation
I stick to your content from starting till end.Excellent way of teaching.
even me, he is an excellent at teaching and explaining things!!
This video is very most important for competitive programming..
😇😊 Great emplanation for time complexity
hi, your answer give me a question for you, so why this topic of exercises is most important for competitive programming?
@@manuelconte623 its simple....becuase Its the most basic foundation of programming complexity in accordance with memory, time and everything.....programming is not only about programming but also with these things....hope you understood...
I must say this is a really nice intro to Asymptotic Analysis thank you, saved me a lot of headache
Thanks for the awesome explanation😍😍
hey, Neso in the homework problem the loop for( j=1; j
Yes
J*=2
Yes I scrolled to the comments just to see if somebody else noticed
Note that j *= 2 also works
No
thank god for youtube, my prof went through this and it’s on the final next week. i was so confused but you cleared it up!
the answer is O(n² log n) Great work ♥ I appreciate your effort
This should be O(n^2)
Since 2nd loop is constant time complexity .
I am talking about homework problems
@@kirtitung4877 No, because we have 3 nested loops for the first one is O(n) and the second one is O(log n) then the last one is O(n) so the answer is O(n×log n×n)=O(n² log n)
Correct
O(nxnxlogn)=O(n²logn) try to figure out what happens inside the loops..
1st loop = O(n)
2nd loop = O(logn) , base 2
3rd loop = O(n)
Answer =O (n^2 logn)
Solution of HW problem is: upper bound is infinite.
Since there is no modification in j value.
J always remains 1 and if n>1 then second for loop would be executing infinitely.
J is just multiplied by 2. Not assigned to j again.
Sir I got Time complexity as ----------> (n^(2)) Log(n), if consider j = j*2 in 2nd for loop
Please confirm it.
As same as everyone saying, I like the way and content you teach for us. Thank you very much.
Answer is O(n^2 logn)
I found a best explanation of calculating time complexity here.THANKS #nesoacademy
Answer for homework problem is O(n^2 log n to the base 2)
All the videos are amazing. Thankyou so much.
1st loop : O(n)
2nd loop: O(log2n)
last loop: O(n)
So the total time complexity is
O(n^2 log n)
The Answer is O(n^2 log(n)).....
Nice those videos on time complexity
And Also I want to the videos of space Complexity
The time complexity of nested loops can be determined by analyzing the number of iterations each loop performs.
Let's break down the given nested loops:
```
for (i = n/2; i
thanks !
I have a doubt. Many of them are saying the answer to the Homework problem as O(n^2 * log2(n)), but in the second for loop, there is no update statement. 2*j isn't updating the value of j, which makes j constant and hence, the for loop becomes an infinite loop. Isn't time complexity O (Infinity)?
you are right bro
yes bro i got same only
so time xomplexity is n^2 ??
@@hetaeramancer No, as I said, the time complexity is O(∞).
case one, n= 0, and case 2 n >=1. case one O(1), case two there is no algorithmic complexity, algorithm much terminates.
I am hopeful that..... This is the best content..,..... When I search the entire RUclips channels for data structures
Jasprit sir's way of teaching is over powered
Best way of teaching 🥳🥳
Answer ,0(n^2logn)
this is quality education #naso_acadmey
The answer is: O(n^2log2). Thanks for explaining #nesoacademy
Correct ur answer bro its O(n^2logn)
Here third loop will take 2N unit time because there is count statement
If loop run 2 times then count++ also 2 times here total 4 unit of time is consumed and if last loop run 3 times count++ also run 3 times so here 6 unit of time is consumed so 2*N unit of time is consumed in last loop
n/2×logn×2n=n^2(logn or log2n) i think this the way
There is some mistake in 2nd loop(Home work problem) .. it will be -> for(j=1 ; j
Great contents, loved it 😍
O(n^2logn) may be the answer of today's question.Thank you #nesoacademy
J loop is infinte loop
Mera bhi yhi aaya
Regards
Binod
@@akhil1273 its because j*2 not j *= 2 right?
Superb sir all of ur videos in each subject are awesome
Sir Neso at the 2nd for loop of the homework problem, the loop control variable j does not get updated simply with 2*j
You must mean j *= 2 or j = 2*j. Nonetheless, great lecture as always.
I think the answer will be O(infinite)
Because in the second for loop the value of j is not incrementing so one the program enters the second for loop then the for loop condition will never get wrong and hence it will keep running
infinite loop has no algorithmic time complexity actually for some algo's it is also possible that we cannot find the time complexity
Great content... really cleared my doubts....
Thanks for this video
Best teacher ever..❤️
If we consider above same code then the time complexity would be O(n^3 ) as most of you confused in 2nd loop that there is mistake i don't think so like if there is not written j=j×2 its written j×2 this means the value of j is incrementing by double of its value like the time complexity of this will calculated by 1+2(k-1) =n so its will be N/2
Answer for homework problem is - - it will give TLE (time limit exceed) because 2nd loop runs infinite number of times
It will sow error , as it is not a valid statement.
Can you explain how the loop goes on infinity?
@@pushkarajyeolekar5852 see in 2nd for loop
Value of j is 1 and we are not incrementing its value and value of j is always 1
@@pratikkumar9696 j*2 //it is changing j value when 2nd loop runs for another time j would become j*2 i.e 2
and so on
The Best academy ever
Thank you! For these! A big help. Kindly please post more vidoes in this playlist as it is not complete
Home work, we can consider two cases, one where input is less than one that and input greater than one. less than one the growth rate is O(n), but if its n>= n. the algorithm fails and there is no defined time complexity.
Good explanation.....neso academy always best👍
Beautiful analysis! Incredible job. Thank you for providing this content.
Thanks Neso Academy, you are really helping us better understanding our lectures.
Sir upload more videos daily if u can.maybe 3 or more per day if possible.
answer is O(n2 log n) is it correct jaspreet sir
Love you sir ❤️
O(n*logn base 2 * n)
In given homework problem, loop for variable j goes into infinite loop. but if j = 2*j in inc expression, then answer is as expected.
But lets say j has address 1000, and if j is 1 initially and then multiplied by 2, the answer will be stored in same address, not a different one so it is assigned,,,,correct me if i am wrong
@@nisharathod2945 answer will not get stored without assignment operator, in case of above problem it should throw an error
First loop-O(n)
Second loop-O(log n)
Third loop-O(n)
Final Answer=O(n^2 . log n)
Hey hi senior. Here why we can't take n/2 instead of 'n' while considering the last term of the for loop ( where we have took o(n) )
Because Big-O-notation refer to the worst case complexity I.e. upper bound .
Got it
@@atulmishra2593 thank u..
I LOVE how you went through this thank you so much.
realy first time i got the point
homework problem time complexity is O(n^2logn)
Thanks for saving my life
(n^2 logn)
Great Explanation
Sir what is the right answer ?I got O(n^3) if it is O(n^2.logn) please explain
Thank you for this course. But how much time it will take to complete this ds course
Sir in this list of data structure please cover the advance part of data structure also
So essentially we solve for the variable representing the iteration number each time and use that to find the upper bound?
dayum nice explanation
Always Neso Acadamy
This is infinite loop. the first condition i
home work's question's total time complexity is O(n^2 logn)
Thank you for making this presentation
I wanted to ask that in the last loop why are we considering its time complexity as O(n) instead of taking upper bound of n?
Thank you Sir...
I love you Neso Academy. ❤️
keep up the good work!! this video was so much helpful, thank you soo much!
Answer is O(n^2logn)
Thank you sir. My concepts are now very clear.😊
glt hai n^3 hoga
@@anuragsahu1669 kaise
Thanks a lot #nesoacademy for making this time complexity session very easy to understand
Good explanation 👏
O(n^2logn with base2)
Great explanation! 🤟
the answer is O(n^2 log n base 2)
Thanks a lot !! cleared all my concepts
O(n^2 log(base2) of n)
Thank you
Nice work sir ur videos are really good .
The answer for the H.W problem is O(n*logn*logn)
Sir! Please post DBMS tutorial for beginners 🙏🏻
thanks for such amazing content sir!..one doubt ..that when we declare a function or rather initialize a function....how do we account for the time complexity of that?
Best Sir
O(n'2 log2_n).... Thank u..
The time complexity you have calculated is for worst case right?
n square multiply by logn is total time complexity
Sir,How many more lectures are there to complete the subject ?
Home Work: O(n^2 logn)
TOTAL TIME = O(1) +O(n)+O(logn)+O(n)=O(n^2 logn)................
answer of the homework=> n * logn * n == O(n^2 logn)
thanks a lot🙏🙏🙏🙏 very helpful
you have such a nice voice🥰
Answer of Homework problem = O(n^2logn)
Answer>> O(n^2 logn)
for (int i = 1; i
Too good bro....... 👍
The complexity of the snippet at the end should be infinite. Because even for k=infinite, j = 1
Thank you so much