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

EEX4465 2020 21 - Final

Uploaded by

kavinda1204
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)
20 views4 pages

EEX4465 2020 21 - Final

Uploaded by

kavinda1204
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

The Open University of Sri Lanka

Faculty of Engineering Technology


Department of Electrical and Computer Engineering

Study Programme : Bachelor of Software Engineering Honours


Name of the Examination : Final Examination
Course Code and Title : EEX4465 Data Structures and Algorithms
Academic Year : 2020/21
Date : 27th January 2022
Time : 14:00 – 17:00 hrs.
Duration : 3 hours

General Instructions

1. Read all instructions carefully before answering the questions.


2. This question paper consists of seven (7) questions in four (4) pages.
3. Answer any FIVE (5) questions only. All questions carry equal marks.
4. Answer for each question should commence from a new page.
5. Answers should be in clear handwriting and do not use Red colour pen.
6. Clearly state your assumptions, if any.
7. This is a Closed Book Test (CBT).

Page 1 of 4
Q1
(a) Briefly explain the terms: [02]
Time complexity and Space complexity
(b) Explain the following notations: [03]
i) Big-Oh ii) Big-Omega iii) Big-Theta
(c) Find the worst-case running time for the following expressions/functions in Big-Oh
notation in terms of the variable n. Explain your work. [15]
i) The growth of the sum 1 + 1/2 + 1/3 + . . . + 1/n.
ii) An algorithm takes an n by n Boolean matrix as the input. If the running time of the
algorithm is O(n log n) when n is used as the input size, then what is the running
time of the algorithm for n2.
iii) When inserting n elements into an initially empty binary search tree.
iv) Sorting n 32-bit unsigned integers by using Insertion Sort.
v) The function T(𝑛) = 2T( 𝑛/3) + √𝑛.

Q2 A lower triangular matrix is one in which all elements above the main diagonal are zero
of a square matrix. Assume we have an n by n lower triangular matrix L. Answer the
following questions:
(a) What is the maximum number of nonzero terms in L? [03]
(b) If each element can be stored in a 32-bit signed integer, what is the memory size that
would be needed to store all nonzero terms stated in (a). [02]
(c) Since storing a triangular matrix as a two-dimensional array, is a waste of memory
space. Therefore, write a complete pseudocode algorithm to store only the lower
triangular elements (with the main diagonal) of L in a one-dimensional array called,
arryL. [15]

Q3
(a) Describe what is a binary search tree (BST)? [02]
(b) What is the maximum number of nodes in a binary tree of depth d ? [02]
(c) When constructing a BST, what is the method you use if the sequence of numbers has
duplicates? [03]
(d) Construct a BST for the following sequence of numbers by taking the first element as the
root: [10]
{45, 32, 90, 21, 78, 65, 87, 132, 90, 96, 41, 74, 92}
(e) Use the BST in (d) to find the: [03]
In-order, Pre-order, and Post-order traversals

Page 2 of 4
Q4 Consider the following directed, weighted graph to answer the questions below.

(a) Step through Dijkstra's algorithm to calculate supposedly shortest paths from A to every
other vertex. You should consider negative weight edges as well. Show your steps in the
table form. Cross out old values and write in new ones, from left to right, as the algorithm
proceeds. [15]
(b) Dijkstra's algorithm found the wrong path to some of the vertices. For just the vertices
where the wrong path was computed, indicate both the path that was computed and the
correct path. [03]
(c) What single edge could be removed from the graph such that Dijkstra's algorithm would
happen to compute correct answers for all vertices in the remaining graph? [02]

Q5 Consider the following operands and operators with their precedence for logic
expressions. Note that you must consider left and right parenthesis as well.

Operands Operators and their meaning Precedence


~ not First
0
& and Second
1
| or Third

(a) Write the pseudocode algorithm to convert a string of logic expression into its
expression tree. You can use any data structure to represent the tree and should explain
how your data structure logically relates to the tree. Since ~ is a unary operator, you
should put its only operand to its right child. [12]
(b) Draw the expression tree of the following logical expression: [04]
~ (0 & ~ 1 & 0 | 0) & 0
(c) Obtain the prefix and postfix notations for the given expression in (b). [04]

Page 3 of 4
Q6
(a) What is hashing? [02]
(b) For what purpose the hashing used in data structures? [02]
(c) Describe another two methods which can be used for the purpose written in (b). [04]
(d) What is hash collision and how it can be handled? [02]
(e) Construct a non-collision hash table resulting from the hashing with the given keys,
{12, 44, 13, 88, 23, 94, 11, 39, 20, 16, 5}
by using the hash function,
h(k) = (2k + 5) MOD n,
where n is the number of elements. [10]

Q7
(a) Write the complete pseudocode for the Quick Sort algorithm. [06]
(b) Use the Quick Sort algorithm to sort the following numbers. You should show the step-
by-step procedure. [14]
{2, 6, 7, 5, 10, 9, 2, 4}

-- End –

Page 4 of 4

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