Sub-Question 1 From the answer group below, select the correct answer to insert in the blank box in the truth table of the full adder.. From the answer group below, select the correct a
Trang 1MINISTRY OF SCIENCE AND TECHNOLOGY
HOÀ L C HIGH TECH PARK
MANAGEMENT BOARD
VIETNAM IT EXAMINATION AND
TRAINING SUPPORT CENTER (VITEC)
FUNDAMENTAL
INFORMATION TECHNOLOGY
ENGINEER EXAMINATION
SÁT H CH
K S CÔNG NGH THÔNG TIN
C B N Ngày 26 tháng 1 n m 2003
Ph n thi bu i chi u
Không m đ thi tr c khi đ c phép
Trang 2Date of Birth Examinee Number
Year Month Day
Class II Information Technology Engineer Examination - Afternoon
Fundamental IT Engineer Examination (Afternoon) Questions must be answered in accordance with the following:
Mark the s of the question you select to answer in the “Selection Column” on your answer sheet
(4) Answers
Mark your answers as shown in the following sample question
[Sample Question]
In which month is the Spring Fundamental IT Engineer Examination conducted?
a) March b) April c) May d) June
Since the correct answer is “b” (April), mark your answer sheet as follows:
[Sample Reply]
a
3 This test booklet will be picked up at the end of the test Your test will not be graded unless you turn this test booklet in
4 Assembler specifications are provided as a reference at the end of this booklet
Do not open the exam booklet until instructed to do so
Trang 3Class II Information Technology Engineer Examination - Afternoon
Sát h ch k s Công ngh thông tin c b n (Bu i chi u)
2 ánh d u thông tin sát h ch và câu tr l i sát h ch c a b n theo h ng d n d i đây Bài sát
h ch c a b n s không đ c ch m n u b n không đánh d u đúng ng đánh d u hay vi t lên t
gi y tr l i bên ngoài ch đã qui đ nh
4 Các đ c t h p ng đ c cung c p làm tài li u tham kh o t i cu i c a t p gi y thi này
làm nh v y M i vi c h i thêm v các câu h i sát h ch s
Trang 4Company names and product names appearing in the test questions are trademarks or registered trademarks of their respective companies Note that the ® and ™ symbols are not used within
Trang 5Tên công ti và tên s n ph m xu t hi n trong các câu h i sát h ch là th ng hi u hay th ng hi u đã đ ng kí c a các công ti đó Chú ý r ng các kí hi u ® và ™ không đ c dùng bên trong
Trang 6Questions 1 through 5 are complusory Answer every question
Q1 Read the following descriptions of logical operations and full adders, and then answer
Sub-Questions 1 through 3
(1) The logical circuit symbols for the main logical operations are as follows
Logical operation name
Logical circuit
symbols
Logical product
(A, B: Input, Z: Output) B
A
Z B
A
Z B
Fig Full Adder (k th digit)
Table: Truth Table of Full Adder
Trang 7Các câu h i 1 t i 5 là b t bu c Hãy tr l i m i câu h i
Q1 Hãy đ c nh ng mô t d i đây v các phép toán logic và b c ng đ y đ , sau đó tr l i các
câu h i con 1 t i 3
(2) Các kí hi u m ch logic cho các phép toán logic chính nh sau
Logical operation name
Logical circuit
symbols
Logical product
(A, B: Input, Z: Output) B
A
Z B
A
Z B
(2) Sau đây là hình v b c ng đ y đ , th c hi n vi c c ng các s nh phân theo t ng
ch s có tính t i vi c nh B ng đ c d i đây là b ng chân lí cho b c ng đ y đ
Trang 8Sub-Question 1
From the answer group below, select the correct answer to insert in the blank box
in the truth table of the full adder
Answer group:
Sub-Question 2
From the answer group below, select the correct answer to insert in the blank box
in the logical circuit of the full adder
Trang 11Câu h i con 3
Khi m t m ch logic đ c c u t o b ng các b c ng đ y đ đ c ng các s nh phân n-ch
s đ c bi u di n nh ph n bù hai, vi c c ng các ch s có ý ngh a nh t (An, Bn và Cn) gây ra s tràn (ph n tô đ m c a b ng chân lí c a b c ng đ y đ ) M ch logic đ phát hi n
vi c này có th đ c c u t o b ng m t m ch XOR Hãy ch n t nhóm câu tr l i d i đây
t h p đúng c a các đ u vào X và Y cho m ch logic này
Trang 12Q2 Read the following descriptions about decision tables and answer Sub-Questions 1 and 2
Mr A is designing a module to calculate domestic travel allowances as part of a business travel management system for company B Company B specifies the following rules on daily allowances for domestic business travel (per diem, meal allowance and lodging expense)
(1) The company shall pay ¥500 per diem when the distance one-way from the company
to the destination is less than 20 km
(2) The company shall pay ¥1,000 per diem when the distance one-way from the
company to the destination is 20 km or more but less than 120 km, and the employee works less than 8 hours at the destination If the employee works 8 hours or more at the destination, the company shall pay ¥1,000 per diem and ¥500 as meal allowance (3) The company shall pay ¥2,000 per diem when the distance one-way from the
company to the destination is 120 km or more, and the employee works less than
8 hours at the destination If the employee works 8 hours or more at the destination, the company shall pay ¥2,000 per diem and ¥500 as meal allowance
(4) If business travel requires overnight lodging, the company shall pay ¥10,000 per night as lodging expense
The following decision table was created on the rules of company B to calculate daily expenses for domestic business travel
Decision Table for Domestic Travel Expenses of Company B Less than 20 km one-way Y Y N N N N N N N N More than 20 and less than 120 km one-way N N Y Y N N N N
Pay ¥500 food allowance – – – –
Pay ¥10,000 lodging expense X – X – X – X – X –
Note: In the Conditions section, “Y” means true, “N” means false and “-” means neither
Trang 13Q2 Hãy đ c các mô t d i đây v b ng quy t đ nh và tr l i các câu h i con 1 và 2
Ông A đang thi t k m t mô đun đ tính chi tiêu đi công tác n i đ a nh m t ph n c a h
th ng qu n lí đi công tác cho công ti B Công ti B xác đ nh các qui t c sau v chi tiêu hàng ngày cho vi c đi công tác n i đ a (công tác phí, ti n n và chi phí tr )
(1) Công ti s tr ¥500 công tác phí khi kho ng cách m t chi u t công ti t i n i đ n nh
h n 20 km
(2) Công ti s tr ¥1,000 công tác phí khi kho ng cách m t chi u t công ti t i n i đ n là
20 km hay l n h n nh ng v n nh h n 120 km, và nhân viên làm vi c ít h n 8 gi t i
n i đ n N u nhân viên làm vi c 8 gi hay nhi u h n t i n i đ n, công ti s tr
¥1,000 công tác phí và ¥500 ti n n
(3) Công ti s tr ¥2,000 công tác phí khi kho ng cách m t chi u t công ti t i n i đ n là
120 km hay l n h n, và nhân viên làm vi c ít h n 8 gi t i n i đ n N u nhân viên làm vi c 8 gi hay nhi u h n t i n i đ n, thì công ti s tr ¥2,000 công tác phí và
120 km hay h n m t chi u N N N N Y Y Y Y Làm vi c 8 gi hay h n t i n i đ n – – Y Y N N Y Y
Trang 14Title of Table
Conditions Condition
description
Condition specification
Description Specification
Action description
Trang 15Title of Table
Conditions Condition
description
Condition specification
Description Specification
Action description
Trang 16Sub-Question 2
Rule (3) was revised as follows Which of the following descriptions are incorrect with the
revised decision table?
Choose from the following
a) A “Pay ¥1,000 food allowance.” line must be added to the Actions section
b) There is no need to change the action specification for per diem
c) There is no need to change the action specification for lodging expense
d) There is no need to change the action specification of “Pay ¥500 food allowance.” e) There is no need to change the Conditions section
Trang 17Câu h i con 2
Qui t c (3) đ c s a l i nh d i đây Mô t nào trong nh ng mô t sau là không đúng v i
b ng quy t đ nh đã đ c s a l i?
[Qui t c đã s a l i (3)]
Công ti s tr ¥2,000 công tác phí khi kho ng cách m t chi u t công ti t i n i đ n là 120
km hay h n, và nhân viên làm vi c ít h n 8 gi t i n i đ n N u nhân viên làm vi c 8 gi hay h n t i n i đ n nh ng không c n l i, công ti s tr ¥2,000 công tác phí và ¥1,000
ti n n N u nhân viên làm vi c 8 hay h n t i n i đ n và c n ngh l i đêm, công ti s tr
¥2,000 công tác phí và ¥500 ti n n
Hãy ch n t các mô t sau
a) Dòng “Tr ¥1,000 ti n n.” ph i đ c thêm vào ph n Hành đ ng
b) Không c n thay đ i đ c t hành đ ng đ i v i công tác phí
c) Không c n thay đ i đ c t hành đ ng đ i v i chi phí tr
d) Không c n thay đ i đ c t hành đ ng c a “Tr ¥500 ti n n.”
e) Không c n thay đ i ph n i u ki n
Trang 18Q3 Read the following description about the relational database and answer Sub-Questions 1
the following description
True is returned for the EXISTS predicate when the table sub-query result exists, and false
is returned if it does not exist When the following SQL statement is executed, the selected
SELECT EMPLOYEE_NUMBER FROM EMPLOYEE_SKILL_TABLE WHERE EXISTS (SELECT * FROM EMPLOYEE_SKILL_TABLE
The EXISTS predicate evaluates each respective row if the specified sub-query contains a reference to a table different from that in the main query When the following SQL
statement is executed, the selected employee number is b
SELECT EMPLOYEE_NAME FROM EMPLOYEE_TABLE A WHERE EXISTS (SELECT * FROM EMPLOYEE_SKILL_TABLE B WHERE SKILL_CODE = 'FE”
AND A.EMPLOYEE_NUMBER = B.EMPLOYEE_NUMBER)
Trang 19Q3 Hãy đ c mô t d i đây v c s d li u quan h và tr l i các câu h i con 1 t i 3
C s d li u quan h sau bao g m m t b ng nhân viên và b ng k n ng nhân viên
trong mô t sau
EXISTS cho l i true khi k t qu câu truy v n con vào b ng t n t i, và cho l i false n u nó không t n t i Khi câu l nh SQL sau đây đ c th c hi n, s hi u nhân viên đ c ch n là
SELECT EMPLOYEE_NUMBER FROM EMPLOYEE_SKILL_TABLE WHERE EXISTS (SELECT * FROM EMPLOYEE_SKILL_TABLE
EXISTS tính t ng hàng t ng ng n u câu truy v n con đ c xác đ nh có ch a m t tham
chi u t i b ng khác v i b ng trong câu truy v n chính Khi câu l nh SQL sau đây đ c
th c hi n, s hi u nhân viên đ c ch n là b
SELECT EMPLOYEE_NAME FROM EMPLOYEE_TABLE A WHERE EXISTS (SELECT * FROM EMPLOYEE_SKILL_TABLE B WHERE SKILL_CODE = 'FE”
AND A.EMPLOYEE_NUMBER = B.EMPLOYEE_NUMBER) Nhóm câu tr l i:
Trang 20Sub-Question 2
Which of the following employee_numbers is the following SQL statement requesting?
SELECT DISTINCT EMPLOYEE_NUMBER FROM EMPLOYEE_SKILL_TABLE B1 WHERE EXISTS (SELECT * FROM EMPLOYEE_SKILL_TABLE B2 WHERE B1.EMPLOYEE_NUMBER = B2.EMPLOYEE_NUMBER
Answer group:
a) An employee who has at least one skill
b) An employee who has only one skill
c) An employee who has no skills
d) An employee who has multiple skills
Sub-Question 3
You want to add the employee’s name to the information obtained in Sub-Question 2 From the answer group below, select the correct answer to insert in the blank box in the following description?
SELECT DISTINCT A.EMPLOYEE_NUMBER, EMPLOYEE_NAME FROM EMPLOYEE_TABLE A, EMPLOYEE_SKILL_TABLE B1
WHERE EXISTS (SELECT * FROM EMPLOYEE_SKILL_TABLE B2 WHERE B1.EMPLOYEE_NUMBER = B2.EMPLOYEE_NUMBER
Answer group:
b) BETWEEN A.EMPLOYEE_NUMBER AND B1.EMPLOYEE_NUMBER
d) OR A.EMPLOYEE_NUMBER = B1.EMPLOYEE_NUMBER
Trang 21Câu h i con 2
Câu l nh SQL sau yêu c u nh ng s hi u nhân viên (employee_numbers) nào?
SELECT DISTINCT EMPLOYEE_NUMBER FROM EMPLOYEE_SKILL_TABLE B1 WHERE EXISTS (SELECT * FROM EMPLOYEE_SKILL_TABLE B2 WHERE B1.EMPLOYEE_NUMBER = B2.EMPLOYEE_NUMBER
Nhóm câu tr l i:
a) Nhân viên có ít nh t m t k n ng
b) Nhân viên ch có m t k n ng
c) Nhân viên không có k n ng
d) Nhân viên có nhi u k n ng
Câu h i con 3
B n mu n thêm tên nhân viên vào thông tin thu đ c trong câu h i con 2 T nhóm câu tr
l i d i đây, hãy ch n câu tr l i đúng đ đi n vào h p tr ng trong mô t sau?
SELECT DISTINCT A.EMPLOYEE_NUMBER, EMPLOYEE_NAME FROM EMPLOYEE_TABLE A, EMPLOYEE_SKILL_TABLE B1
WHERE EXISTS (SELECT * FROM EMPLOYEE_SKILL_TABLE B2 WHERE B1.EMPLOYEE_NUMBER = B2.EMPLOYEE_NUMBER
Nhóm câu tr l i:
b) BETWEEN A.EMPLOYEE_NUMBER AND B1.EMPLOYEE_NUMBER
d) OR A.EMPLOYEE_NUMBER = B1.EMPLOYEE_NUMBER
Trang 22Q4 Read the explanations about the following program and pseudo-language syntax, and the
program itself, then, answer Sub-Questions 1 and 2
[Program Description]
This is a sub-program known as QuickSort that quickly sorts elements from A [Min]
to A [Max] in an integer-type one-dimensional array A where 0 Min < Max
(1) Sorting procedures are as follows
differ from the value of A [Min], compares the value of the first found element against A [Min], and selects the larger of the two as the base value (Pivot) If all
of the elements in the array are the same, sort processing ends For selecting the criteria value, a sub-program known as FindPivot is used
Elements are rearranged so that all elements less than the pivot are A [Min], …,
A [i - 1] (Min < i Max) and all elements equal to or greater than the pivot are
A [i], …, A [Max] A sub-program known as Arrange performs this processing
[Max]) are treated as two new arrays and sorted by recursively applying QuickSort
(2) Argument specifications for the sub-programs are given in the following tables
Table 1 QuickSort Arguments
Table 2 FindPivot Arguments
Returns subscript of element storing pivot value However,
Trang 23Q4 c mô t ch ng trình d i đây và cú pháp gi ng , và b n thân ch ng trình, sau đó tr
l i các câu h i con 1 và 2
[Mô t ch ng trình]
ây là ch ng trình con có tên QuickSort s p x p nhanh các ph n t t A [Min] sang
A [Max] trong m ng m t chi u các s nguyên A v i 0 < Min < Max
(1) Th t c s p x p nh sau
giá tr c a A [Min], so sánh giá tr c a ph n t đ c tìm th y đ u tiên v i A [Min], và ch n s l n trong hai s này là giá tr c s (Pivot) N u t t c các ph n
t trong m ng đ u gi ng nhau, thì vi c x lí s p x p k t thúc M t ch ng trình con
có tên FindPivot đ c dùng đ ch n giá tr tiêu chu n
Các ph n t đ c b trí l i đ cho t t c các ph n t bé h n pivot là A [Min],
…, A [i - 1] (Min < i Max) còn t t c các ph n t b ng hay l n h n ph n t
th pivot là A [i], …, A [Max] Ch ng trình con có tên Arrange th c hi n
B ng 2 i c a FindPivot
Cho l i ch s c a ph n t c t gi giá tr pivot Tuy nhiên,
Trang 24Table 3 Arrange Argument
Rearranges elements so values A [Min], …, A [i - 1]
are less than Pivot and values A [i], … A [Max] are equal to or greater than Pivot
[Pseudo-Language Syntax Explanation]
Syntax Explanation
A continuous area where declarations and processes are described
Declares name, type and other attributes of procedures, variables, etc
Condition expression
• Process 1
• Process 2
Indicates selection
When the condition expression is true, process 1 is executed
When false, process 2 is executed
Condition expression
• Process Indicates looping with the termination test at the top While the condition expression is true, the process is
executed
Trang 25Table 3 Arrange Argument
Mi n liên t c n i mô t các khai báo và các ti n trình
Khai báo tên, ki u và các thu c tính khác c a các th t c, bi n, v.v
Khi condition expression là đúng, process đ c th c hi n
Trang 28Sub-Question 1
From the answer groups below, select the correct answers to insert in the blanks a
Answer group for “a” and “b”:
Answer group for “c” and “d”:
Trang 30Sub-Question 2
The contents of arguments have been summarized in Table 4 after using QuickSort to
sort elements A[0] to A[9] of an integer-type one-dimensional array From the answer
groups below, select the correct answers to insert in the blanks e through
g in the following table
Table 4 QuickSort Call Count and Integer Content
Trang 31Câu h i con 2
N i dung c a các đ i đã đ c tóm t t trong B ng 4 sau khi dùng QuickSort đ s p x p
các ph n t A[0] t i A[9] c a m ng m t chi u các s nguyên T các nhóm câu tr l i d i
đây, hãy ch n nh ng câu tr l i đúng đ đi n vào các ch tr ng e t i g
Trang 32Q5 Read the following description on program design and answer Sub-Questions 1 and 2
You are going to design a program for a game that raises and lowers a flag In the game, the player responds to instructions (raise/lower red flag and/or white flag) from the output device by operating buttons A certain type of window is displayed when the correct response is made and another type is displayed when an incorrect response is made
This pattern is repeated only for a set number of times and the number of correct responses
is displayed as the score The game hardware configuration and the windows for correct responses and incorrect responses are shown in Figure 1 below
Initialization value
Program
Interface
Correct response
Your response
W indow displayed when correct response is given.
Correct response
Your response
W indow displayed when incorrect response is given.
Output device Interface
Down
• The output device gives an instruction by voice and displays the correct response and the player’s response after the response detection time has elapsed After the game ends, the score is displayed
• The input device detects only the first button pressed after the instruction has been given and notifies the program of this button
Figure 1 Game Hardware Configuration and Correct/Incorrect Response Display
Trang 33Q5 Hãy đ c mô t d i đây v thi t k ch ng trình và tr l i các câu h i con 1 và 2
B n đ nh thi t k m t ch ng trình cho trò ch i d ng và h c Trong trò ch i này, ng i
ch i đáp ng l i các l nh (d ng/h c đ và/ho c c tr ng) t thi t b đ a ra b ng vi c thao tác các nút b m M t ki u c a s nào đó đ c hi n th khi đáp ng đúng đ c th c hi n và
m t ki u c a s khác đ c hi n th khi đáp ng sai đ c th c hi n
Hình m u này đ c l p l i ch cho m t s l n đã đ t s n và s các đáp ng đúng đ c hi n
th nh đi m s C u hình ph n c ng trò ch i này và các c a s cho nh ng đáp ng đúng
và sai đ c nêu trong Hình 1 d i đây
Initialization value
Program
Interface
Correct response
Your response
W indow displayed when correct response is given.
Correct response
Your response
W indow displayed when incorrect response is given.
Output device Interface
Down
• Thi t b đ a ra cho m t l nh b ng ti ng nói và hi n th đáp ng đúng và đáp ng c a ng i
ch i sau khi th i gian phát hi n đáp ng đã h t Sau khi trò ch i k t thúc, s đi m đ c
hi n th ra
• Thi t b đ a vào ch phát hi n nút đ u tiên đ c nh n sau khi l nh đã đ c cho và thông báo cho ch ng trình c a nút này
Hình 1 C u hình ph n c ng trò ch i và hi n th đáp ng đúng/không đúng
Trang 34[Explanation of Program]
(1) The program internally holds the current status of the flag
Red flag status: Up or Down White flag status: Up or Down (2) The program reads the initial value file and sets the initial status of both the red flag and white flag to “Down”
Initial value file format
Response detection time Incorrect response window display time No of
repetitions
(3) The program randomly selects a flag for the raise/lower instruction and a selectable instruction, based on the status of the flags given in the table, and then sends that information to the output device
Table Flag Status and Selectable Instructions
(4) There are 5 types of operations which can be received from the input device: raise the red flag, lower the red flag, raise the white flag, lower the white flag, and move neither flag (when a response is not detected within the response detection time) (5) The program detects the player’s response If correct, it adds “1” to the number
of correct responses and sends the correct response window to the output device
If incorrect, it sends the incorrect response window to the output device and, after the incorrect window display time in the initial value file has elapsed, it sets the flag in the window to the correct state
(6) The programs repeats steps (3) through (5) the number of repetitions written in the initial value file
(7) The program sends the player’s score to the output device
Trang 35[Gi i thích ch ng trình]
(1) Ch ng trình gi tr ng thái hi n th i c a c
Tr ng thái c đ : D ng hay H
Tr ng thái c tr ng: D ng hay H (2) Ch ng trình đ c t p giá tr kh i đ u và đ t tr ng thái kh i đ u cho c c tr ng và c
(4) Có 5 ki u thao tác có th nh n đ c t thi t b đ a vào: d ng c đ , h c đ , d ng
c tr ng, h c tr ng, và không chuy n c (khi đáp ng không đ c phát hi n trong
th i gian phát hi n đáp ng)
(5) Ch ng trình phát hi n đáp ng c a ng i ch i N u đúng, nó c ng “1” vào s l n đáp ng đúng và g i c a s đáp ng đúng ra thi t b đ a ra N u không đúng,
nó g i c a s đáp ng sai ra thi t b đ a ra và, sau khi th i gian hi n th c a s đáp ng sai trong t p giá tr kh i đ u đã trôi qua, nó đ t c trong c a s này sang tr ng thái đúng
(6) Ch ng trình l p l i các b c (3) t i (5) theo s l n l p đ c ghi trong t p giá tr
kh i đ u
(7) Ch ng trình g i đi m s c a ng i ch i ra thi t b đ a ra
Trang 36Sub-Question 1
Figure 2 below is a state transition diagram of the flags Which of the statements listed
about Figure 2?
S0 indicates the initial status and the “raise the red flag” response corresponds to state transition ¦ from S0 to S1 In this case, S1 is the a state And, the response corresponding to state transition of S3 to S0 is b and that for state transition ¡
Figure 2 State Transition Diagram of Flags
Answer group for “a”:
a) red flag up and white flag up
b) red flag up and white flag down
c) red flag down and white flag up
d) red flag down and white flag down
Answer group for “b” and “c”:
a) raise the red flag
b) lower the red flag
c) raise the white flag
d) lower the white flag
Trang 37Câu h i con 1
Hình 2 d i đây là bi u đ chuy n tr ng c a các c M nh đ nào trong các m nh đ đ c
v Hình 2?
S0 ch ra tr ng thái kh i đ u và đáp ng “d ng c đ ” t ng ng v i vi c chuy n tr ng thái ¦ t S0 sang S1 Trong tr ng h p này, S1 là tr ng thái a Và, đáp ng
Trang 38Sub-Question 2
Figure 3 below is a flowchart of this program The initial status is set in the initialization processing Other than the initialization processing and the setting of the number of repetitions, what two processes reference the content of the initial value file?
Main process repetitions N:1, 1, No of repetitions (Note)
End
Start
Incorrect response processing
Main process end Main process start
Fig 3 Flowchart
Instruction selection
Instruction output Response detection
Correct?
State transition
Correct response processing Correct count ← Correct count +1
Note: The repetition specification at
the top of the loop is as follows: variable name: initial value, increment, terminal value.
Answer group:
g) Response detection
Trang 39Câu h i con 2
Hình 3 d i đây là l u đ c a ch ng trình này Tr ng thái kh i đ u đ c đ t trong khi x
lí kh i đ u Ngoài vi c x lí kh i đ u và đ t s l n l p, hai x lí nào tham chi u t i n i dung c a t p giá tr kh i đ u?
Main process repetitions N:1, 1, No of repetitions (Note)
End
Start
Incorrect response processing
Main process end Main process start
Fig 3 Flowchart
Instruction selection
Instruction output Response detection
Correct?
State transition
Correct response processing Correct count ← Correct count +1
Note: The repetition specification at
the top of the loop is as follows: variable name: initial value, increment, terminal value.
Trang 40Select one of the following four questions (Q6, Q7, Q8, or Q9) Be sure to mark on your answer
sheet the “Select” circle corresponding to the question you have selected
If you select more than one question, only the first answer will be graded
Q6 Read the following description of a C program and the program itself, then, answer the
Fig Coordinate Assignment of Bitmap Window
A triangle has been drawn on the bitmap window This triangle has three apexes at P1 (x1, y1), P2 (x2, y2) and P3 (x3, y3) The handling procedures of a recursive function known as DrawTrg that turns on all pixels along each side of the triangle and the area enclosed by the three sides are as follows:
(1) DrawTrg checks whether the three apexes are adjacent to each other or not
(2) If adjacent, the pixels of the three apexes turn on and processing ends
(3) If not adjacent, DrawTrg obtains the square of the length of each side using the
Pythagorean theorem
(4) DrawTrg selects the longest side and obtains the coordinates (xc, yc) of the midpoint
C of that side It then partitions the triangle into two triangles by drawing a line from this midpoint For example, if side P2P3 is the longest, DrawTrg partitions the
triangle into triangle P1CP2 and triangle P1CP3