Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Sprint 1

Learning Objectives:

  • Identify areas of inefficiency that contribute to higher time or space complexity
  • Refactor the code to reduce its complexity.

There are some common programming tasks in this folder. The same tasks are provided in both JavaScript and Python. You should solve each task in one language. We recommend you pick some tasks in each language.

For each task you undertake:

  1. Identify the section(s) of code that contribute to the complexity of the code.
  2. Explain the complexity using Big O notation.
  3. Identify whether the complexity can be reduced. If so, refactor the code to reduce its complexity. If you don't think the complexity can be reduced, explain why not in a comment.
  4. Provide the refactored code and briefly set out the complexity of your refactor.

Running Tests

Python Tests

First, create and activate a virtual environment:

python3 -m venv .venv
source .venv/bin/activate

Then install dependencies:

pip install -r requirements.txt

Run tests:

# Run all tests once
pytest -v

# Run all tests in watch mode (auto-rerun on file changes)
pytest -v --watch

JavaScript Tests

Navigate to the JavaScript directory first.

# Run all tests once
npm run test

# Run all tests in watch mode (auto-rerun on file changes)
npm run test:watch

Resources

Tip

Big-O notation focuses on the dominant trend of how resource usage grows as the input size n gets very large. It simplifies things by ignoring constant factors (multipliers) and lower-order terms.

For example, an algorithm that takes 2n steps and another that takes n steps are both considered O(n) (Linear Time). Why? Because as n gets huge, both grow directly in proportion to n. The factor of 2 doesn't change the fundamental linear growth pattern.

Similarly, if you have two separate loops, each running n times (total 2n steps), the complexity is still O(n). This is different from nested loops, where one loop runs n times inside another loop that also runs n times, leading to n * n or O(n²) complexity.