Big O Notation Examples || Lesson 10 || Algorithms || Learning Monkey ||

Learning Monkey
Learning Monkey
1.5 هزار بار بازدید - 2 سال پیش - Big O Notation ExamplesIn this
Big O Notation Examples

In this class, we will understand Big O Notation Examples.

We have already discussed the definition of Big O Notation in our previous class.
Big O Notation Examples

In the previous class, we said that Big O Notation gives the upper bound for an algorithm.

To understand this, we will consider the algorithm shown below.

The above algorithm is to search for an element in an array.

The algorithm will search for the given element.

Let’s consider the array shown below.

If we are searching for five, how many times the for loop will iterate.

The loop will iterate four times.

Similarly, if we search for nine, the loop will iterate only once.

The number of times the loop iterate will depend on the input.

We can’t say exactly how many times the loop will iterate for this algorithm, but we can say the upper bound.

The Upper bound means the atmost number of program steps executed in the worst-case scenario.

The maximum or atmost number of program steps execution is done when we search for 31.

We have discussed that Big O notation gives the upper bound for the function for this search algorithm we can notate with Big O.

Notating an algorithm with Big O means atmost in the worst case, the algorithm will execute those many numbers of program steps.

Our search algorithm will execute n number of program steps in the worst case.

For a better understanding, click the YouTube link provided on the top.

#algorithms #gatecse #learningmonkey #computerscienceengineering #competitivecoding #placementtraining


Link for playlists:
@learningmonkey


Link for our website: https://learningmonkey.in

Follow us on Facebook @ Facebook: learningmonkey

Follow us on Instagram @ Instagram: learningmonkey1

Follow us on Twitter @ Twitter: _learningmonkey

Mail us @ [email protected]
2 سال پیش در تاریخ 1401/04/04 منتشر شده است.
1,580 بـار بازدید شده
... بیشتر