As a new engineer on the performance optimization team, your job is to evaluate common algorithms not just for correctness, but for how well they scale. In this assignment, you’ll implement several small functions and assess their performance in terms of time and space complexity.
Each function includes a prompt and space for your analysis.
This file contains five algorithmic challenges. For each one, you are expected to:
- Write a working implementation using Python
- Define your own test cases and verify that your code works
- Complete the performance analysis block below your function
- Best-case, worst-case, and average-case time complexity
- Space complexity
- Justification of your approach and possible optimizations
-
Find Most Frequent Element
Return the value that appears most frequently in a list. -
Remove Duplicates While Preserving Order
Remove duplicate values while keeping the original order. -
Return All Pairs That Sum to Target
Find all unique pairs of numbers that add up to a given target. -
Simulate List Resizing
Model how lists grow dynamically and analyze amortized time complexity. -
Compute Running Totals
Return a new list where each item is the sum of all values up to that index.
- Edit the
performance_lab.py
file directly. - Add test cases using
print()
or assert statements to confirm correctness. - Fill out the analysis block after each function with your complexity breakdown.
- Use your understanding of core operations (insert, delete, access, traverse) and structure trade-offs from earlier units.
When complete:
-
Save and commit your work using Git
-
Push to GitHub using:
git add . git commit -m "Completed performance lab" git push
-
Submit your repository link on Learn.