Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

ANALYSIS OF ALGORITHMS

Rating
-
Sold
-
Pages
3
Uploaded on
04-04-2023
Written in
2022/2023

This Algorithms and Data Structures course will teach you everything you need to prepare for placements, interviews and logic building. This playlist will teach you how to create optimal solutions to your real world problems. We will cover a wide variety of data structures and algorithms in this course. Make sure to access the notes I have provided along with the course.

Show more Read less
Institution
Course

Content preview

Best Case, Worst Case and Average Case Analysis of an Algorithm (With
Notes)
CodeWithHarry
To define an algorithm, To define the events in the life of an algorithm
, We have , Best Case Worst Case and Expected Case. And along with that,
I 've packed one more thing into this video : The definition of Log. If
you watch this video till the end , Then you will find out what this 'Log
' really is. 1. . . 5. . . 7. . . 9 and 24 are the numbers in it; They
're in ascending order , You can see for yourself. If you know even a bit
of maths, You 'll know that it is in an ascending order. Now what I say
is that I 'll give a number : 'A' And I 'd like you to tell me If this
number exists within the array , or not. Suppose the value of A is 8. So
what will be your answer ? Yes. Meaning 1. If A is. . . Sorry, your
answer will be no , because it is n't there. If the value is 9, What will
the answer be ? Your answer will Algo 1 is a simple person. It does n't
have much of a brain. It is comparing it with all the numbers. Is this
the best way to do this work ? Obviously not. Because Algo. 1 is lucky ,
He will get A=1. It will tell us in the first comparison itself. In one
comparison only.


If Algo 1 is in luck, The time needed is ' k ' - T=k. This means that it
does n't depend on 'n '. Take a 10-element array, take a single element
array or take a 10,000 element array. It only has to make one comparison
because it is only searching for the first element in the array. Now,
AlGo 1 's luck is bad. Till now, he was fortunate ; But now he 's not so
lucky anymore. Average Case complexity is equal to. . . the sum of the
run time for the total number of possibilities. The O ( Sum of all
possible run times divided by the number of possibility ) is O ( n ) The
average case complexity is the sum. Average Case is equal. to. . . The
sum of all. possible run. times divided. by the total. number of possible
run time. So for an array size of 5, We saw six cases. 't ' ; I 'll
calculate ' O ' later. n+1 If 'n ' is the size of the array , Then there
is 'n+1 '' number of possibilities. 'n' possibilities is when there is
1st element, 2nd element, 3rd element, 4th element, 5th element and 6th
element. If the element is here, How many comparisons will it have to
make ? It will have to do. . . 1. . . 2. . . 3 comparisons. I 've taken '
k ' as common out of everything. I removed this because this is
different. And this I have added separately.


K is an integer ) SO now I 'll write it like this K n ( K is an integer )
So now I 'll write it Like this K n ( K is an integer ) So now I 'll
write it like this. K n ( K is an integer ) And now what will happen? The
value of 'k ' will become very large And so 2n will be going down. The
graph of ( n^2+n ) ; graph of n ; graph of ( N^2+n ) will go below 2n.
THe Average Case Complexity for a given algorithm is the time it takes to
run through all possible cases, divided by the total number of
possibilities..?" This passage discusses Algo 2, which is a cunning
person who is smart. Birbal. Algo 2 says that he will not make useless
comparisons, and provides an example. An example of how he does this..
Algo 2 first takes the first and last element of an array, and then
compares them. IF. They match, Algo 2 is good; if they don't match., Algo
2 will find the mid--point of the array and be okay..


AP is Arithmetic Progression and GP is a geometric progression. AP is
used in 'O ' a lot. APs are made as well as GPs sometimes. When there are
questions on 'O' APs and GPs are used in the answers to questions on O.
The formula of Average Case Complexity is All possible run times divided

Written for

Course

Document information

Uploaded on
April 4, 2023
Number of pages
3
Written in
2022/2023
Type
OTHER
Person
Unknown

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
muhammadharoon3

Also available in package deal

Get to know the seller

Seller avatar
muhammadharoon3 Exam Questions
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions