COMP152 - Homework 3
Due in-class on 2/28
- Do problems R-3.2, R-3.3, R-3.8, and R-3.29 through R-3.33 from the text. Be sure to justify your answer.
- Answer the following:
- How many times do you need to divide 482 by 2 to get a value less than 1?
- How many times do you need to divide 379 by 2 to get a value less than 1?
- If starting at 1, how many times would you need to double up to get to a value that is bigger than 1011?
- If starting at 1, how many times would you need to double up to get to a value that is bigger than 92?
- List the nearest integers (smaller and bigger) to the following: lg(25), lg(195), lg(15300), and lg(95127). Don’t use a calculator and remember that lg is logarithm in base 2.
- What is the time complex of the following code fragments? For each fragment the variable alist is list data.
1.
for el in alist: ...
2.
for i in range(len(alist)): el = alist[i] ...
3.
for i in range(0,len(alist)): for j in range(i,len(alist)): ...