Homework 6
1) Write a while loop that prints out the numbers 1 - 10.
x=1
while x < 11:
print x
x=x+1
2) Write a repeat until loop that prints out the numbers 1-10.
x=1
repeat:
print x
x=x+1
until x > 10
3) Problem 6 on page 251
Because there is no initial
HOMEWORK 5
6. The CSMA/CD protocol is not applicable in a wireless network because all machines
communicate with each other via a central AP as a machine may not be able to detect a collision.
If CSMA/CD is used, when the medium detect a collision, the en
Homework 7
8. Rewrite program segment using a while structure:
count = 1
while (count < 5):
print (count)
count = count + 1
48. Binary search: least case: 1
Worst case: 11< log base 2 of 4000 <12
We have that the largest number of entries is 12.
Sequenti
CSC-208
Home Work 2
Solutions
1. Write an algorithm that returns the index of the first occurrence of the value key
in the sequence s1,s2 ,s3 ,.sn . If the key is not in the sequence, the
algorithm returns the value of 0. Example
CSC-208
Homework-3
Solutions
1. A man has eight shirts, four pairs of pants, and five pairs of shoes. How
many different outfits are possible?
8*4*5=160
2. How many times are the print statements executed?
For i = 1 to m
println(i)
For j =1 to n
println(j