0% found this document useful (0 votes)
6 views5 pages

2003 D

The document is an examination paper for the CSIS1118 Foundations of Computer Science course at the University of Hong Kong, dated December 31, 2003. It includes various questions covering topics such as equivalence relations, big O notation, logical propositions, combinatorial problems, algorithms, graph theory, and finite state machines. Candidates are required to answer all questions, with specific guidelines on calculator usage and scoring.

Uploaded by

peak
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)
6 views5 pages

2003 D

The document is an examination paper for the CSIS1118 Foundations of Computer Science course at the University of Hong Kong, dated December 31, 2003. It includes various questions covering topics such as equivalence relations, big O notation, logical propositions, combinatorial problems, algorithms, graph theory, and finite state machines. Candidates are required to answer all questions, with specific guidelines on calculator usage and scoring.

Uploaded by

peak
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/ 5

THE UNIVERSITY OF HONG KONG

FACULTY OF ENGINEERING
DEPARTMENT OF COMPUTER SCIENCE AND INFORMATION SYSTEMS

CSIS1118 Foundations of computer science

Date: December 3 l, 2003 Time: 9:30 am - 12:30 pm

Candidates may use any calculator which fulfils the following criteria: (a) it should be
selj~contained, silent, battery-operated and pocket-sized; (b) it should have numeral-
display facilities only and should be used only for the purpose of calculation; ( c) it should
not have any printing device, alphanumeric keyboard, or graphic display; and ( d) it
should not contain any recorded data or program. It is the candidate's responsibility to
ensure that the calculator operates satisfactorily and the candidate must record the name
and type of the calculator on the front page of the examination scripts. Lists of
permitted/prohibited calculators will not be made available to candidates for reference,
and the onus will be on the candidate to ensure that the calculator used will not be in
violation of the criteria listed above.

Answer ALL questions. Each question carries 10 points. Total score is 130 points.

Question 1

(a) Let T be the set of all triangles in the plane. For t 1 and t 2 E T, define ti 9\ t2 if ti, t2
have the same area. Determine whether 9\ is an equivalence relation or a partial
ordered relation.

(b) Let T be the set of all triangles in the plane. For t 1 and t2 E T, define t1 9\ t2 if t1 has
an area larger than or equal to the area of t2 . Determine whether 9\ is an equivalence
relation or a partial ordered relation.

Question 2

