Datastructure and algorithm fundamentals
Datastructure and algorithm fundamentals
EXAMINER: ......................................................
Date:....../12/2024
Instructions:
Addition instruction:
1)
a) Convert 111 110 000 from base 2 to base 8
b) Convert 193 from base 10 to binary
c) Convert 1011 1110 0000 1001 from base 2 to base 16
2) A well-defined algorithm include the qualities of good algorithm. As a programmer what
do you consider as quality of good algorithm.
3) An operator is a symbols that tell compiler to perform specific mathematical or logical
manipulations. Match the following operator with their respective categories
Page 1 of 4
Operator Categories
?: Arithmetical
*+% logical
/=,^= conditional
==,!= Compound
|||&|& Relational
4) A given the following illustration of Boolean logical gates complete the truth table
INPUT OUTPUT
A B AND NAND OR NOR EXOR EXNOR
0 0
0 1
1 0
1 1
5) Analyze the following Boolean algebra and then try to simplify (i) and (ii)
I. (A+B)(A+C)=AA+AC+AB+BC (2.5marks)
II. AB+A(B+C)+B(B+C)=AB+AB+AC+BB+BC (2.5marks)
6) Write an algorithm to read n number of values in an array and display them in reverse order.
Find the output of the following program: If the value of a=20, b=3, what will be the value of the
sum? (5marks)
7) Demonstrate (show) by the truth table the following De Morgan theorems. 5Marks
Page 2 of 4
a.
b.
8) Copy and complete the following table (5marks)
Name of the symbol Diagram Description
……………………. …………………..
…………………….. ……
…………………….
9) Write an algorithm which receives student note and it displays the grade as follows:
5Marks
Note form 16 and above: Grade A
Note 14-16 : Grade B
Note 12-14 : Grade C
Note below 12 : Grade D
10) Write an algorithm which receives a number and informs the user whether it is positive
or negative. 5Marks
1) Write algorithm and the flowchart for the problem that allow the user to input three
numbers and display the sum, the average and the product of them. (10marks)
2) Compare for loop with while loop. (10marks)
3) Write an algorithm that allows the user to input the positive number and displays the
sum of positive numbers up to that number.
4) White a pseudocode to keep asking for a number less than 100 and stop when the
number is multiple of 3, 5, and 7. (Hint: Use while loop). (10marks)
Page 3 of 4
End!
Page 4 of 4