計算機概論 試題
(資訊科學系碩士班)
※請注意:1.本試題共二頁。
2.答案須寫在答案卷上,否則不予計分。
問答題(共 100 分)
1. Consider the following structure of the instruction register.
What is the maximum number of distinct operation codes that can be recognized and executed
by the processor on this machine? What is the maximum memory size on this machine? (10
分)
第 1 頁,共 2 頁
f (n, 10, 0);
(d). for (unsigned int i = 0; i < n; ++i)
for (unsigned int j = i; j < n; ++j)
f (n, m, k);
4. Explain the operation of my fun(v) on some vertex v of the given graph.
Here `graph' in line 7 is an adjacency list for representing graph. (10 分)
1 #define MAX_VERTICES 50
2 typedef struct node *node_pointer;
3 typedef struct node{
4 int vertex;
5 struct node *link;
6 };
7 node_pointer graph[MAX_VERTICES];
8
9 void my_fun(int v)
10 {
11 node_pointer w;
12 visited[v] = TRUE;
13 printf("%5D",v);
14 for (w = graph[v]; w; w = w->link)
15 if(!visited[w->vertex])
16 my_fun(w->vertex);
17 }
5. Write the postfix form of the following expressions: (a) -a+b-c+d (b) a*-b+c (c) (a+b)*d+e/
(f+a*d)+c (6 分)
6. The Fibonacci numbers are defined as: f 0 = 0, f 1 = 1, and f i −1 + f i −2 for i > 1 . Write a program to
compute fi . (14 分)
7. There are three towers and 64 disks of different diameters placed on the frst tower. The disks
are in order of decreasing diameter as one scans up the tower. Monks were reputedly supposed
to move the disk from tower 1 to tower 3 obeying the rules: (a) Only one disk can be moved at
any time. (b) No disk can be placed on top of a disk with a smaller diameter. Write a recursive
function that prints out the sequence of moves needed to accomplish this task. (20 分)
第 2 頁,共 2 頁