0% found this document useful (0 votes)
57 views13 pages

DFC 2023

it

Uploaded by

Zhess Bug
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
0% found this document useful (0 votes)
57 views13 pages

DFC 2023

it

Uploaded by

Zhess Bug
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
You are on page 1/ 13
CLOI cl cLo2 cr CLO! ch SULIT DFC2023:ALGORITHM AND DATA STRUCTURE SECTION B : 70 MARKS: BAHAGIAN B : 70 MARKAH INSTRUCTION: This section consists of FOUR (4) structured questions. Answer ALL questions. ARAHAN: Bahagian ini mengandungi EMPAT (4) soalan berstruktur. Jenvab semua soalan, QUESTION 1 SOALAN 1 a) Define data structure. Berikan definisi struktur data, [2 marks) [2 markah} b) State ONE (1) application of data structure in real life. Nyatakan SATU (1) aplikasi struktur data dalam kehidupan sebenar. [2 marks] [2 markah] ©) Node consists of TWO (2) parts which are __and . Nod terdiri daripada DUA (2) bahagian iaitu i dan [2 marks] (2 markah] n suLiT SULIT DEC2023:ALGORITHM AND DATA STRUCTURE, CLO? | 6) Draw the resulting linked list after each of the operations below is exeented. Assuming C3 the original linked list is given in Figure B1. Lakarkan gambarajah bagi operast senarai berpaut yang diberi berdasarkan Rajah Bl. >[R +| z faim Figure BI / Rajah BI |. Insert a node at the starting with data W. Selitkan nod pada permulaan dengan data W. [2 marks] (2 markati| CLO2 |e) Differentiate berween push and pop. Bezakam di antara ‘push’ dan ‘pop [2 marks} | [2 markah 2 suLIT suLIT DFC2023:ALGORITHM AND DATA STRUCTURE CLO3 1) Figure B2 shows the top of stack implemented using array, cl Rajah B2 menunjukkan ‘top’ bagi tindanan menggunakan tatasusunan, ToP| [0] L Figure B2 / Rajah B2 | Drawa stack data structure in Figure B2 using a linked list. Then, show top of the Stack. Lukiskan tindanan bagi siruktur data menggunakan array dalam Rajah B2 kepada tindanan senarai berpaut. Kenvudian, tunjukkan top bagi tindanan tersebut [2 marks] [2 markai] 13 suLit CLO3 cl cLo2 c2 SULIT DFC2023:ALGORITHM AND DATA STRUCTURE, | QUESTION 2 SOALAN 2 a) Ifthe characters "DC, 'B' 'A' are placed in a queue (in order), and then removed one character at a time, identify the order of the deleted characters? Jika aksara'D',‘C’,'B', ‘A’ ditempatkan di dalam giliran (mengikut susunan), dan kemudian aksara tersebut dihapuskan satu aksara pada satu-satu masa, kenalpasti apakah susunan aksara yang dihapuskan? (2 marks} [2 markah] b) Figure B3 show the queue implemented using linked list. Rajah B3 menunfukkan opevasi giliran menggunakan senarai berpaw e 80) uu Figure B3 / Rajah B3 Redraw queue based on each of the operation given below. Lukis semua giliran berdasarkan kepada kod yang dtberi i, Enqueue (90, &S) ii, Dequeue (&S) [4 marks] [4 markah] 4 SULIT CLO3 C2 CLO3 cl suLIT DFC2023:ALGORITHM AND DATA STRUCTURE ©) Draw the Circular Queue according to the segment code below. Lukiskan ‘Circular Queue' berdasarkan kod seginen di bawah. typedef struct Queue { int Sront,rear,count; int eQueue[3]; JoQueves void create(eQueue *eq) { eq fron! eqerear = 0; oq->count = 0; 3 {2 marks] [2 markali| 4d) Figure B4 shows the binary tree, Identify what is the result of Rajah Bd memunjukkan pokok dedua seperti di bawah. Kenalpasti apakah keputusan bogi: G rN D t ‘ f B x un ws ac Ik \ P Figure B4 / Rajah B4 i. Preorder traversal/ penyusuran ‘Preorder’ ii, Inorder traversal’ penyusuran ‘Inorder' iii, Postorder traversal’ penyusuran ‘Postorder’ [6 marks] [6 markah} 1s suLIT suuir DFC2023:ALGORITHM AND DATA STRUCTURE CLO3 |e) Sketch a Binary Search Tree (BST) by inserting node in sequence using the characters c3 given. Lakarkan Carian Pokok Dedua dengan memasukkan nod secara berturutan menggunakan aksara yang di beri Cer EE Eee eeee C,0,M,P,U,T.E [2 marks] [2 markal Loz |) Refer to Figure BS, identify the methods of sorting that has been used cl Merujuk kepada Rajah BS, kenalpasti kaedah susunan yang telah digunakan, | Figure BS / Rajah BS [2 marks} [2 markah] CLO2 |g) Differentiate between linear search and binary search. C2 Bezakan ai amara carian linear dan earian dedua. [2 marks) [2 markah] 16 suuir CLO3 C3 SULIT DFC2023:ALGORITHM AND DATA STRUCTURE bh) Show the steps to solve problem by using selection sort algorithm to sort the sequence of characters below, Tunjukkan cara menggunakan algoritma isih pilthan untuk menyisih berdasarkan urutan aksara di bawah. a [2 markati} 7 suLIT cLol cl cLo2 cl he) b) suLiT QUESTION 3 SOALAN 3 DFC2023:ALGORITHM AND DATA STRUCTURE, List THREE (3) Non-Primitive data types. Senaraikan TIGA (3) jenis data “Non-Primitive”. Write structure declaration based on information in Table BI Tulis pengisytiharan struktur berdasarkan Jadual BL Nama Struktur TYPE NAME DATA TYPE ‘Stucture name Student [Member 17 Ahi 7 ‘Name/Nama 25 character/aksara | Member 2/Abli 2 “Agel Umar | Integer / Nombor Bular ‘Variable structure/ DIP Until 30 records’ Pemboleh ubah structur Sehingga 30 rekod Table BI / Jadual BY [3 marks) [3 markah) [3 marks} [3 markah] SULIT CLO! C2 cLo2 co cLO2 cl svLiT DFC2023:ALGORITHM AND DATA STRUCTURE, ©) Describe THREE (3) differences between list and linked list Describe TIGA (3) perbezaan di antara senarai dan senarai berpaut. [3 marks} [3 markah head ure BG / Rajah B6 4) Write the algorithm to delete the front node in the linked list given in Figure B6. Tulis algoritma untuk hapus nod pertama di dalam senarai berpaut seperti di beri dalam Rajah B6. [3 marks] (8 markahi] ©) Arrange the order of the characters when they are removed (pop) after they are inserted (push) into stack in the following given order. Tunjukkan susunan hnaruf apabila dihapuskan (pop) selepas huruf tersebut dimasukkan (push) ke dalam tindanan seperti susunan berikut ENP [3 marks] [3 markah] 19 SULIT CLO3 ch SULIT DPC2023:ALGORITHM AND DATA STRUCTURE, 1) Sketch a stack diagram to represent each statement when it is being executed by asst the size is 2. State any error if occurred, Lakarkan satu tindanan untuk mewakili setiap penyataan apabila ia dilaksanakan dengan menganggap saiz adalah 2. Nyatakan apa-apa kesalahan yang berlaku. i. Push (2); ii, Posh (11s Popt );, [3 marks] [3 markah 2 SULIT cLo02 cl CLO3 cl SULIT DPC2023:ALGORITHM AND DATA STRUCTURE, QUESTION 4 SOALAN 4 a) Figure B7 is the content of array implementation of a quewe. Show the contents sar after executing the following of the queue and the locations of front and instruction: Rajah B7 di bawah adalah kandungan pelaksanaan tatasunan bagi satu barisan. Tunjukkan kandungan barisan dan lokasi penuding “front” dan “rear" selepas melaksanakan setlap arahan berikut Figure BT / Rajah B7 i, queue.dequene( ); fi, queue.enqueue(7); [3 marks] (3 markafi) b) Based on Figure B8, draw a diagram to show the content of the queue and the location of front and rear after executing queue-enqueue (5); Berdasarkan Rajah B8, lukis gambarajah baharu yang menunjukkan data dan lokasi ‘front “ dan “rear” Giliran selepas melaksanakan queueenqueue (5) Figure B8 / Rajah B8 [3 marks} [3 markah 21 SULIT cLo2 C2 cLo3 C3 SULIT DFC2023:ALGORITHM AND DATA STRUCTURE, ©) Write the resulting output of preorder traversal based on Binary Tree in Figure B9. Tulis hasil output dari “Preorder traversal” berdasarkan Pokok Dedua di dalam Rajah BO. Figure B9 / Rajah BD [3 marks] [3 markak] 4) Based on Binary Tree in Figure B10, draw a new tree when these instructions are executed: Berdasarkan Pokok Dedua yang diberi dalam Rajah B10, lukis pokok yang baharu selepas arahan berikut dilaksanakan. i.) SO @ Figure B10/ Rajah B10 i, delete 12 ii, delete 3 iii, insert 9 [3 marks] [3 markah] 2 suLir cLo2z cz CLO3 C2 SULIT DFC2023:ALGORITHM AND DATA STRUCTURE €} Show the steps to sort the following list in descending order using the Selection Sort Tunjukkan langkah-langkah untuk mengisih senarai di bawah secara menurun menggunakan Isih Pilih | 12, 54, 32, 89,23, 76, 43 [3 marks] {3 markal) f) Solve the problem given by using Binary Scarching Method. Selesaikan masalah yang diberi menggunakan Kaedah Carian Deda. Target Key =3 zp3s74!)]s ] éy7 aw 2] GB 4 {6} [3 marks] [3 markah] 23 SULIT

You might also like