0% found this document useful (0 votes)
31 views2 pages

Circle Red-Node Triangle Black-Node

The document is an exam paper for a course on algorithms at Fu Jen Catholic University, detailing the exam rules and structure. It includes various tasks related to binary trees, graph theory, and algorithm design, with specific questions and percentages allocated to each section. The exam is scheduled for June 16, 112, and emphasizes adherence to academic integrity during the examination process.

Uploaded by

jason036510
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)
31 views2 pages

Circle Red-Node Triangle Black-Node

The document is an exam paper for a course on algorithms at Fu Jen Catholic University, detailing the exam rules and structure. It includes various tasks related to binary trees, graph theory, and algorithm design, with specific questions and percentages allocated to each section. The exam is scheduled for June 16, 112, and emphasizes adherence to academic integrity during the examination process.

Uploaded by

jason036510
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/ 2

期中 畢業

天主教輔仁大學 ■學期 補考 考 試 試 題 (共 2 頁第 1 頁)
科目: 演算法 系級組別: 資訊工程學系 考試日期:112 年 6 月 16 日第 2 與 3 節
命題教授: 張信宏 先生(簽章) 112 年 6 月 03 日 需用份數:90 份 總分: 130

依據本校 98 學年度學生獎懲委員會第 1 次會議臨時動議決議辦理。於本命題紙上加印考試規則第 10 條;請主試老師或監考助教


於監考時能宣讀考試規則第 10 條,以提醒同學遵守考試規則,不要作弊。
考試規則第 10 條:學生於考試時,不得夾帶、抄襲、傳遞、交換答案卷、以自誦或暗號告人答案、或故意將答案供人窺視抄襲、
或將考試科目內容製作於桌上或其他物體等舞弊情事。違者除該科該次成績以零分計算外,並予記大過以上處分。

(1) (50%) Please use the following insertion order to build four kinds of binary trees.

A 1 2 3 4 5 6 7 8 9 10 11 12
5 3 12 11 7 9 8 2 6 4 10 13

(a) (8%) red-black tree. (Use circle O to represent red-node and triangle △ to represent black- node).
(b) (7%) 234-Tree.
(c) (7%) Splay Tree (note: Total insertions for building a BST are completed and then user will find(11)).
(d) (8%) Please build an AVL tree from A[1] to A[11].
(e) (8%) Please build a segment tree for solving range max query.
(f) (5%) Use the segment tree in (e) and demonstrate how to get max value from index 3 to 10.
(g) (7%) Please build a bit index tree (BIT) for solving range sum query.

(2) (40%) Graph Theory.

(a) (I) (15%) Please demonstrate the SPFA algorithm to solve the shortest path from node 0 to other nodes in
the following graph.
_

(II) (10%) Please demonstrate the Dijkstra algorithm to solve the shortest path from node 0 to other nodes
in the following graph.

(b) (I) (10%) Please use dinic algorithm to find the maximum flow from source node 1 to sink node 6 in the
following directed graph. (II) (3%) Explain “minimum cut is equal to maximum flow. (III) (2%) Explain
“flow conservation property in node 2”?
期中 畢業
天主教輔仁大學 ■學期 補考 考 試 試 題 (共 2 頁第 2 頁)
(3) (40%) Algorithm Design.

(a) (10%) Cars arrive at the train station in the following order. When each car arrives, you can add it to the
beginning or end of the car-chain, or refuse to add it. Please show the longest increasing car-chain you can
arrange?

9 8 12 6 14 10 3 13 1 4

(b) (10%) OPTi indicates optimal sum of a subarray in array A[i] and OPT*(i) indicates max sum of a subarray
with ending at A[i]. Please use Design a O(n) algorithm to find maximum sub-array in the following array
and fill in the OPT(i) and OPT*(i) of following table. The initial values of OPT(i) and OPT*(i) are zero.

A 1 2 3 4 5 6 7 8 9 10 11
1 -3 8 5 -2 6 3 -5 4 -6 7
OPT(i)
OPT*(i)

(c) (10%) Given a double ended queue (dequeue) with permutation of numbers from 1 to n (n≥5), we want to
remove all of the numbers to form a sequence <a1, a2, a3, …,an> that maximizes the alternative sum
(a1-a2+a3…±an), where a1 is the first number removed, a2 is the second number, and so on. Please design
an O(n2) dynamic programming algorithm to generate the optimal sequence for a given permutation <5, 4,
1, 2, 3>.

(d) (10%) Find the articulation points in the following graph. Redraw the graph showing tree edges, back
edges, the DFS number and LOW value assigned to each vertex. For definiteness, start your DFS at
vertex A and whenever the algorithm has a choice of which edge to follow next, pick the edge to the
alphabetically(字典序小的先) first vertex among the vertex choices.

You might also like