Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions en/complexity/space-complexity.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Space complexity is the amount of memory that a program takes to run with respec
In this chapter, we will learn about the following space complexities:

- O(n) - linear space complexity
- O($n^2$) - quadratic space complexity
- O(n^2) - quadratic space complexity
- O(1) - constant space complexity

### **Linear Space Complexity: O(n)**
Expand All @@ -33,7 +33,7 @@ console.log(squareElements(myArray)); // Output: [1, 4, 9, 16, 25]
In this example, the space complexity is O(n) because the result array grows in proportion to the size of the input array `arr`.


### Quadratic Space Complexity (O($n^2$))
### Quadratic Space Complexity (O(n^2))
The memory required grows proportionally to the square of the input size.

**Example:**
Expand Down Expand Up @@ -70,3 +70,4 @@ printCube(3); // Output: 27
```

The space required does not depend on the input size.

Loading