0% found this document useful (0 votes)
104 views5 pages

Exam Paper C 2022S1

This document contains instructions for a data structures and algorithms exam. It consists of 5 sections - preparation instructions, a theory section with 3 questions, a practical programming section with 2 questions, and a final section on marking and submission. Students are expected to answer all questions in the allotted time of 4 hours, showing work where required. They will complete questions in both an answer book and by submitting computer code and output files. The exam covers topics like data structures, graphs, trees, hashing, and stack and queue implementations.

Uploaded by

somto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views5 pages

Exam Paper C 2022S1

This document contains instructions for a data structures and algorithms exam. It consists of 5 sections - preparation instructions, a theory section with 3 questions, a practical programming section with 2 questions, and a final section on marking and submission. Students are expected to answer all questions in the allotted time of 4 hours, showing work where required. They will complete questions in both an answer book and by submitting computer code and output files. The exam covers topics like data structures, graphs, trees, hashing, and stack and queue implementations.

Uploaded by

somto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Student Number

Surname & Initials

YEAR: 2022
SEMESTER: 1
ASSESSMENT: C

SUBJECT NAME: DATA STRUCTURES AND ALGORITHMS V

SUBJECT CODE: DTD117V


QUALIFICATION(S): ADRS20 ADVANCED DIPLOMA IN COMPUTER SCIENCE

PAPER DESCRIPTION: COMPUTER DURATION: 4 HOURS PAPER: ONLY


BASED

SPECIAL REQUIREMENTS
 NONE
 NON-PROGRAMMABLE POCKET CALCULATOR
 SCIENTIFIC CALCULATOR
 COMPUTER ANSWER SHEET
 GRAPH PAPER
 DRAWING INSTRUMENTS

OTHER: COMPUTER
ANSWER BOOK

INSTRUCTIONS TO CANDIDATES: ANSWER ALL QUESTIONS

THIS TEST IS TO BE ANSWERED ON PC AND ON ANSWER BOOK.


WHEN YOU ARE DONE, GIVE YOUR ANSWER SCRIPT BACK TO THE
INVIGILATOR AND SUBMIT YOUR FILE.

TOTAL NUMBER OF PAGES INCLUDING COVER PAGE: 5

TOTAL NUMBER OF ANNEXURES: 0

EXAMINER: Dr Ntsako Baloyi FULL MARKS: 100

MODERATOR: Ms Mpho Nkosi TOTAL MARKS: 100


STUDENT TOTAL: ___
STUDENT %: ___

1 DTD117V – Paper C (2022S1)


Preparation

Theory
a. Use the answer book to answer questions.
b. Show all steps where applicable.
c. Write legibly

Practical
a. Use Java/C++ to create the programs required in section 2
b. Write your code legibly and provide comments
c. To evidence your output, capture the output of all the various functionality requirements into a word
document (correctly numbered) and save it as PDF at the end.
d. You are then required to put the PDF output file and the associated code into a zip file and send to Lecture PC.

2 DTD117V – Paper C (2022S1)


Section A – Theory [50]

Question 1 [15]

1.1 Identify the following structures and briefly describe their characteristics.
1.1.1 (3)

1.1.2 (3)

1.1.3 (3)

1.2 What is the formula for determining the position of the left child node? (3)

1.3 At what point or position does the deletion of elements in a heap tree take place from? (1)

1.4 When is a binary search best applied? (2)

Question 2 [10]

2.1 Define a data structure. (3)

2.2 Which data structure uses a Last in First out (FIFO) approach? (1)

2.3 The Department of Chaos want to implement a ticketing system to manage operations for people coming in
to receive services. The ticketing system needs to take into account people with special circumstances.

2.3.1 Which data structure would be Most appropriate? (2)

2.3.2 Why did you choose the data structure above? (2)

2.3.3 What are the two different types of ordering approaches with the data structure chosen?
(2)
3 DTD117V – Paper C (2022S1)
Question 3 [25]

3.1 Present the following graph in an adjacency matrix. (10)

3.2 Use Huffman encoding to compress the text below. Show all the steps. (10)

For each character show the encoding.


Text:
MISSISSIPPI

3.3 Discuss two methods that can be used to resolve collisions in hash tables. (5)

Section B – Practical/Programming [50]

Question 4 [20]

4.1 Turn the steps below into java code to implement the AVL Tree Insertion by using the recursive Binary Search
Tree. (20)

4.1.1 Perform the normal BST insertion. (4)


4.1.2 The current node must be one of the ancestors of the newly inserted node. Update the height of
the current node. (3)
4.1.3 Get the balance factor (left subtree height – right subtree height) of the current node. (3)
4.1.4 If balance factor is greater than 1, then the current node is unbalanced and we are either in Left-
Left case or Left-Right case. To check whether it is Left-Left case or not, compare the newly
inserted key with the key in left subtree root. (3)
4.1.5 If balance factor is less than -1, then the current node is unbalanced and we are either in Right-
Right case or Right-Left case. To check whether it is Right-Right case or not, compare the newly
inserted key with the key in right subtree root. (3)
4.1.6 Use the following input to test the code: 10, 20, 30, 40, 50, and 25. Capture a screenshot of the
output and submit it together with the code. (4)

4 DTD117V – Paper C (2022S1)


Question 5 [30]

Develop a java program that uses two integer stack data structures. The main stack should be called OddNum and
the second should be called Temp. Perform the following operations:

5.1 Create and initialise the OddNum stack with the following values: 55, 47, 91, 39, 21, 13, 7, and 15 using the
appropriate function. Each initialisation operation should display a message such as “value XX added into
stack OddNum”. (5)

5.2 Display the list of values in the OddNum stack. (2)

5.3 Delete value 21 from the OddNum stack. For each operation resulting in the deletion and restoration of the
stack, display a message to that effect. You may need to also utilise the Temp stack for this operation.
(7)

5.4 Increment the value 7 by 4. Use display messages to show each operation on the relevant stack or stacks.
(4)

5.5 Swap the values 39 and 15. (7)

5.6 Display the values in the OddNum stack. (2)

5.7 Ensure that the program is well written, properly commented and the output neatly displayed. (3)

The End

5 DTD117V – Paper C (2022S1)

You might also like