QUIZ
Started on Monday, 29 September 2025, 7:53 PM
State Finished
Completed on Monday, 29 September 2025, 9:33 PM
Time taken 1 hour 40 mins
Marks 97.70/106.00
Grade 92.17 out of 100.00
Information
This assessment covers the complete curriculum and outcomes and is also a good preparation for the written part of the
exam. [Remember - the final exam will consist of two sections: the written part (quiz) and a Final Practical Project].
Work through Class 4 and Chapter 21 in the prescribed textbook, before you attempt the assessment.
You have two (2) attempts to complete this assessment. The system will automatically upload your attempts when the due
date and time is reached. The due date is Wednesday, 1 October 2025, 11:00 PM. Note that this is the last day that UNISA
will accept assessments - thus no extension can be given.
Remember, the due date is the last date for submission and not the day on which you should start with the assessment.
Question 1
Complete
Mark 3.00 out of 3.00
Match each description with its correct data type.
Represents a single character, usually 1 byte char
Single-precision floating-point number float
Double-precision floating-point number double
Boolean type, stores true or false bool
Typically stores integers in the range of -32,768 to 32,767 (2 bytes) short
Typically stores integers in the range of -2,147,483,648 to 2,147,483,647 int
Extended size integer, at least 8 bytes long long
,Question 2
Complete
Mark 2.00 out of 2.00
When you build a linked list in the backward manner, a new node is always inserted at the end of the linked list.
True
False
Question 3
Complete
Mark 2.00 out of 2.00
When you build a linked list in the backward manner, a new node is always inserted at the end of the linked list.
True
False
Question 4
Complete
Mark 2.70 out of 3.00
Match each of the characteristics with the correct data structure (Queue or Stack).
Follows First In, First Out (FIFO) Queue
Uses push() to add an element Stack
Access the element at the front using front() Queue
Access the element at the top using top() Stack
Follows Last In, First Out (LIFO) Stack
Uses pop() to remove an element Both (Queue & Stack)
Elements are processed in the order they were added Queue
The last element added is processed first Stack
Allows direct access to any element by index Neither Queue nor Stack
Allows sorting of elements Neither Queue nor Stack
,Question 5
Complete
Mark 2.00 out of 2.00
Study the incomplete code. The outcome of this code should be:
10
20
30
Complete the code by dragging the relevant code segments into the empty spaces in the code.
Code:
std::queue<int> numberQueue;
// Adding elements to the queue
numberQueue.push(10);
numberQueue.push(20);
numberQueue.push(30);
// Remove and display elements until the queue is empty
while ( !numberQueue.empty() )
{
std::cout << numberQueue.front() << std::endl;
numberQueue.pop(); // Remove the element after displaying it
}
numberQueue.pop()
numberQueue.start();
not(numberQueue.empty())
, Question 6
Complete
Mark 2.00 out of 2.00
Study the following incomplete code.
int val1 = 10;
int val2 = 20;
int val3 = 30;
std::stack<int> numberStack;
numberStack.push(val1);
numberStack.push(val2);
numberStack.push(val3);
...(i)...
Which of the following code (i) will correctly display the elements of numberStack in descending order?
a. while (!numberStack.empty())
{
std::cout << numberStack.top() << std::endl;
numberStack.pop();
}
b.
while (!numberStack.empty())
{
std::cout << numberStack.top().desc() << std::endl;
}
c. while (!numberStack.empty())
{
numberStack.pop();
std::cout << numberStack.top() << std::endl;
}
d. while (!numberStack.empty())
{
std::cout << numberStack.pop() << std::endl;
numberStack.top();
}
e.
while (!numberStack.empty())
{
numberStack.top();
std::cout << numberStack.pop() << std::endl;
}
f. None of the options provided is correct.