MG - Algorithms Fundamentals 2019
MG - Algorithms Fundamentals 2019
Ministry of Education
TVET NATIONAL COMPREHENSIVE ASSESSMENT
ACADEMIC YEAR 2019
Page 1 of 13
c) Pseudo code
d) Syntax
6. From the following sorting algorithms which algorithm needs the minimum
number of swaps?
a. Bubble sort
b. Quick sort 2Marks
c. Merge sort
d. Selection sort
7. From the following sorting algorithms which has the lowest worst case complexity?
a. Bubble sort
b. Quick sort 2Marks
c. Merge sort
d. Selection sort
8. What are the difference between compiler and interpreter? 6Marks
9. In data structure, there are two types of searching techniques. List and explain
them. 4Marks
10. Demonstrate (show) by the truth table the following De Morgan theorems.
5Marks
a.
b.
11. Write an algorithm which receives a number and informs the user whether it is
positive or negative. 5Marks
12. 12. (a) Convert 62010 into hexadecimal 3Marks
(b) Convert 11101001102 into hexadecimal 3Marks
13. 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
……………………. …………………..
…………………….. ……
…………………….
16. 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
17. List any five-logic gate by drawing its symbols. 10Marks
18. Describe five qualities of good algorithm 10Marks
19. (a) List any five operators available in algorithm 5marks
(b) What are the main difference between primitive and non-primitive data
types? 5Marks
20. Write an algorithm allows entering a number of students in a class and the
marks obtained by those students, then calculate the sum of those marks and
their average and display the number of students, the marks, sum and average on
the screen. 15Marks
21. Write an algorithm to find the largest among three different numbers entered
by user. 15Marks
Page 3 of 13
MAKING GUIDE:
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
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
Page 4 of 13
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 5 of 13
Linear search: In this technique of searching, the element to be found in searching the
elements to be found is searched sequentially in the list. This method can be performed on
a sorted or an unsorted list 1mark
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
620
2Marks
Then, the answer will be written from right to left like this: 62010 = (26C)16 1Mark
Page 6 of 13
(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.
Start
Read(Note)
Else
End if
end
14. Bubble Sort Algorithm is used to arrange N elements in ascending order, and for that,
you have to begin with 0th element and compare it with the first element. If the 0 th element
is found greater than the 1st element, then the swapping operation will be performed, i.e.,
Page 7 of 13
the two values will get interchanged. In this way, all the elements of the array get
compared. 2Marks
15.
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
Page 8 of 13
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
Begin
Read num1,num2,num3
sum ←num1+num2+num3
ave ←sum/3
sum ←num1*num2*num3
End
1Mark
b. XOR 1Mark
1Mark
c. NOT 1Mark
1Mark
Page 9 of 13
d. NOR 1Mark
1Mark
e. XNOR 1Mark
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 10 of 13
Primitive types are predefined (already defined). Non-primitive types are created by
the programmer and is not defined. 1mark
Non-primitive types can be used to call methods to perform certain operations, while
primitive types cannot. 1mark
A primitive type has always a value, while non-primitive types can be null. 1mark
A primitive type starts with a lowercase letter, while non-primitive types starts with
an uppercase letter. 1mark
The size of a primitive type depends on the data type, while non-primitive types have
all the same size. 1mark
20.
21.
START
Read (A,B,C)
Elseif (B>C)then
Else
End if
End
Page 12 of 13
Page 13 of 13