Skip to content

Instantly share code, notes, and snippets.

View tparveen's full-sized avatar

Tauhida Parveen tparveen

View GitHub Profile
@tparveen
tparveen / Big_O_practice.md
Last active July 10, 2021 00:03
Big O exercises

Exercise: What's the complexity?

Implement the following algorithms and analyze its expected (average) and worst run time complexities. You should work through the functions one by one, making comments and identifying the complexity of each part of the algorithm. If you are unsure of how the algorithms scale, then try adding counter variables and incrementing them each time an operation takes place. By logging out the counters for different sizes of input you should be able to see a trend developing.

Exercise 1:

Write a program that determines if an input is even or odd. Explain its average and worst run time

Exercise 2:

Write a program that doubles every value in an array. Explain its average and worst run time