Algorithm, Complexity Analysis and Notation
The algorithm is a step to do a job. Every day we are the usage of thousands of algorithms, unbeknownst to themselves. From faculty to home? Think of it the least time to go when you go on a road. This is also an algorithm.
There was algorithm even earlier than the computer was discovered. Although we now recognize the algorithm, it is a concern of laptop science. Basically it is a branch of mathematics. Simply put, the algorithm is the mathematical approach to resolve a problem. Take some records or parameters as an algorithm input. After that, after the required computations will give some output as return.
Let's begin with a easy problem. Can begin with the linear search algorithm. We have a list, where there are some numbers. We'll now find out if there is a wide variety in that list. Linear search, take the first number of the list, suit the variety with which you favor to find it. If it does now not match, then appear at the number in the list. When you get the match, the index index will return. I mean, how many indexes have been discovered in the index, that index. See the photograph below. Visual assessment of how linear search works.

Visual review of how linear search works.
Image source:
If we write this Pseudocode, it can be written in this way:
I have not said a little about the pseudocode. Pseudocode is not a genuine programming language code. The code that can easily be understood close to the computer language and the humans of the steps. They have no particular rules. And so maybe you can see the algorithm of one algorithm in one location at one place. If you look excellent then all algorithms all seem for the structure of the psudocodel is almost the same. And any algorithm can without difficulty be utilized to any langeway to see the pseudocode. To make it easier, let's say the steps of an algorithm can be written in the language of the pc language, so that it can be easier to put in force any language later on.
1.linear_search (list, value)
2. for each item in the list
3.if match item == value
4.return the item's location
5.end if
6.end for
7.end
We used the linear search algorithm to locate out if a wide variety is on the list. Now one trouble can be solved in greater than one way. That ability there may be many algorithms to clear up a problem. Which algorithm we use? Before we select an algorithm, we will dispose of many calculations before. Possib thinks all the algorithms. Find out how plenty time an algorithm will take, how plenty reminiscence it will take. Complexity evaluation is what it says. Then we use that little useful resource that the algorithm will take.
For example, the quantity that we'll find, will look at the first quantity of the array. If you see two numbers in the same number, then the range of the array in the array will return. The important algorithm can be implemented in C, C ++ or this type of language.
1.for (i=0; i<n; i++)
2. if (arr[i] == x)
3. return i;
Here the array initialization, no number will be found, it is now not written about, etc. The algorithm has been written as a good deal as it requires. If we follow the algorithm to locate out the algorithm of the computer, then we want some computer education to run it.
Instruction Counting:
One time to take one operation on one computer. For example, many of the historical low configurations will work very gradual on any computer. Again, the new high configuration will be eliminated faster on the computer. To solve this problem, we can set some values for an algorithm analysis. Such as:
I. An instruction to set the value to a variable
ii. An instruction to find value from an index of an array
iii. An instruction to compare between two values
iv. An instruction for an inimitable (i ++) or decryment (i) operation, etc.
As a result, there should be two instructions at the beginning of the for loop. An instruction for
i = 0 at the beginning and an instruction for i <n. The value of this n is the number of elements in an array, that is the value. Suppose that the miniamam has two values in the array.
After each iteration of the for loop, you need two instructions. One is for i ++. And an i
Two more instructions inside the for loop. One is to get the value of arr [i], the other is the comparison of the x. If there is n element in the list, then here we need 2n instructions.
So our total instructions are: 2 + 2n + 2n. If we think of a function, where n is required for our algorithm, then we get f (n) = 2 + 2n + 2n = 2 + 4n
Best-case analysis:
Suppose our list is arr = [4,3,6,8,1] and we want to figure out whether 4 is on this list. Now since we are doing a lonely search, we will get it at the beginning, there are 4 lists. Then our instruction will take 2 + 2 or four. Two Instructions at the beginning of the loop. And two instructions inside the loop. Then go out of the loop.
Worst-case analysis:
If our list is arr = [4,3,6,8,1], and we want to find out if 1 is on this list, then our system will require a lot more. Check each number once. Once in the last element, you will see 1 list.
The number that you are looking for will not be included in the list, but you can search all the elements. For example, if we want to find out if we have 5 lists, then it will take the same time. See each element once.
Asymptotic Notation:
We implemented the linear search algorithm in C. Here we have used the for loop. We have to process additional instructions for using the for loop. In other languages, this process may be done more easily, with fewer Instructions. Again, since one processor's processing power is the same, we can eliminate minor issues.
Now we look at our function f (n) = 2 + 4n. If there is a large number of such trillions, then 2 is smaller than that. Whatever the value of n, there is no change in 2. So we can exclude it. Now 4n here we can remove 4 again because it is Constant. Then we can write f (n) of our linear search compository function f (n) = n;
It is important to know that if we work with a for loop on any programming, then we may know that for a loop, it will be the highest n or To have another forlup inside a forlup, it will etterate maximum n * n or n2 times. If there are three forllups, the maximum n * n * n or n3 times will rotate.
Now if we give the answer of an algorithm, we get 8n + 5 then its asymptotic notation will be n. Asymptotic Notation of 2n2 + 8 would be n2 Asynptotic Notation of 4n3 + 9 will be n3
Asymptotic Notation is usually written as Θ (f (n)) asymptotic notation Θ (n) of our linear search algorithm. Theta of n is pronounced.
Tight Bound:
Asymptotic Notation, we need to take several instructions to process an algorithm. And for this it is called Tight Bound This means that if you see the complexity of an algorithm Θ (n), then this Θ (n) is the Tight Bound of those algorithms.
Big O Notation:
An algorithmic instruction or complexity is obtained by calculating f (n) = n. But it was found in the implementation that the n2 instruction may be required to run or algorithm to run. Then this n2 is called the Upper Bound of the algorithm. And it is released with Big O Notation. We usually think of the worst case. Therefore, an algorithmic compilation is usually published with Big O Notaion.
Different types of complexes
O (n) or Linear complexity: Instruction increases loneliness as input value (n) increases. Such as:
-1 item: 1 instruction
-10 items: 10 instructions
-100 items: 100 instructions
O (n2) or Quadratic complexity: Input item n can take the instruction n2. Such as:
- 1 item: 1 instrction
- 10 items: 100 instructions
- 100 items: 10000 instructions
O (1) or Constant complexity: Whatever the input, it will always require Constant Instruction. Such as:
1 item: 1 instruction
10 items: 1 instructions
100 items: 1 instructions
: Instructions will increase in logarithmic form as input items increase. Such as:
1 item: 1 instruction
10 items: 2 instructions
100 items: 3 instructions
1000 items: 4 instructions
10000 items: 5 instructions
The following topics are usually seen in the performance calculation of an algorithm
Completeness
Optimal or not
Time Complexity
Space Complexity
We can see the above topics to determine which algorithm we will use for a problem. Complutnance means whether our algorithm will give a solution. How long it takes, how much memory will take etc.
Some more articles related to this on next
i.Algorithm: Linear Search
ii.Algorithm: Bubble Sort
iii.Breadth First Search Algorithm - Breadth-first search
iv.Deepth First Search Algorithm - Depth-First Search
v.Recurrence / Recursion, Recursive Algorithm, Recursive Function and Applying at C Programming
vi.Linked List / Linked List Ideas and Implementation in C Programming
vii.Graph Theory, Graph Representation and Implementation
Posted on Utopian.io - Rewarding Open Source Contributors

@amulla505, Approve is not my ability, but I can upvote you.
Thank You so much @steemtstats
you are a moderator on utopian.io?
Sick post. I've looking for info on algo like this for weeks. Still lots of research to do by myself so maybe one day I can understand them better as they are a little bit hard for me now.
haha.
carry on you can understand very soon.
Your contribution cannot be approved because it does not follow the Utopian Rules.
Blog posts should be directly related to specific open-source projects. This topic is a general programming topic.
Thanks.
You can contact us on Discord.
[utopian-moderator]
This post has received a 0.60 % upvote from @booster thanks to: @amulla505.