1 algorithm for any topic
Answers
Explanation:
Analysis of Algorithms:
Asymptotic Analysis
Worst, Average and Best Cases
Asymptotic Notations
Little o and little omega notations
Lower and Upper Bound Theory
Analysis of Loops
Solving Recurrences
Amortized Analysis
What does ‘Space Complexity’ mean?
Pseudo-polynomial Algorithms
NP-Completeness Introduction
Polynomial Time Approximation Scheme
A Time Complexity Question
Time Complexity of building a heap
Time Complexity where loop variable is incremented by 1, 2, 3, 4 ..
Time Complexity of Loop with Powers
Performance of loops (A caching question
Let’s look at a very simple algorithm called find_max().
Problem: Given a list of positive numbers, return the largest number on the list.
Inputs: A list L of positive numbers. This list must contain at least one number. (Asking for the largest number in a list of no numbers is not a meaningful question.)
Outputs: A number n, which will be the largest number of the list.
Algorithm:
Set max to 0.
For each number x in the list L, compare it to max. If x is larger, set max to x.
max is now set to the largest number in the list.
An implementation in Python:
def find_max (L):
max = 0
for x in L:
if x > max:
max = x
return max
Does this meet the criteria for being an algorithm?
Is it unambiguous? Yes. Each step of the algorithm consists of primitive operations, and translating each step into Python code is very easy.
Does it have defined inputs and outputs? Yes.
Is it guaranteed to terminate? Yes. The list L is of finite length, so after looking at every element of the list the algorithm will stop.
Does it produce the correct result? Yes. In a formal setting you would provide a careful proof of correctness. In the next section I’ll sketch a proof for an alternative solution to this problem.
hope this helps you
pleeeaaassseee
mark as BRAINLIEST