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

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

This document provides instructions for a practical exam on data structures. It outlines 4 questions to be completed during the exam: 1. Write a program to count keyword occurrences in a Java source code file, excluding keywords in comments or strings. 2. Write a program to count word frequencies in a text file and store the words and counts in a map. 3. Write a program to read student mark data from a CSV file and store it in a data structure to efficiently retrieve marks by student. 4. Write a program to evaluate postfix expressions by using a stack to scan the expression from left to right.
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)
63 views2 pages

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

This document provides instructions for a practical exam on data structures. It outlines 4 questions to be completed during the exam: 1. Write a program to count keyword occurrences in a Java source code file, excluding keywords in comments or strings. 2. Write a program to count word frequencies in a text file and store the words and counts in a map. 3. Write a program to read student mark data from a CSV file and store it in a data structure to efficiently retrieve marks by student. 4. Write a program to evaluate postfix expressions by using a stack to scan the expression from left to right.
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 II

COURSE CODE: COMP201 Data Structures

Examiner: Mr E. Jembere
Duration: 0pen
Marks : 100

Instructions

1. Attempt all questions.


2. Your solutions will be marked/assessed during the practical session on Tuesday, 01 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 java program to read in a Java source code file and count the occurrence of each keyword in
the file, but don’t count the keyword if it is in a comment or in a string literal.
[20 marks]
2. **Write a program that reads words from a text file, counts the occurrence of each word in the file, and
stores words and their frequencies in a map and displays the words and their corresponding frequencies
in the order of their frequency. In the storage of the word occurrences, the words should remain the keys
and the frequencies should remain the values. Please note that you are not expected to create the class
“WordOccurence” as was expected in Practical I.
[30 marks]
3. *Write a program that reads the data in the file marks.csv provided on Moodle and store the data in a
data structure that enables efficient retrieval of all the modules that a given student has attempted and

1|Page
their corresponding marks (see Figure 1). The program should read the file once, through a single pass
through the file. Thereafter all queries for student marks should be done on the data structure. The
program should have GUI such as the one shown in Figure 1 that allows the user to pass a student
number as query for the student’s marks.

Figure 1: GUI for displaying student marks

[20 marks]
4. **(Postfix notation) Postfix notation is a way of writing expressions without using parentheses. For
example, the expression (1 + 2) * 3 would be written as 1 2 + 3 *. A postfix expression is evaluated
using a stack. Scan a postfix expression from left to right. A variable or constant is pushed into the
stack. When an operator is encountered, apply the operator with the top two operands in the stack and
replace the two operands with the result. The following diagram shows how to evaluate 1 2 + 3 *.

Write a program to evaluate postfix expressions. Pass the expression as a commandline argument in
one string.

[30 marks]

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

WISHING YOU ALL THE BEST

2|Page

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy