Practice

Practice 1

Label the running time of each line (use comment) of the template code in Big-O in terms of the input, and at the end (use comment) put the running time of the whole program in Big-O in terms of the input. The input of the problem is ex_list, and assume it has n elements. The first two lines will be done for you as an example.

💻 Template code

Solution code

Practice 2

Label the running time of each line(use comment) of the following code in Big-O in terms of the input, and at the end(use comment) put the running time of the whole program in Big-O in terms of the input. The input of the problem is ex_list, and assume it has n elements. The first two lines will be done for you as an example. Hint: Tricky case.

💻 Template code

Solution code

Practice 3

Label the running time of each line(use comment) of the following code in Big-O in terms of the input, and at the end(use comment) put the running time of the whole program in Big-O in terms of the input. The input of the problem is ex_list, and assume it has n elements. The first two lines will be done for you as an example.

💻 Template code

Solution code

Practice 4

Label the running time of each line(use comment) of the following code in Big-O in terms of the input, and at the end(use comment) put the running time of the whole program in Big-O in terms of the input. The input of the problem is ex_list, and assume it has n elements. The first two lines will be done for you as an example. Note: You will be surprised!

💻 Template code

Solution code

Practice 5

Label the running time of each line(use comment) of the following code in Big-O in terms of the input, and at the end(use comment) put the running time of the whole program in Big-O in terms of the input. The input of the problem is ex_list, and assume it has n elements. The first two lines will be done for you as an example. This problem assumes you have knowledge of 2D Lists.

💻 Template code

Solution code

Previous Section

15.7 Tricky Cases

Next Chapter

Ch. 16 Selection Sort

<aside> ⚖️ Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License.

If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact [email protected] for inquiries.

</aside>