You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compilation:
i. Make sure that VS code program has been installed and the python extension was inputted
ii. Create a folder named CC11l_Lab01
iii. On the same folder, create a file name "main.py"
iv. Type the code on the file created.
Running the Program: Save the file and click the "Run Python File" button on the right side of the VS code program.
Complexity Notes
In a sentence, justify O(n) time for find_max and linear_search.
O(n) time is taken on by both the find_max and linear_search because in the worst case, every cell must be examine so the running time grow linearly along with the amount of element.
Is there any case they run faster than O(n) worst-case? (Hint: best-case for search if found at index 0.)
For the find_max, there's no case that it can run faster than the worst-case because it needs to iterate all the cells in an array to provide a reliable answer. However, there is a possibility to run faster than the worst-case in linear_search as long as the number being search is not on the last cell of the array.
Notes
Language used:PythonCompilation:i. Make sure that VS code program has been installed and the python extension was inputted
ii. Create a folder named CC11l_Lab01
iii. On the same folder, create a file name "main.py"
iv. Type the code on the file created.
Running the Program:Save the file and click the "Run Python File" button on the right side of the VS code program.Complexity Notes
In a sentence, justify O(n) time for find_max and linear_search.Is there any case they run faster than O(n) worst-case? (Hint: best-case for search if found at index 0.)