Professional Documents
Culture Documents
CPT112
CPT112
Duration : 2 hours
(Masa : 2 jam)
Please ensure that this examination paper contains EIGHT (8) printed pages before you
begin the examination.
[Sila pastikan bahawa kertas peperiksaan ini mengandungi LAPAN (8) muka surat yang
bercetak sebelum anda memulakan peperiksaan ini.]
[Anda dibenarkan menjawab soalan sama ada dalam bahasa Inggeris atau bahasa
Malaysia.]
…2/-
SULIT
SULIT CPT112
-2-
(i). Identify S ꓵ T
Kenal pasti S ꓵ T
(ii). Identify S – T
Kenal pasti S – T
(iii). Identify S + T
Kenal pasti S + T
(3/100)
(b). Construct a formula that generates the following sequence a1, a2, 23 …. of:
(iii). 2, 0, 2, 0, 2, 0, …
(iv). 0, 2, 0, 2, 0, 2, 0, …
(4/100)
(c) In following questions, nine (9) people (Ann, Ben, Cal, Dot, Ed, Fran, Gail, Hal,
and Ida) are in a room. Five (5) of them stand in a row for a picture.
Bagi soalan-soalan berikut, sembilan (9) orang (Ann, Ben, Cal, Dot, Ed, Fran,
Gail, Hal, dan Ida) berada di dalam satu bilik. Lima (5) daripada mereka berdiri
sebaris untuk mengambil gambar.
…3/-
SULIT
SULIT CPT112
-3-
(i). In how many ways can this be done if Ben is to be in the picture?
(ii). In how many ways can this be done if both Ed and Gail are in the picture?
(iii). In how many ways can this be done if neither Ed nor Fran are in the
picture?
Berapakah cara ia boleh dilakukan jika Ed dan Fran tidak perlu berada
dalam gambar?
(iv). In how many ways can this be done if Dot is on the left end and Ed is on
the right end.
Berapakah cara ia boleh dilakukan jika Dot berada paling kiri dan Ed
berada paling kanan?
(8/100)
(d) (i). Analysis the problem below, then, find and correct the error in the
solution to this problem.
Problem: You flip two (2) coins and want to find the probability that both
coins show heads.
Solution: There are three (3) possible outcomes: two (2) heads, two (2)
tails, or one (1) head and one (1) tail. Since a “success” is one (1) of
these three (3) outcomes, p(both heads) = 1/3.
…4/-
SULIT
SULIT CPT112
-4-
(iii). You pick a word at random from the set of all words of length six of letters
of the alphabet with no repeated letters. What is the probability that the
word has exactly one vowel?
(iv). A red and green die are rolled. What is the probability of getting a sum
of six, given that the number on the green die is odd?
Satu dadu merah dan satu dadu hijau dibaling. Apakah kebarangkalian
mendapat hasil enam, diberi nombor pada dadu hijau itu adalah nombor
ganjil?
(10/100)
(2). (a). Prove by mathematical induction that, for whenever n is a positive integer,
13 + 33 + 53 + … + (2n +1)3 = (n+1)2(2n2 +4n +1)
(10/100)
…5/-
SULIT
SULIT CPT112
-6-
(b). Construct the recurrence solution to get the closed formula based on:
an = 3an-1 + 2 with initial value a0 = 1
(10/100)
(5/100)
(4/100)
(7/100)
…6/-
SULIT
SULIT CPT112
-6-
(c). APEX Airline System (AAS) has announced a new daily route among five major cities;
Penang (PP), Kuala Lumpur (KL), Singapore (SG), Jakarta (JK) and Bali (BL). The
available routes are the corresponding fares are listed in the following table.
Sistem Penerbangan APEX (AAS) telah mengumumkan laluan harian baru di antara
lima bandar utama; Penang (PP), Kuala Lumpur (KL), Singapura (SG), Jakarta (JK)
dan Bali (BL). Laluan yang tersedia dengan tambang-tambang yang bersepadanan,
disenaraikan dalam jadual berikut.
From\ To PP KL SG JK BL
PP - RM 300 - RM 200 RM 800
KL RM 300 - RM 200 - -
SG RM 200 - RM 600 -
JK RM 600 - RM 400
BL RM 800 - - RM 400 -
(i). Using the above information, prepare a graph where the nodes indicate the
cities while the edges indicate the corresponding flight fares.
(ii). Use Dijkstra's Algorithm to find the shortest path length between Penang and
Bali from the weighted graph found in 3-(c)-(i). Show your work.
(4). (a). Refer to your graph in 3-(c)-(i) when answering the following questions. When visiting
the nodes, please visit the nodes in an alphabetical order (Bali, Jakarta, Kuala Lumpur,
Penang, Singapore). Show your work.
Rujuk kepada graf anda dar jawapani 3-(c)-(i) apabila menjawab soalan-soalan
berikut. Apabila melawat nod, sila lawati nod dalam susunan abjad (Bali, Jakarta,
Kuala Lumpur, Pulau Pinang, Singapura). Tunjukkan jalan kerja anda.
…7/-
SULIT
SULIT CPT112
-7-
(ii). Generate the minimum spanning tree resulting from Prim's algorithm.
(3/100)
(iii). Generate the minimum spanning tree resulting from Kruskal's algorithm.
(3/100)
(b). Answer the following questions based on the following transition table where S0 is the
start state and S3 is the only accepting state:
input f
states 0 1
s0 s1 s2
s1 s2 s0
s2 s1 s3
s3 s3 s1
(i). Generate the finite state machine associated to the given transition table.
(2/100)
(ii). Generate the simplest phrase structure grammar, G = (V, T, S, P), for the
machine.
(4/100)
…8/-
SULIT
SULIT CPT112
-8-
Reformulasi tata bahasa yang anda temui dalam 4-(b)-(ii) dalam notasi BNF.
(4/100)
(iv). Identify the result for input string 1111, of the finite state machine in 4-(b)-(i).
Kenal pasti keputusan untuk input 1111, dari mesin keadaan terhingga yang
ditemui dalam 4-(b)-(i).
(2/100)
(c). “x+y+5 where x=5, y=6” is a sentence defined by an unknown context-free grammar.
The following diagram is the parse tree for the sentence. Based on what are given,
generate a simple BNF notation that can be a possible a context-free-grammar for the
given sentence.
"x + y + 5 where x = 5, y = 6" adalah ayat yang ditakrifkan oleh tatabahasa bebas
konteks yang tidak diketahui. Gambar rajah berikut adalah pohon parse untuk ayat
tersebut. Berdasarkan kepada maklumat yang diberikan, hasilkan satu notasi BNF
yang mudah, yang boleh menjadi tatabahasa bebas konteks untuk ayat yang
diberikan.
(5/100)
- oooOooo -
SULIT