(a) Givcn.f(n) = n2 + IOOn + 3, show thatf(n) = O(n\


[Hint: Start with the definition of big 0 notation, find the constants that can show f(n)
2
= O(n ).]

(b) List the functions below from lowest order to highest order n, 2n, nlogn, logn,
7 n 5-n 3+n, _-Yn,
I n 2+1ogn, (1 ogn )2 , n l..

. ... ./Question 3
Question 3

(a) Let p, q, r be the propositions


p: You get an A on the final exam.
q: You do every exercise in this book.
r: You get an A in this course.
Write the following propositions using p, q, rand logical connectives.
(i) You get an A in this course, but you do not do every exercise in this book.
(ii) To get an A in this course, it is necessary for you to get an A on the final.
(iii) Getting an A on the final and doing every exercise in this book is sufficient for .
getting an A in this course.
(iv) You will get an A in this course if and only if you either do every exercise in
this book or you get an A on the final.

(b) Consider the open statement


p(x, y) : y - x =y + x2
where the universe for each of the variables, x, y comprises all integers.

Determine and prove the truth-value for each of the following statements.

(i) Vy p(O, y)
(ii) 3y p(l, y)
(iii) Vx 3y p(x, y)
(iv) 3y Vx p(x, y)
(v) Vy 3x p(x, y)

Question 4

Let S be a set of five positive integers the maximum of which is at most 9. Prove that the
sums of the elements in all non-empty subsets of S cannot all be distinct.
[Hint: (1) Are all the integers in S distinct? (2) Consider all the subsets of size 3 or less,
i.e., compare the number of these subsets and maximum sum af a subset of si::.e 3.]

Question 5

(a) Which is more likely: rolling a total of 9 when two dice are rolled or rolling a total of
9 when three dice are rolled. Give a proof for your claim.

(b) What is the conditional probability that a randomly generated bit-string of length
four contains at least two consecutive Os given that the first bit is a 1. (Assume the
probabilities of a 0 and a 1 are the same.)

.... ./Question 6

2
Question 6

Consider the following algorithms.


(i) Procedure A(n)
(ii) If n = 1 then return 1
(iii) else return (A(n-1) + 1)

When A(n) is invoked, we have


A (n) = { A ( n - 1) + 1 when n > 1
1 when n = 1

(a) What is the value of A(n)?

(b) If line (iii) is replaced by


else return (2A(n/2) + 1)
What is the value of A(n) when n = 2k for some integer k ~ O?

(c) If line (iii) is replaced by


else return (4A(n/2) + n)
What is the value of A(n) when n =2k for some integer k ~ O?

Question 7

In how many ways can six identical (indistinguishable) balls are assigned to three bins {A,
B, C} if
(i) each bin contains any number of balls
(ii) each bin contains at least one ball
(iii) each bin contains at least two balls
(iv) bin A contains at least four balls
(v) each bin contains at most three balls [Hint: inclusion and exclusion]

Question 8

Determine which of the graphs in following figures are planar. Prove your claim.

a a

d b

d c

.... ./Question 9

3
Question 9

In chess, a knight's move consists of moving two squares


horizontally or vertically and then one square in the perpendicular x x
direction. The board on the right shows that a knight on square K can x x
move to any squares marked X.
K

A knight's tour on an n x n board, begins at some square, visits each x x


square exactly once by legal moves and returns to the initial square. x x

(a) Model this problem by a graph, i.e., define V and E of the graph and state the graph
problem corresponding to the knight's tour problem.

(b) Show that this graph is a bipartite graph.


[Hint: consider the chess board on the right, the set of white and
black squares. J

(c) Show that there does not exist a knight's tour when n is odd.

Question 10

(a) A domino is a rectangular block divided into two squares with each square numbered
one of 0, 1, 2, 3, 4, 5, 6 (see the figure for examples). Two squares on a single

a·. 8B::
domino can have the same number.

(i) How many distinct dominos are there?


(ii) Show that the distinct dominoes can be arranged • : • • • •
in a circle so that touching dominoes have •• • • • • : :
adjacent squares with identical numbers.

(b) What are the chromatic numbers of the following graphs:

(i) Kn.m
(ii) Wheel Wn
(iii) Full m-ary tree
(iv) Multi-stage graph where Vis partitioned in m sets, Vi, V2, ... , Vm and edges are
only connected between Vi and Vi+l where 1 :::; i < m.
(v) Planar graph

.... ./Question 11

4
Question 11

(a) Let T be a binary tree with n vertices, what is the maximum height that T can attain?
What is the minimum height? Give the drawings in these two cases.

(b) Let T be a binary search tree for 3 elements, each with an accessing probability.
(i) Give a situation that the maximum height tree will give the minimum cost tree?
(ii) Give a situation that the minimum height tree will give the minimum cost tree?
Prove your claim.
[Note that a minimum cost tree gives the lowest expected number of comparisons for
searching.]

Question 12

Given a text and a pattern formed from the alphabet {A, B, C}, the pattern matching
problem is to find the position in the text where the pattern occurs. With the help of finite
state machine, the pattern can be found efficiently.

(a) Construct the finite state machine for the pattern A BA A C.

(b) Let the text be BAB A CA A B CAB A BA A A BA A BA A CB. Give the


transitions of states when the above text is traced.

Question 13

(a) Draw the state diagram for the finite state machine defined by Table 1.

next state output

~
e
0 1 0 1
So So S1 0 0
S1 So S1 1 1
Table 1

(b) Determine the output for the following sequences, assuming s0 is the initial state

(i) x =1 1 1
(ii) x = 10 10

(iii) x = 0 0 0 1 1

(c) Describe in words what this finite state machine does.

END OF PAPER

You might also like