0% found this document useful (0 votes)
29 views

BACS2063 2020-Oct Final Exam Question Paper

Uploaded by

Jason Yeoh
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)
29 views

BACS2063 2020-Oct Final Exam Question Paper

Uploaded by

Jason Yeoh
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/ 6

KOLEJ UNIVERSITI TUNKU ABDUL RAHMAN

FACULTY OF COMPUTING AND INFORMATION TECHNOLOGY

ACADEMIC YEAR 2020/2021

SEPTEMBER/OCTOBER EXAMINATION

COMPUTER SCIENCE BACS2063


DATA STRUCTURES AND ALGORITHMS

THURSDAY, 1 OCTOBER 2020 TIME: 9.00 AM - 12.00 NOON (3 HOURS)

BACHELOR OF COMPUTER SCIENCE (HONOURS) IN DATA SCIENCE


BACHELOR OF COMPUTER SCIENCE (HONOURS) IN INTERACTIVE SOFTWARE
TECHNOLOGY
BACHELOR OF COMPUTER SCIENCE (HONOURS) IN SOFTWARE ENGINEERING

BACHELOR OF INFORMATION SYSTEMS (HONOURS) IN ENTERPRISE INFORMATION


SYSTEMS

BACHELOR OF INFORMATION TECHNOLOGY (HONOURS) IN INFORMATION SECURITY


BACHELOR OF INFORMATION TECHNOLOGY (HONOURS) IN INTERNET TECHNOLOGY
BACHELOR OF INFORMATION TECHNOLOGY (HONOURS) IN SOFTWARE SYSTEMS
DEVELOPMENT

BACHELOR OF SCIENCE (HONOURS) IN MANAGEMENT MATHEMATICS WITH


COMPUTING

Instructions to Candidates:

Answer ALL questions in the requested format or template provided.

This is an open book final online assessment. You MUST answer the assessment questions on your
own without any assistance from other persons.
You must submit your answers within the following time frame allowed for this online assessment:
o The deadline for the submission of your answers is half an hour from the end time of this
online assessment.
Penalty as below WILL BE IMPOSED on students who submit their answers late as follows:
o The final marks of this online assessment will be reduced by 10 marks for answer scripts that
are submitted within 30 minutes after the deadline for the submission of answers for this
online assessment.
o The final marks of this online assessment will be downgraded to zero (0) mark for any answer
scripts that are submitted after one hour from the end time of this online assessment.
Extenuation Mitigating Circumstance (EMC) encountered, if any, must be submitted to the
Faculty/Branch/Centre within 48 hours after the date of this online assessment. All EMC
applications must be supported with valid reasons and evidence. The UC EMC Guidelines apply.

This question paper consists of 2 questions on 6 printed pages.


2
BACS2063 DATA STRUCTURES AND ALGORITHMS

FOCS Additional Instructions to Candidates:


Include your FULL NAME, STUDENT ID and PROGRAMME OF STUDY in
your submission of answer.
Read all the questions carefully and understand what you are being asked to answer.
Marks are awarded for your own (original) analysis. Therefore, use the time and
information to build well-constructed answers.

By submitting this online assessment, I declare that this submitted work is free from all
forms of plagiarism and for all intents and purposes is my own properly derived work. I
understand that I have to bear the consequences if I fail to do so.

Final Online Assessment Submission


Course Code:
Course Title:
Signature:
Name of Student:
Student ID:
Date:

This question paper consists of 2 questions on 6 printed pages.


3
BACS2063 DATA STRUCTURES AND ALGORITHMS

Question 1

a) Algorithm analysis focuses on the growth rate of the running time as a function of the input size n. The
Big-O time efficiency.

(i)
elapsed between the start and end time of running the algorithm. (6 marks)

(ii) How does the Big-O Notation resolve these limitations from Question 1 a) (i)? Justify your
answer with an example of code segment (in your code example, indicate how do you derive
the Big-O). (5 + 5 marks)

(iii) Consider two programs A and B that have the following Big-O time efficiency:
A: O(n)
B: O(n2)
If each program requires 10 seconds to solve a problem of size 1000, estimate the time
required by each program to solve a problem of size 2000. (4 marks)

b) When is it suitable to use a Queue ADT? Explain your answer by giving an example of a system or an
application that would use a Queue ADT. Your answer should include what is the object in the queue
and how this ADT is used. (10 marks)

