Understanding and Calculating Time and Space Complexity
Algorithm Efficiency
Algorithm efficiency is measured in two dimensions: time efficiency and space efficiency.
Big O Notation
Big O notation mathematically describes the asymptotic behavior of a function. It provides an estimation of an algorithm's growth rate. The rules for deriving Big O are:
Replace all additive constants in the runtime fun ...
Posted on Sun, 17 May 2026 01:01:04 +0000 by janderson
Understanding Algorithm Efficiency and Data Structures
Problem Statement
Consider the following problem: Find all possible combinations of a, b, and c such that a + b + c = 1000 and a^2 + b^2 = c^2 (where a, b, and c are natural numbers).
Initial Attempt
import time
start_time = time.time()
# Note: triple loop
for a in range(0, 1001):
for b in range(0, 1001):
for c in range(0, 1001):
...
Posted on Fri, 15 May 2026 15:21:00 +0000 by noblegas
Implementing Bubble Sort in C
Bubble Sort operates by repeatedly comparing adjacent elements in an array and swapping them if they are in the wrong order. This process is repeated until the entire array is sorted, with larger elements gradually moving towards the end like bubbles rising to the surface.
Bubble Sort is suitable for small datasets or partially sorted data and ...
Posted on Thu, 14 May 2026 05:23:15 +0000 by joviyach