An algorithm is a step-by-step procedure used to solve a problem. It takes input, processes it, and produces the desired output.
Algorithms are the foundation of programming and are used in solving real-world computational problems efficiently.
Pseudo code is a simple way of writing algorithm logic using plain English-like statements.
Example (If-Else):
IF number > 0
PRINT "Positive"
ELSE
PRINT "Negative"
END IF
Example (Loop):
FOR i = 1 TO n
PRINT i
END FOR
Time Complexity:
Sorting algorithms arrange data in a particular order (ascending or descending).
Used to analyze performance of algorithms for large inputs.
Works on sorted array. Divide array into halves.
Steps:
Time: O(log n)
Divide array into parts and compare results.
Steps:
Steps:
Time: O(n log n)
Steps:
Best: O(n log n), Worst: O(n²)
Efficient matrix multiplication using divide & conquer.
Steps:
Time: O(n^2.81)
Greedy algorithm selects the best choice at each step without considering future consequences.
Steps:
Type: Fractional
Steps:
Steps:
Steps:
Find shortest route visiting all cities once.
Store programs in increasing order of length.