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

CSC508 TEST2 12july2023

This document contains a 4 question test for the Data Structures course CSC508, to be taken on July 12th, 2023. It includes questions on sequential and binary search algorithms, hashing, sorting algorithms like selection sort, merge sort and heap sort, binary search trees, AVL trees, graph representations, and Dijkstra's shortest path algorithm. Students are instructed to answer all questions within the 2 hour time limit. Good luck is wished for their final exam.

Uploaded by

2021886362
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)
281 views

CSC508 TEST2 12july2023

This document contains a 4 question test for the Data Structures course CSC508, to be taken on July 12th, 2023. It includes questions on sequential and binary search algorithms, hashing, sorting algorithms like selection sort, merge sort and heap sort, binary search trees, AVL trees, graph representations, and Dijkstra's shortest path algorithm. Students are instructed to answer all questions within the 2 hour time limit. Good luck is wished for their final exam.

Uploaded by

2021886362
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

CS/JULY2023/CSC508/TEST 2

CONFIDENTIAL CS/JULY 2023/CSC508/TEST 2

UNIVERSITI TEKNOLOGI MARA


TEST 2

COURSE : DATA STRUCTURES


COURSE CODE : CSC508

DATE : 12 JULY 2023


TIME : 2 HOURS (8:00 – 10:00 AM)
SEMESTER : MARCH - AUGUST 2023
NAME :
STUDENT’S ID :
GROUP :
STUDENT

INSTRUCTIONS TO CANDIDATES

1. This paper consists of FOUR (4) questions.


2. Answer ALL questions.

Score Total Marks

QUESTION 1 20

QUESTION 2 20

QUESTION 3 20

QUESTION 4 20

TOTAL SCORE 80
CS/JULY2023/CSC508/TEST 2

Answer ALL questions

QUESTION 1 (20 marks)


Consider the following list :

4 8 12 23 39 45 49 55 60 68 73 75 80 97 132

How many comparisons are required to find whether items 73 and 99 are in the list?
a) Using Sequential Search algorithm? (5 marks)
b) Using Binary Search algorithm? (5 marks)

c) The following questions are on hashing:

i. What is collision in hashing? (2 marks)


ii. Explain two(2) methods in resolving collision. (4 marks)
iii. Consider the following values. Store the hash values in a hash table with five(5)
buckets using modulo (%) operator and hashing with chaining.
46 72 91 12 28 19 23 30 55 24
(4 marks)

QUESTION 2 (20 marks)


From the given list of items below, illustrate the execution of each pass of the following sorting
algorithms:
65 5 90 68 93 23 87 22
a) Selection Sort (6 marks)
b) Merge Sort (6 marks)
c) Heap Sort (8 marks)

QUESTION 3 (20 marks)


a) Given the following list of items, construct the Binary Search Tree.

ITS432 MAT499 CSC508 CTU153 QMT155 BEL100 ENT300 ITC511


(5 marks)
CS/JULY2023/CSC508/TEST 2

b) Based on the AVL Tree below, answer the following questions:

550

30 80

46 65
15

50

i. Insert value 48 into the AVL Tree above. The resulting tree must also be an AVL
tree.
(5 marks)
ii. What are the balance factors at each node after the insertion in (i).
(5 marks)

c) Write a recursive method countLeaves() for class BinarySearchTree, which will


count the number of leaves in a BST.
(5 marks)

QUESTION 4 (20 marks)


a) Draw a graph and adjacency list from the following information:
Graph G = (V, E) is composed of:
V = {a, b, c, d, e}
E = { (a,b), (a,c), (a,d), (b,e), (c,d), (c,e), (d,e) }
(10 marks)
b) If the weight of all edges in E is given as follows respectively:
W(E) = { 5, 3, 12, 7, 2, 15, 3}
Using Dijkstra algorithm, find the shortest path from vertex a to any other vertices in G.
(10 marks)
CS/JULY2023/CSC508/TEST 2

END OF QUESTION PAPER

GOOD LUCK FOR YOUR FINAL EXAM

*** Ilmu itu didapati dengan lidah yang gemar bertanya


dan akal yang suka berfikir ***
(Abdullah Ibnu Abbas)

You might also like