0% found this document useful (0 votes)
22 views2 pages

University of Kwazulu Natal: School of Mathematics, Statistics & Computer Science

This document provides instructions for a practical exam on data structures. It lists 4 questions to answer involving stacks, queues, and priority queues. Question 1 has subparts to reverse elements in a stack using additional stacks or variables, and to sort stacks and queues. Question 2 checks for matching parentheses, braces, and brackets in code. Question 3 adds very large integers using a stack as shown in a figure. Question 4 implements a priority queue with a list. The document wishes students the best on the exam.
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)
22 views2 pages

University of Kwazulu Natal: School of Mathematics, Statistics & Computer Science

This document provides instructions for a practical exam on data structures. It lists 4 questions to answer involving stacks, queues, and priority queues. Question 1 has subparts to reverse elements in a stack using additional stacks or variables, and to sort stacks and queues. Question 2 checks for matching parentheses, braces, and brackets in code. Question 3 adds very large integers using a stack as shown in a figure. Question 4 implements a priority queue with a list. The document wishes students the best on the exam.
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/ 2

SCHOOL OF MATHEMATICS, STATISTICS &

COMPUTER SCIENCE

UNIVERSITY OF KWAZULU NATAL

WESTIVILLE CAMPUS

Practical IV

COURSE CODE: COMP201 Data Structures

Examiner: Mr E. Jembere
Duration: open

Instructions

1. Attempt all questions.


2. Your solutions will be marked/assessed during the practical session on Tuesday, 29 August 2017.
Please note that no marking will be done before or after the practical session.
3. Assessment will be done NOT only on your code, but also on your ability to explain your code.
Inability to explain your code will cost you all your marks for that question.
4. You are advised to come for the practical session almost done with all questions on this paper.
5. The stars against the questions indicate the level of difficulty of a question. The level of difficulty
is rated easy (no star), moderate (*), hard (**), or challenging (***).

1. Write a program that have methods that can do the following;

a. Reverse the elements of a stack, and using two additional stacks.


b. *Reverse the elements of a stack using one additional stack and some additional non-
container variables.
c. **Sort the elements in a stack in ascending order using one additional stack and some
additional non-container variables:
d. Sort the elements in queue using one additional queue and some additional non-
container variables.
Your program must have the logic to test all the four methods above.

1|Page
2. **A java Program contains various pairs of grouping symbols such as:
 Parentheses ( and )
 Braces { and }
 Brackets [ and ]
The symbols do not overlap (e.g. (a {b)} is illegal). Write a program to check whether a
java source code file has correct pairs of the three (3) grouping symbols mentioned
above. Pass the source code file name as a command-line argument.
3. (Adding two very large Integers) A stack can be used to add two very large integers
outside the scope of int data type as shown in Figure 1.

Figure 1

Write a program that adds two integers as shown in Figure 1.

4. Write a program for implementing a priority queue using a list as the underlying data
structure. Your program should aim for efficiency in the implementation of the enqueue
and dequeue operations of the priority queue.

----------------------------------------------------------------------------------------------------------------

WISHING YOU ALL THE BEST

2|Page

You might also like