Algorithms
Algorithms
Types of Algorithms
Divide and Conquer: Breaks the problem into smaller sub-problems, solves
them independently, and combines the results.
Greedy Algorithm: Makes the best local choice at each step, aiming for a
global optimum.
Sorting Algorithms:
Quick Sort: Partitions the array into subarrays and sorts recursively.
Searching Algorithms:
Graph Algorithms:
Breadth-First Search (BFS): Explores all neighbors at the current depth before
moving deeper.
Time Complexity
Space Complexity
Examples
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n - 1)
if arr[mid] == target:
return mid
left = mid + 1
else:
right = mid - 1
return -1
Applications of Algorithms