Professional Documents
Culture Documents
Scoa021 Question Paper For Mid - Year 2017 Examination
Scoa021 Question Paper For Mid - Year 2017 Examination
TURFLOOP CAMPUS
(DATA STRUCTURES)
: MR MJ MATJUDA
INSTRUCTIONS:
QUESTION 1 [10]
1.2 Define the following concepts as applied in C++ data structure applications:
1.2.1 Data structures [1]
1.2.2 Generic data type [1]
1.2.3 Preorder traversal algorithm [1]
1.2.4 Template [1]
1.2.5 Memory leak [1]
QUESTION 2 [10]
2.1 Use a suitable ADT to create a structure called Node having two data members: item and next,
where the latter is a pointer to another node and item is of type double. Instantiate two variables
Node1, and Node2 from the created structure type. [5]
2.2 Suppose that you have the following declaration; where StackType is a template class.
StackType <double> stack(50);
double num;
input : 25 60 -10 40 -3.7 90 -12 9
Write C++ code that processes input as follows: If the number is non- negative, it pushes the square
root of the number onto the stack; otherwise it pushes the square of the number onto the stack. After
processing these numbers show code that outputs the elements of the stack. [5]
QUESTION 3 [10]
3.1 Create a data type called Book based on the following properties:
the title of the book is 25 characters long, price R175.50
Author first name, last name and gender
Instantiate two objects of type Book and declare them book1 and book2 respectively. Show how you
will initialize members of book1. [6]
3.2 Consider the following linked list of integer values and implement the statements below
10 50 100 200
Header
2|Page
SCOA021 MAY/JUNE EXAMINATION 2018
3.2.1 Insert a node with the value 300 at the end of the list. [2]
3.2.2 Update the second node of the list by replacing the value 50 with 225. [1]
3.2.3 Delete the node with value 200. [1]
QUESTION 4 [10]
4.1 Differentiate between a struct and a class [2]
4.2 Contrast static and dynamic allocation of memory. [2]
4.3 In general, the basic operations that are performed on an abstract data type are classified into
four (4) categories. Briefly describe each. [4]
4.4 Describe the accessing protocol of a queue at the logical level [2]
QUESTION 5 [10]
Multiple – choice
Write down the question number and correct answer in your answer book
5.2. Element double Array [7] is which element of the array? [1]
5.3 In a stack, the data item placed on the stack first is [1]
3|Page
SCOA021 MAY/JUNE EXAMINATION 2018
5.7 When writing the code to define a member function, the name of ______ must precede the
4|Page
SCOA021 MAY/JUNE EXAMINATION 2018
5.9 The programming practice of hiding the representation of data from the applications that
5.9.2 Robustness
5.9.3 Abstraction
5.9.4 Encapsulation
QUESTION 1 [20]
QUESTION 2 [30]
2.1 Suppose L1 and L2 denote languages and L1 = {a, b, c, d, e} and L2 = {1, 2}, compute the
following operations on languages? [5]
2.1.1 L1L2
5|Page
SCOA021 MAY/JUNE EXAMINATION 2018
2.1.2 L1UL2
2.1.3 L1*
2.1.4 L1+
2.1.5 L1
2.2 Consider the statement
If (A+3<400) A = 0;
else B = A∗A;
Create the tokens returned by the lexical analyzer [5]
2.3 Consider the Regular Expression (RE): (a | b)* a b b
Construct an NFA and a DFA for the above. [10]
2.4 For the following expression generate an intermediate and the final code. [10]
X=a+b
X=x*c
T = t/d
6|Page