Algorithm Fundamentals Answers
Algorithm Fundamentals Answers
Ministry of Education
TVET NATIONAL COMPREHENSIVE ASSESSMENT
ACADEMIC YEAR 2019
01.Define:
a. Algorithm: is a sequence of unambiguous instructions for solving a
problem.
Is just a detailed sequence of simple steps that are needed to solve a
problem. 1.5Marks
b. Flowchart: is a diagrammatic representation that illustrates the
sequence of operations to be performed to get the solution of a problem.
Or
Page 1 of 10
Is a graphical representation of an algorithm. 1.5Marks
c. Variable: A variable is the name for a place in the computer's memory
where you store some data. Or
A symbolic name associated with a value and whose associated value
may be changed. 1.5Marks
d. Loop: loop is a way of repeating a statement a number of times until
some way of ending the loop occurs. 1.5Marks
e. Array: a data structure used to store items having the same type.
1.5Marks
04. The difference between the while and do-while loop is in the place where
the condition is to be tested. In the while loop, the condition is tested following
the while statement and then the body gets executed. Whereas as in do-while,
the condition is checked at the end of the loop.
The do while loop will execute at least one time even if the condition is false
initially, the do while executes until the condition becomes false. 4Marks
Page 2 of 10
06. (d) or Selection sort 2marks
07. (c) or Merge sort 2marks
08.
Compiler Interpreter
Binary search is a very fast and efficient searching technique. It requires the
list to be in sorted order. In this method, to search an element you can
compare it with the present element at the center of the list 1mark
5marks
Page 3 of 10
11.. Variable a: integer 0.5mark
START
WRITE (“enter a number”) 0.5 mark
READ (a) 0.5mark
IF (a>0) THEN 1mark
WRITE (“the number is positive”) 0.5mark
ELSE 1mark
WRITE (“ the number is negative”) 0.5mark
END IF 0.5mark
END
12. (a) 62010 = ( )16
620
2Marks
Then, the answer will be written from right to left like this: 62010 = (26C)16
1Mark
(b) 11101001102 =( )16 Here we have to make (form) the groups of 4 digits
each, from right to left. If it is necessary, we add the zeros on the last group
where the bits are less than 4. Lastly, we translate every quadruple to its
equivalent hexadecimal.
Page 4 of 10
= 3A616 1mark
Start
Read(Note)
Else
End if
end
15.
Page 5 of 10
Name of the symbol Diagram Description
16. Algorithm:
Variables num1, num2, num3, sum, Ave, product: integers
0.5marks
BEGIN
WRITE ("Enter three numbers :”) 0.5marks
READ (num1, num2, num3)
sum ←num1+num2+num3 1mark
ave ←sum/3 1mark
product←num1*num2*num3 1mark
WRITE ("the sum of ”, num1,num2 ,” and ”,num3,” is ”, sum, ”
their average is ”, ave, ” and their product is ”, product) 1mark
END
Flowchart: 5Marks
Page 6 of 10
17. Draw the logical symbols of gates:
a. AND: 1Mark
1Mark
b. XOR 1Mark
1Mark
c. NOT 1Mark
1Mark
d. NOR 1Mark
1Mark
e. XNOR 1Mark
Page 7 of 10
1Mark
18. Qualities of good algorithm:
a)Input: 1Mark the algorithm must take zero or more input. 1Mark
b) Output: 1Mark the algorithm may produce one or more outputs. 1Mark
a) Arithmetic operators
b) Relational operators
c) Logical operators
d) Assignment operators
e) Increment &decrement operators
f) Conditional operators
g) Bitwise operators
h) Special operators
(b)The main difference between primitive and non-primitive data types are:
Page 8 of 10
A primitive type has always a value, while non-primitive types can
be null. 1mark
The size of a primitive type depends on the data type, while non-primitive
types have all the same size. 1mark
20.
Page 9 of 10
21.
START
Read (A,B,C)
Elseif (B>C)then
Else
End if
End
Page 10 of 10