Algorithm
Algorithm
Characteristics of an Algorithm?
Time Complexity
• The time taken by a program is the sum of the compiled time & the run time. The
time complexity of an algorithm is given by the number of steps taken by the
algorithm to compute the function it was written for.
Space Complexity
• The total time is found by adding the times for all statements
What is Sorting?
Selection Sort
• The main idea of selection sort is to scan the entire given list to find its smallest
element and exchange it with the first element, putting the smallest element in
its final position in the sorted list. And repeat this operation until we sort all the
list
• The bubble sort algorithm makes several passes through the array. On each
pass, successive neighboring pairs are compared. If a pair is in decreasing order,
its values are swapped; otherwise, the values remain unchanged
Merge Sort
Quick Sort
Insertion Sort
Linear search
Binary Search
• This type of searching algorithm is used to find the position of a specific value
contained in a sorted array.
• The binary search algorithm works on the principle of divide and conquer and it
is considered the best search algorithm because it's faster to run.
• Depth First Search (DFS) is a recursive algorithm for exploring all vertices of a
graph or tree.
• Traversal refers to visiting all the nodes in a graph.
• This algorithm explores the graph in a depthward manner and uses a stack to
keep track of the next vertex to visit when a dead end is reached.
Exhaustive Search
Dynamic Programming
Recursion
• A technique where a function calls itself to solve a smaller instance of the same
problem.
Program