PART I:
1. Explain why a computer cannot solve a problem for which there is no solution outside the computer.
2. Do some research and find out whether the Pascaline calculator is a computer according to the Turning model.
3. A computer uses isolated I/O addressing. Its memory has 1024 words. If each controller has 16 registers, how many controllers can be accessed by this computer?
4. Using the instruction set of the simple computer in section 5.7, write the code for a program that performs the following calculation:
D ←A+B+C
A, B, C and D are integers in two’s complement format. The user types the value of A, B, and C, and the value of D is displayed on the monitor.
5. Chapter 5, page 143: Exercise 54.
Using the instruction set of the simple computer in Section 5.7, write the code for a program that performs the following calculation:
B ← A-2
A and 2 are integers in two’s complement format. The user types value of A and the value of B is displayed on the monitor. (Hint: use the decrement instruction)
6. A multiprogramming operating system uses paging. The available memory is 60MB divided into 15 frames, each of 4MB. The first program needs 13MB. The second program needs 12MB. The third program needs 27MB.
a. How many frames are used by the first program?
b. How many frames are used by the second program?
c. How many frames are used by the third program?
d. How many frames are unused?
e. What is the total memory wasted?
f. What percentage if memory is wasted?
7. Compare and contrast 3 basic sorting algorithms.
8. Distinguish between compilation and interpretation.
PART 2
1. Using the product algorithm, make a table to show the value of the product after each integer in the following list is processed:
2 12 8 11 10 5 20
2. Using the FindLargest algorithm, make a table to show the value of the Largest after each integer in the following list is processed:
18 12 8 20 10 32 5
3. Using the bubble sort algorithm, manually sort the following list and show your work in each pass using a table.
14 7 23 31 40 56 78 9 2
4. A list contains the following elements. The first two elements have been sorted using the selection sort algorithm. What is the value of the elements in the list after three more passes of the selection sort?
7 8 26 44 13 23 98 57
5. Draw a UML diagram the bubble sort algorithm that uses two loops. The nested loop is used to swap adjacent items in unsorted sublist.
PART 3:
1. Write the code in exercise 29 (below) using a do-while loop.
For (int I = 5: i ˂ 20, I + +)
{
statement;
i = i + 1;
}
2. Write the code in exercise 30 using a for loop.
A = 5
Do
{
statement;
A = A + 1;
} while (A ˂ 10 )
3. Write a code fragment using a while loop that never executes its body.
4. Change the following segment of code to use a switch statement:
If (A= =4) statement1;
Else
If (A= = 6) statement 2
Else if (A= = 8) statement 3