0% found this document useful (0 votes)
39 views4 pages

ICT 202 June, 2023

The document is a final examination paper for the ICT202 course on Data Structures & Algorithms at Mulungushi University, consisting of two sections: Section A with multiple-choice and true/false questions totaling 50 marks, and Section B with four questions where students must answer three, totaling 60 marks. The exam covers various topics related to data structures, algorithms, and their complexities. Students are instructed to present their work clearly and answer all questions as specified.

Uploaded by

Muma Hillary
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)
39 views4 pages

ICT 202 June, 2023

The document is a final examination paper for the ICT202 course on Data Structures & Algorithms at Mulungushi University, consisting of two sections: Section A with multiple-choice and true/false questions totaling 50 marks, and Section B with four questions where students must answer three, totaling 60 marks. The exam covers various topics related to data structures, algorithms, and their complexities. Students are instructed to present their work clearly and answer all questions as specified.

Uploaded by

Muma Hillary
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/ 4

MULUNGUSHI UNIVERSITY

Pursuing the frontiers of knowledge

SCHOOL OF ENGINEERING AND TECHNOLOGY

ICT202 - Data Structures & Algorithms

Final Examination

June 2023

Instructions/Information:

1. This paper has two sections Section A and Section B


2. Answer all questions in Section A. Total marks for Section A is 40 marks
3. There are four(4) questions in Section B,answer ONLY three(3) questions. Total marks
for Section B is 60 marks

4. Present readable and tidy work


SECTION A. Answer All
Multiple Choice (20 Marks)
1. Which of the following will result from infinite recursion in Java?
Select one:
_

a. None of the other answers.


b. The program will throw an ArrayOutOfBoundsException.
c. The program will
d. The program will
hang as though there
not compile.
is
an infinite loop.

e. The program will run out of memory.


2. All of the following true for both recursion and iteration except:
are
Select one:
a. both gradually approach termination.
b. they can cause infinite loops or
infinite recursion.
c. they are based on a control statement.
d. they have a base case.

3. Which ofthe following tasks cannot be performed using an enhanced for loop?
Select one:
a. Multiplying all the values in an array together.
b. Comparing the elements in an array to a specific value.
c. Incrementing the value stored in each element of the array.
d. Displaying all even element values in an array.
4. What is the result of evaluating the following postfix expression: 4 8 + 2 *

Select one:
20
a.
64
b.
24
c.
40
d.
e. none of the answers are correct
5. Which of the following functions grows faster? (assume “ is the symbol for power eg

n
n’2 means to the power 2)
Select one:
a. logn
b. nlogn
c. n2
d. n
e. 10
6. Suppose you have
a singly linked list with the following elements:

5 ->8->3->1->9->null
What would be the resulting linked list after deleting the node with value 3?
Select one:

a. 5->8->1->9->null
'b. S5S->8-> 1 -> null
ce 5->8->9->null
d. 8->1->9->null
7. What is the time complexity of inserting a node at the beginning
list?
of
a singly linked
Select one:

a. O(1)
b. O(log n)
c. O(n)
d. Of@logn)
8. Which
of the following is a way to implement a stack using a linked list?
Select one:
a. Adding elements to the beginning of the linked list
b. Adding elements to the end of the linked list
c. Removing elements from the beginning of the linked list
d. Removing elements from the end of the linked list
9. Whatis the time complexity of deleting the last node in a singly linked list?
Select one:
a. O(1)
b. O(log n)
c. O(n)
d. O(n log n)
10. Which of the following is an advantage of linked lists over arrays?
Select one:
a. Linked lists have constant time access to any element
b. Linked lists use less memory than arrays
c. Linked lists can be resized without copying data
d. lists can be sorted more efficiently than arrays
Linked

TRUE/FALSE (10Marks)
True or False: A stack follows the Last-In-First-Out (LIFO) principle.
True or False: A linked list
allows for constant time insertion and deletion at any
position.
True or False: A binary search tree guarantees constant time complexity for searching,
insertion, and deletion.
True or False: A hash table provides constant time complexity for insertion, deletion,
and retrieval on average.
True or False: A tree is a connected acyclic graph.
True or False: An array is a dynamic data structure in which elements are stored in
contiguous memory locations.
True or False: A stack follows the First-In-First-Out (FIFO) principle.
True or False: A linked list can be easily traversed in both forward and backward
directions.
True or False: A binary search tree guarantees constant-time insertion and deletion
operations.
True or False: In a heap data structure, the smallest (or largest) element always is
stored at the root.
SECTION
B Answer any THREE (3) questions
Question 1

a) Using the rules and concepts learned for analysis of algorithms, show your working
given that the time complexity for the “for loop” below is O(log2n). (10 marks)

b) What is the output of the following java code? (10 marks)


Question 2

a) Write a method in Java to insert a new node at


the beginning of a
singly linked list.
The function should take in the head of the linked list and the value of the new node
to be inserted as parameters, and return the new head of the linked list.

For example, if the original linked list is 1 -> 2 -> 3 -> None and the new node to be
inserted has a value of 0, the new linked list should be 0 -> 1 -> 2 -> 3 -> None. (10
marks)

b) An algorithm takes 5 seconds for an input size of 100. If the algorithm is quadratic,
approximately how long does
working(5 marks)
it take to solve a problem of size 200?.Show your

Write a line of code that creates a 5-element array called primeNums of ints and sets
its value with the first five prime numbers greater than 399 but less than 415. (5
marks)

Question 3
Write and test a java program to demonstrate the use of a stack to evaluate postfix
expression. (10 marks)

b) Use a stack-based algorithm to evaluate the postfix expressions given below


105861/+*- (10 marks)
Show all your steps

Question 4

Given the fibonacci function as below fibonacci(0) = 0 fibonacci(1) = 1


fibonacci(n) =
fibonacci(n—1) + fibonacci(n—2) What would be
the result ifn is equal to the first 4
prime numbers show your working?(10 marks)

b) Consider the following array of integers: [5, 2, 9, 1, 7]. Implement the Bubble Sort

algorithm to sort the array in ascending order. Show the step-by-step process and
provide the sorted array as the final result. (10 marks)

You might also like