Programming Algorithms and Data Structures

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

UGANDA BUSINESS AND TECHNICAL EXAMINATIONS

BOARD

PAPER CODE PROGRAMME DATE


TDIT124 NATIONAL DIPLOMA IN INFORMATION TUESDAY,
AND COMMUNICATION TECHNOLOGY 12TH DECEMBER 2023
YEAR ONE SEMESTER TWO

SERIES PAPER NAME TIME ALLOWED


NOV/DEC 2023 PROGRAMMING ALGORITHMS AND 3 HOURS
DATA STRUCTURES

YOU SHOULD HAVE THE FOLLOWING FOR THIS EXAMINATION


Answer Booklet
Drawing Instruments
Non-Programmable Calculator

INSTRUCTIONS TO CANDIDATES
1. This paper consists of eight questions.
2. Answer only five questions.
3. All questions carry equal marks.
4. All answers to each question should begin on a fresh page.
5. Do not write anywhere on this question paper.
6. All rough work should be done in the official answer booklet provided.
7. Read other instructions on the answer booklet.

© 2023 Uganda Business and Technical Examinations Board Turn Over


Question One
(a) Explain the importance of using a Stack in programming. (02 marks)
(b) Discuss six operations that can be applied on the Stack. (12 marks)
(c) The C++ code below employs both the programming objects of system stack
and function calls. Study the program and write down the output of the
program. (06 marks)
1. #include <iostream>
2. using namespace std;
3. void fun3()
4. {
5. cout << "fun2 line 2\n";
6. }
7. void fun2()
8. {
9. cout << "fun2 line 1\n";
10. }
11. void fun1()
12. {
13. cout << "fun1 line 1\n";
14. fun2();
15. cout << "fun1 line 2\n";
16. fun3();
17. }
18. int main()
19. {
20. cout << "main line 1\n";
21. fun1();
22. cout << "main line 2\n";
23. }

2
Question Two
(a) Study the program code below and write down its output. (10 marks)
1. #include <iostream>
2. using namespace std;
3. int main()
4. {
5. cout << boolalpha;
6. bool Result = false;
7. int y = 5;
8. Result = 7 || (y = 0);
9. cout << "Result of (7 || (y = 0)): " << Result
<< endl;
10. cout << "Value of y: " << y << endl;
11. int a, b, c;
12. a = b = c = 0;
13. Result = ++a || ++b && ++c;
14. cout << '\n';
15. cout << "Result = " << Result;
16. cout << ", a = " << a;
17. cout << ", b = " << b;
18. cout << ", c = " << c << endl;
19. a = b = c = 0;
20. Result = ++a && ++b || ++c;
21. cout << "Result = " << Result;
22. cout << ", a = " << a;
23. cout << ", b = " << b;
24. cout << ", c = " << c << endl;
25. return 0;
26. }
(b) Decision making is key to program flow in programming. One way programmers
dictate a program flow is by using Logical operators (Logical And, Logical Or and
Logical Not). Using the above operators, write down the output for the logical
operations given in the table below. (08 marks)

Turn Over
3
A B A && B A || B
TRUE TRUE
TRUE FALSE
FALSE TRUE
FALSE FALSE

(c) Discuss the functionality of a complement logical operator. (02 marks)

Question Three
The diagram below is a standard binary search tree where each key is greater than
the keys in its left subtree and smaller than the keys in its right subtree.

(a) Draw a reverse binary search tree. (05 marks)


(b) Draw the binary search tree that results from inserting the values 1 to 7 in each
of the following Orders (reading from left to right):
(i) 5376214 (05 marks)
(ii) 1234567 (05 marks)
(iii) 4352617 (05 marks)

Question Four
A student of Lora Technical created a list of songs in a playlist on his laptop. The
student repeatedly played songs in a playlist. The rewind and forward functions on a
playlist enabled him to navigate through songs and play his favourite choices. The
Circular double linked lists technology in Round Robin scheduling implemented the
functions in the playlist.
(a) With an illustration, describe the technology mentioned in the scenario above.
(06 marks)
(b) Using codes, demonstrate the following operations in the technology
mentioned in 5(a)
(i) Insertion Operation (07 marks)
4
(ii) Delete Operation (07 marks)

Question Five
(a) Define the term Hash Table as used in data structures. (02 marks)
(b) Explain five properties of a good hash function. (10 marks)
(c) Describe the process of storing objects using a hash function. (08 marks)

Question Six
(a) Identify the major data structures used in the following areas:
(i) RDBMS (02 marks)
(ii) Network data model (02 marks)
(iii) Hierarchical data model (02 marks)
(b) Draw the Binary Tree of order 3 created by inserting the following data arriving
in sequence – 92, 24, 6, 7, 11, 8, 22, 4, 5, 16, 19, 20, 78. (14 marks)

Question Seven
(a) Distinguish between a Constructor and a Destructor. (04 marks)
(b) Discuss three access class modifiers used in data structures and algorithm.
(06 marks)
(c) Samuel submitted his shopping list at the beginning of this new semester,
however, his parents are programming enthusiastic required him to write the
list using C++ putting into account the use of data structures and algorithms.
(i) Write down the algorithm that will simplify Samuel’s program.(04 marks)
(ii) Write down a C++ program to execute Samuel’s program. (06 marks)

Question Eight
(a) Describe the difference between Data Structures and Algorithm.(04 marks)
(b) Discuss four Data structures that are used in Object oriented Programming.
(08 marks)
(c) Explain the following terms;
(i) Encapsulation (02 marks)
(ii) Polymorphism (02 marks)
(iii) Inheritance (02 marks)
(iv) Abstraction (02 marks)

END

You might also like