Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
539 views
6 pages
CSC508
csc508
Uploaded by
aisyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save CSC508 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
539 views
6 pages
CSC508
csc508
Uploaded by
aisyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save CSC508 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save CSC508 For Later
You are on page 1
/ 6
Search
Fullscreen
CONFIDENTIAL = CSIDEC 2018/CSC508/518 & UNIVERSITI TEKNOLOGI MARA FINAL EXAMINATION COURSE : DATA STRUCTURES/DATA STRUCTURE AND ALGORITHM ANALYSIS COURSE CODE : CSC508/518 EXAMINATION : DECEMBER 2018 TIME : 3HOURS INSTRUCTIONS TO CANDIDATES 1 This question paper consists of five (5) questions. 2 Answer ALL questions in the Answer Booklet. Start each answer on a new page. 3 Do not bring any material into the examination room unless permission is given by the invigilator. 4, Please check to make sure that this examination pack consists of i) the Question Paper jl) an Answer Booklet ~ provided by the Faculty 5, Answer ALL questions in English. DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO This examination paper consists of 6 printed pages © Hak Cipta Universiti Toknologi MARA CONFIDENTIAL,CONFIDENTIAL 2 CSIDEC 2018/¢SC508/518 QUESTION 4 a) List THREE (3) basic operations performed on stack. (3 marks) b) Write an application to enqueue FIVE (5) random integer values in sequences into a queue named Number. (4 marks) ¢) Figure 1 below shows a piece of coding. Write the contents for both queue and stack at both comment lines. (5 marks) public class Ql ( public static void main(String s [] ) { Stack lew Stack(); Queue y=new Queue (); for(int i= { 3; i<80; i+=13) x.push (i); } for(int j=0; 3<3; j++) { y-enqueue(x-pop()) 7 } //#e+++%%¢4comment Line 1 while (!y.istmpty ()) ( x.push(y.dequeue() ) ; ) for(int j=0; j<3; j++) { y-enqueue(x.pop() ) + y //****4*4«%Comment Line 2 } y Figure 7 (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL,CONFIDENTIAL 3 CSIDEC 2018/CSC508/518 d) Figure 2 shows the ADT of Bus and Queue classes. public class Bus { string regNo; // bus registration number String yearReg; // year registered with JPJ String owner; //name of the owner String stateReg; //which state the vehicle is registered eg. Pahang, Melaka, etc public Bus (String, String, String, String); public String getRegNo(); public String getYearReg(); public String getOwner(); public String getstate(); } public class Queue { public Queue(); public void enqueue (Object); public Object dequeue (); public Boolean isEmpty (); //definition for other methods. Figure 2 Queue named busQueue inserted with 50 busses information, write a Java program segments for the following requirements: i) Find the total number of busses which was registered in the year 2018 and display it. (Noted: In order to avoid data loss, use temporary queue to store bus information.) (4 marks) ii) From the temporary queue, move all buses that were registered in Melaka into a stack name M1kSt.ack and other busses into the original queue. (4 marks) QUESTION 2 a) Given the following list: 6, 10, 22, 29, 35, 41, 53, 76, 80, 100, 25 i) Show the values of first, last, mid and the number of comparison for search item 100. (4 marks) (© Hak Cipta Universiti Teknologi MARA CONFIDENTIALCONFIDENTIAL 4 CSIDEC 2018/CSC508/518 ll) Show the values of first, last, mid and the number of comparison for search item 27. (4 marks) b)_ State the TWO (2) differences between sequential search and binary search. (4. marks) ©) Uist eny THREE (3) commonly used Hash Method. (3 marks) d) Given the following values to be inserted into a hash table of size 5, draw a diagram of the hash table if the function uses the modular (%) method and hashing with chaining. 43, 32, 56, 192, 1000, 26, 34 78, 16, 66 (6 marks) QUESTION 3 a) Define Heap Sort, (3 marks) b) Briefly explain the way merge sort algorithm differs from the selection sort algorithm in partitioning lists. (4 marks) ©) List out the THREE (3) operations that make up the most running time in sorting algorithm, (3 marks) 4) Given the following list, show steps to sort the list by using Merge Sort. 8, 4, 6,9, 2,3,4 (6 marke) €) Given the following list, iltustrate how Insertion sort is done. 64, 26, 93, 17, 77, 31, 44, 65, 20 (4 marks) QUESTION 4 8) Define successor and predecessor in binary tree. (3 marks) b) Briefly describe the TWO (2) types of rotation in AVL tree. (3 marks) (© Hak Cipta Universiti Teknologi MARA CONFIDENTIALCONFIDENTIAL 5 CSIDEC 2018/CSC508/518 ©) Write an algorithm for post order traversal. (4 marks) d) Given the following lists, construct an AVL tree with the balance factor after each insertion. 322, 229, 656, 767, 888, 311, 201, 760, 995, 898 (5 marks) QUESTION 5 a) Table 1 shows the weight of edges and the adjacent nodes for nodes labeled A through F. Draw an undirected graph based on Table 1 (6 marks) Node ‘Adjacent nodes Weighis K (CO) (0, 8) B (A, C, F) (10, 7, 2) c (A,B, DE) 6.7, 12, 16) D (C,E, F) (12, 9, 5) E (C, D) (6,9) F (B,D) (2,5) Tabie 1 b) Using Kruskal's Algorithm, find the minimum spanning tree for the graph in Figure 3. (10 marks) | Figure 3 CONFIDENTIAL @ Hak Cipta Universiti Teknologi MARACONFIDENTIAL 6 CSIDEC 2018/CSC508/518 ©) Using Djikstra Algorithm, find the shortest path from A to all other vertices for the graph in Figure 4. (10 marks) END OF QUESTION PAPER (© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL,
You might also like
Revision Final Exam Itt270 Ans
PDF
100% (1)
Revision Final Exam Itt270 Ans
6 pages
CSC510 20242 - Chapter 5 - Program Correctness - Rai
PDF
No ratings yet
CSC510 20242 - Chapter 5 - Program Correctness - Rai
69 pages
Uitm Mat523 Feb2022 Final
PDF
No ratings yet
Uitm Mat523 Feb2022 Final
18 pages
ICT450 Chapter 1 Notes
PDF
100% (1)
ICT450 Chapter 1 Notes
2 pages
Universiti Teknologi Mara Final Examination: Confidential Cs/Jun
PDF
100% (1)
Universiti Teknologi Mara Final Examination: Confidential Cs/Jun
11 pages
CSC186 FinalDec2019
PDF
No ratings yet
CSC186 FinalDec2019
20 pages
CSC508
PDF
No ratings yet
CSC508
7 pages
CSC508 TEST2 12july2023
PDF
No ratings yet
CSC508 TEST2 12july2023
4 pages
ICT450 Chapter 3
PDF
No ratings yet
ICT450 Chapter 3
2 pages
CSC508 - Test1 - 05dec2022 Answer Scheme PDF
PDF
No ratings yet
CSC508 - Test1 - 05dec2022 Answer Scheme PDF
8 pages
CSC508 TEST2 16jan2023
PDF
No ratings yet
CSC508 TEST2 16jan2023
4 pages
ICT Final Report Final
PDF
100% (1)
ICT Final Report Final
48 pages
Final Report Csc510 Group Mini Project
PDF
No ratings yet
Final Report Csc510 Group Mini Project
19 pages
Study Plan For BCS Batch 201
PDF
No ratings yet
Study Plan For BCS Batch 201
3 pages
CSC577 - STR (Izzaty, Izzatun, Han, Faisal, Zulaikha)
PDF
No ratings yet
CSC577 - STR (Izzaty, Izzatun, Han, Faisal, Zulaikha)
19 pages
Itt Group Project Report
PDF
No ratings yet
Itt Group Project Report
15 pages
Final Assessment Sta220 Answer Scheme Feb2022
PDF
No ratings yet
Final Assessment Sta220 Answer Scheme Feb2022
6 pages
CSC577 (Test1) 30042024
PDF
No ratings yet
CSC577 (Test1) 30042024
4 pages
Csc577 SDD 4c Group2
PDF
100% (1)
Csc577 SDD 4c Group2
45 pages
Quiz 1 With Answer Sta116 Quiz 1
PDF
100% (1)
Quiz 1 With Answer Sta116 Quiz 1
8 pages
CSC305 - Test 2 (Answer Scheme) Student
PDF
No ratings yet
CSC305 - Test 2 (Answer Scheme) Student
7 pages
Ict200 3
PDF
No ratings yet
Ict200 3
14 pages
Answer Scheme Isp500 Jan 2023
PDF
No ratings yet
Answer Scheme Isp500 Jan 2023
4 pages
2023 Oct CSC510 Test 1 Answer Scheme
PDF
No ratings yet
2023 Oct CSC510 Test 1 Answer Scheme
5 pages
Universiti Teknologi Mara: Confidential CS/TEST 1/NOV2020/CSC583
PDF
100% (1)
Universiti Teknologi Mara: Confidential CS/TEST 1/NOV2020/CSC583
15 pages
Hangman Documentation
PDF
0% (1)
Hangman Documentation
2 pages
Ict550 Final Assessment
PDF
No ratings yet
Ict550 Final Assessment
4 pages
Nurulnazifarais Isp542 Part A
PDF
No ratings yet
Nurulnazifarais Isp542 Part A
3 pages
CSC577 (Test2) - 20222 20220620
PDF
No ratings yet
CSC577 (Test2) - 20222 20220620
3 pages
Csc577 Srs 4c Group2
PDF
100% (1)
Csc577 Srs 4c Group2
31 pages
Test May 2024 CSC569
PDF
No ratings yet
Test May 2024 CSC569
3 pages
ICT450
PDF
No ratings yet
ICT450
6 pages
Isp542 Part A
PDF
No ratings yet
Isp542 Part A
3 pages
Skillbased Assessment Julai 2021
PDF
No ratings yet
Skillbased Assessment Julai 2021
8 pages
Mobile Programming Questions
PDF
No ratings yet
Mobile Programming Questions
2 pages
ICT501 Exercise 6 Joins New
PDF
100% (1)
ICT501 Exercise 6 Joins New
6 pages
Universiti Teknologi Mara Final Assessment: Confidential 1 CS/FEB 2022/CSC580
PDF
No ratings yet
Universiti Teknologi Mara Final Assessment: Confidential 1 CS/FEB 2022/CSC580
4 pages
UiTM CS230 Course Outline
PDF
No ratings yet
UiTM CS230 Course Outline
2 pages
Csc186topic 1 - Part2
PDF
No ratings yet
Csc186topic 1 - Part2
34 pages
CSC128 CSC415
PDF
No ratings yet
CSC128 CSC415
11 pages
Scheme of Work CSC204
PDF
0% (1)
Scheme of Work CSC204
7 pages
Fundamentals of Computer Problem Solving (CSC415)
PDF
No ratings yet
Fundamentals of Computer Problem Solving (CSC415)
52 pages
Laboratory Task 2 (F1122) DFP30243
PDF
100% (1)
Laboratory Task 2 (F1122) DFP30243
4 pages
CSC305 LabTestAB Questions
PDF
No ratings yet
CSC305 LabTestAB Questions
5 pages
CSC404 Exam 1
PDF
No ratings yet
CSC404 Exam 1
5 pages
Csc577 - SDD Software Design Documents
PDF
No ratings yet
Csc577 - SDD Software Design Documents
23 pages
Csc577 SRA 4c Group2
PDF
No ratings yet
Csc577 SRA 4c Group2
17 pages
Test CSC207 20242
PDF
No ratings yet
Test CSC207 20242
10 pages
CSC204 Test Oct20-Feb21
PDF
No ratings yet
CSC204 Test Oct20-Feb21
14 pages
Lab ICT501
PDF
No ratings yet
Lab ICT501
11 pages
Universiti Pendidikan Sultan Idris Pentaksiran Akhir SEMESTER 2 SESI 2020/2021
PDF
No ratings yet
Universiti Pendidikan Sultan Idris Pentaksiran Akhir SEMESTER 2 SESI 2020/2021
27 pages
CSC248 Julai 22 Quiz
PDF
No ratings yet
CSC248 Julai 22 Quiz
9 pages
Assignment 1 CSC 248
PDF
No ratings yet
Assignment 1 CSC 248
10 pages
Test 1csc508 Answer
PDF
No ratings yet
Test 1csc508 Answer
7 pages
Test#1csc508 20nov2023
PDF
No ratings yet
Test#1csc508 20nov2023
6 pages
Test Question Oct 2020
PDF
No ratings yet
Test Question Oct 2020
5 pages
Hangman Game: Vocabulary Building Flutter App: 1) Background/ Problem Statement
PDF
No ratings yet
Hangman Game: Vocabulary Building Flutter App: 1) Background/ Problem Statement
7 pages
CSC126 Fundamentals of Algorithms & Computer Problem Solving Quiz 1
PDF
No ratings yet
CSC126 Fundamentals of Algorithms & Computer Problem Solving Quiz 1
5 pages
Lab04 Priority Queues and Heaps
PDF
No ratings yet
Lab04 Priority Queues and Heaps
6 pages
CSC520 Assessment 1. Presentation (10%)
PDF
No ratings yet
CSC520 Assessment 1. Presentation (10%)
2 pages