c) Analyze TWO (2) benefits of using abstraction in the data structures. Justify your answer with relevant
examples. (8 marks)

d) Consider the program output in Figure 1(a). The output shows a triangle shape where the line number
.

(i) This problem can be solved iteratively, as shown in Figure 1(b). For the output in Figure 1(a),
the shape is produced by passing n=10 to the method drawPattern. Write a recursive solution
to the code segment in Figure 1(b). Your answer should be written in one or more methods.
You do not need to write the code for the driver program. (8 marks)

(ii) Compare the iterative solution in Figure 1(b) with your recursive solution in Question 1 d)
(i). Which is a better solution? Briefly explain your reason. (4 marks)

Figure 1(b): Iterative solution


[Total: 50 marks]
Figure 1(a): Program Output
This question paper consists of 2 questions on 6 printed pages.
4
BACS2063 DATA STRUCTURES AND ALGORITHMS

Question 2

a) The Penang State Public Library would like to implement a search function to their existing library
system.
Books are being represented as objects in the library system.
Figure 2 below shows the relationship between the Book class and the BookCopy class.

Book BookCopy
- ISBN: String - bookID: String
- title: String - book: Book
- authors: String[] - dateReceived: Date

Figure 2: Part of the Analysis Class Diagram for the Penang State Public Library System

The code snippet of the classes is shown in Figure 3.


public class Book{ public class BookCopy{
private String ISBN; private String BookID;
private String title; private Book book;
private String[] authors; private Date dateReceived;

}
}
Figure 3: Code Snippet of the Book Class and BookCopy Class

The Search function allows the user to enter a word (which should be part of the book title) to search for
a book from a database. The returned records (books which have the title containing the searched word)
would be stored in a suitable variable (X) of a particular Collection Abstract Data Type (ADT). The
variable X should be able to be sorted by the title in ascending order (A-Z). If the user clicks on a particular
book title from the search results, the system must be able to access that particular book from variable X
and display the details of the book.

You are being assigned to develop this search function for the above requirements.

Select a suitable Abstract Data Type (ADT) to store the search object of book. Justify why your ADT is
suitable for this purpose. (10 marks)

This question paper consists of 2 questions on 6 printed pages.


5
BACS2063 DATA STRUCTURES AND ALGORITHMS

Question 2 (Continued)

b) The code segment given in Figure 4 is the implementation of a sorting algorithm that sorts an array of
String in ascending order.

Figure 4: Code segment for a sorting algorithm

Based on the code segment given in Figure 4, answer the following questions:

(i) What is the type of sorting algorithm shown in Figure 4? (2 marks)

(ii) The usual number of results returned from the search in Question 2 a) is between 1 to 20 books.
Based on the algorithm you had given in Question 2 b) (i), is this sorting algorithm suitable to
be used to sort the book search results in Question 2 a)? Why?
(6 marks)

(iii) Suppose the sorting algorithm shown in Figure 4 is used to sort the book titles returned in the
search results in Question 2 a). Some sample data of book records is shown in Table 1.

ISBN Title Authors


9781623171322 The Abundance of Less Andy Couturier
9780593187741 Clutter-Less James Carter
9781401954871 The Year of Less Cait Flanders
9781601427994 The Simplicity of Less Joshua Green
Table 1: Sample data of Book records

Illustrate how the algorithm in Figure 4 sorts the book objects based on the title. Show your
answers in Figure 5 and explain the changes after each pass is performed.
(12 marks)
0 1 2 3
The Simplicity
Original Clutter-Less
of Less
After Pass 1

Figure 5

This question paper consists of 2 questions on 6 printed pages.


6
BACS2063 DATA STRUCTURES AND ALGORITHMS

Question 2 (Continued)

c) Based on the binary search tree from Figure 6, answer the following questions:

E J

B F H M

K P
A C

O R

Figure 6: Binary Search Tree

(i) Show the results of the inorder and postorder traversals on the binary search tree in Figure 6.
(6 marks)

(ii) Briefly explain your answer.


(6 marks)

d) You are intending to store the details of 75 students of the Vegan Society into a hash table with table
size as 83. Design an appropriate hash function using the Student ID (sample data given below) as
input. Express your answer in coding or algorithm. (8 marks)
20PMD1250 20PMD1251 20PMD1252 20PMD1325

[Total: 50 marks]

This question paper consists of 2 questions on 6 printed pages.

You might also like