Professional Documents
Culture Documents
Disadvantage
Microprogram relies on fast micro memory. It requires high speed memory.
3. Explain briefly how the buses are used for the communication between several components
of a computer (Example: CPU and memory) The bus provides a communication path for the
data and control signals moving between the major components of the computer system. bus is a
high-speed internal connection. Buses are used to send control signals and data between the
processor and other components. Address bus – carries memory addresses from the processor to
other components such as primary storage and input/output devices. The address bus is
unidirectional
1.1 MACHINE LANGUAGE Any computer can directly understand its own machine language. Machine
language is the “natural language” of a computer and such is defined by its hardware design. Machine
languages generally consist of strings of numbers (ultimately reduced to 1s and 0s) that instruct
computers to perform their most elementary operations one at a time
4. a. Define a recursive function.[1 points] public class RecursionExample3 {
static int factorial(int n){
if (n == 1)
return 1;
else
return(n * factorial(n-1));
}
public static void main(String[] args) {
System.out.println("Factorial of 5 is: "+factorial(5));
}}
5. Write a recursive function that computes the greatest common divisor (GCD/HCF) of two
positive integers. [5 points
6. #include <iostream>
7. using namespace std;
8.
9. int main() {
10. int n1, n2, hcf;
11. cout << "Enter two numbers: ";
12. cin >> n1 >> n2;
13.
14. // swapping variables n1 and n2 if n2 is greater than n1.
15. if ( n2 > n1) {
16. int temp = n2;
17. n2 = n1;
18. n1 = temp;
19. }
20.
21. for (int i = 1; i <= n2; ++i) {
22. if (n1 % i == 0 && n2 % i ==0) {
23. hcf = i;
24. }
25. }
26.
27. cout << "HCF = " << hcf;
28.
29. return 0;
30. }
6. Write a function that accepts a positive integer and displays the digits of the number in reverse
order.[3 points]
#include <iostream>
using namespace std;
int main() {
while(n != 0) {
remainder = n % 10;
reversed_number = reversed_number * 10 + remainder;
n /= 10;
}
return 0;
}
Step 1 - Consider the first element of the list as pivot (i.e., Element at first position in the list).
Step 2 - Define two variables i and j. Set i and j to first and last elements of the list respectively.
Step 3 - Increment i until list[i] > pivot then stop.
Step 4 - Decrement j until list[j] < pivot then stop.
Step 5 - If i < j then exchange list[i] and list[j].
Step 6 - Repeat steps 3,4 & 5 until i > j.
Step 7 - Exchange the pivot element with list[j] element
the greater the cohesion of each module in the system, the lower the coupling between modules
is.
Explain why a cache memory, in addition to RAM (or primary memory), is needed in computer systems.
(2 points)
Cache memory is important because it improves the efficiency of data retrieval. It stores program
instructions and data that are used repeatedly.
A computer’s memory is
composed of 8K words of 32 bits
each. How many bits are required
for memory
address if the smallest
addressable memory unit is a
word?
A computer’s memory is composed of 8K words of 32 bits each. How many bits are required for
memory address if the smallest addressable memory unit is a word?
Answ:13 bits is the correct option
1. 1k of memory is equivalant to 1024 bytes. Hence, 32k memory reprentss 32*1024=32768
bytes of memory.
2. One memory location occupies one Byte of memory so 32k memory (32768 bytes) will
be having a total of 32768 memory locations. So if 0000 (H) represents the first memory
location then the last location in deciaml number system would be 32767.
Decimal number can be easily converted to hexadecimal number system, for instance
hexadeciaml representation of 32767 will be 7FFF (H), where H reprents hexadecimal
representation. So the last memory location in hexadecimal of a 32k memory will be 7FFF
(H).
Expla 1GB = 1024MB. 1MB = 1024KB. 1kB = 1024 Bytes. 1 Byte = 8 bits.
Page -9-
iii. Cars with price greater than
Birr 280,000 are luxury cars. List
the customer number, name and
address of customers who have
ordered more than one luxury car.
(3 points)
Page -8-
Part III: Database Management Systems (20 points)
3.1 Based on the description given below, answer the questions that follow.
The Cheapest Car Company sells new and used cars from different makers such
as Ford, Volvo and Toyota
and of different models such as Camry, Falcon, Corolla, Carina. custNo,
serialNo and staffNo are the sole
keys of Customer, Car and Staff, respectively. Customers make orders to buy
cars; a customer can make
several orders. Each order has a unique order number (orderNo) and only one
car is ordered in one order.
An order is processed by one staff member.
Customer(custNo, custName, street, city, postcode)
Car(serialNo, model, year, maker, price)
Staff(staffNo, staffName, position)
Order(orderNo, staffNo, date, custNo, serialNo, amount_paid)
Attribute amount_paid of relation Order is the amount that a customer pays for
an order; a Customer may
not pay in full for the order. The other attributes are self-explanatory.
a. Discuss the likely Functional Dependencies in Order. (2 points)
b. Give the foreign keys in Order and the relevant referential integrity
constraints. (2 points)
A ticket line;
An escalator;
A car wash.
A printer queue;
An input stream;