What is Linear Time Complexity – O(n)? Linear time complexity, denoted as O(n), means that the execution time of an algorithm increases in direct proportion to the size of the input. If the input doubles, the time taken by the algorithm will also rou...
Let’s start with an example of constant time complexity C++ Code Example: Constant Time #include <iostream> using namespace std; int main() { int x, y, z; // Step 1: Variable declaration z = x + y; // Step 2: Addition opera...
Understanding Constant Time Complexity – O(1) When you're learning Data Structures and Algorithms (DSA), one of the first concepts you'll hear about is time complexity — a way to describe how fast or slow a program runs depending on the size of the i...
From Linear to Quadratic Time Complexity Quadratic Equation Example: Let’s take this equation: f(n) = 2n² + 3n - 5 Now plug in a large value, like n = 3000: f(3000) = 2(3000)² + 3(3000) - 5f(3000) = 18,000,000 + 9000 - 5 = 18,008,995 As you can s...
Sure! Here's a beginner-friendly article on Time Complexity, explaining the concept in simple terms with examples: Understanding Time Complexity: A Beginner’s Guide If you’re new to programming, you’ve probably heard terms like “Big O”, “Time Comple...
Why Writing 100 Lines of Code Can Be Better Than Just 2 When you're learning programming, or even after years of experience, there's always a temptation to write code that's short and clever. It feels cool to solve a problem in just 2 lines. But some...
💡 tl;dr - certain action is done by pre-processor before actual complilation of source code. The goal is to share: what is Preprocessor Directive in C & C++ and what are the different ways we use it. I’m writing this ‘blog’ today 2 February 2025 b...