LearnReviewHistoryAI
Profile
AboutHow I passedFeedback
Learn
Review
HistoryAI
Profile
LearnReviewHistoryAI
Profile
AboutHow I passedFeedback
FE-B 2025 Spring

ITPEC FE Subject B April 2025 — Question 1 of 20

Question 1

From the answer group below, select the correct combination of answers to be inserted into A through C in the program.

Centurial years refer to the years that are divisible by 100. The centurial years are not leap years except for years that are exactly divisible by 400. The non-centurial years, that is, years that are not divisible by 100, refer to leap years that are divisible by 4. The function isLeapYear receives an integer number year and returns true if a given year is a leap year or false otherwise.

[Program]
○ boolean: isLeapYear(integer: year) // returns true if the variable year
// is a leap year; otherwise, returns false
if (A)
return B
elseif (C)
return false
elseif (year mod 4 = 0)
return true
else
return false
endif

Answer group

OptionABC

ITPEC FE Subject B April 2025 — Question 2 of 20

Question 2

From the answer group below, select the correct combination of answers to be inserted into A and B in the program.

The function isPerfect receives positive number n, and returns whether n is a perfect number. Here, a number is a “perfect number” if the sum of its positive divisors (excluding the number itself) is equal to the number itself. For instance, 28 is a perfect number because 28 has divisors 1, 2, 4, 7, and 14, and 1 + 2 + 4 + 7 + 14 = 28.

[Program]
○ boolean: isPerfect(integer: n)
integer: k
integer: sum ← 0
integer: half ← integer part of (n ÷ 2)
for (increase k from 1 to half by 1)
if (A)
B
endif
endfor
if (sum = n)
return true
else
return false
endif

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 3 of 20

Question 3

From the answer group below, select the correct answer to be inserted into blank in the description.

The greatest common divisor (GCD) of two numbers is the largest number that divides both of them. The function GCD receives two positive integer numbers and returns their GCD. When the function GCD is called as GCD(98, 56), the output is blank in (1)-(4) below. Here, the output statement “output m, n” outputs the values of variables m and n, and subsequently starts a new line.

(1)98 5642 1428 1414 7
(2)42 5642 1428 1414 14
(3)42 5642 2814 2814 14
(4)56 4242 1414 2814 14
[Program]
○ integer: GCD(integer: x, integer: y)
integer: m ← x
integer: n ← y
while (m ≠ n)
if (m > n)
m ← m - n
else
n ← n - m
endif
output m, n
endwhile
return m

Answer group

ITPEC FE Subject B April 2025 — Question 4 of 20

Question 4

From the answer group below, select the correct combination of answers to be inserted into A and B in the program.

The following function receives an integer number and returns the result of interpreting the decimal representation of the number as a binary number. Note that the number is non-negative, and its decimal representation comprises only the digits 0 and 1. For instance, if it receives 1100, it returns 12.

[Program]
○ integer: convert(integer: number)
integer: place, n, remainder, decimal
decimal ← 0
place ← 1
n ← number
while (n > 0)
remainder ← n mod 10
n ← integer part of (n ÷ 10)
decimal ← decimal + A
place ← B
endwhile
return decimal

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 5 of 20

Question 5

From the answer group below, select the correct answer to be inserted into blank in the program.

The function calc receives the positive real numbers x and y, and returns the result of the calculation of (√x + √y)2. For instance, when the function calc is called as calc(4, 9), the return value is 25. Here, the function pow(a, b) returns a raised to the power of b.

[Program]
○ real: calc(real: x, real: y)
return blank

Answer group

ITPEC FE Subject B April 2025 — Question 6 of 20

Question 6

From the answer group below, select the correct combination of answers to be inserted into A and B in the program.

Gray code is a sequence of binary numbers in which two successive values differ by only 1 bit. The function GrayBiCon converts the gray code to a binary code using bitwise operators. The bitwise operators operate on the individual bits of the variables. The function receives the 8-bit type argument x as a gray code, and returns a corresponding binary number of the given argument. The value of each bit after conversion is the exclusive OR of the most significant bit in the gray code up to the corresponding bit position and the converted value of the next higher bit position. For instance, when the function GrayBiCon is called as GrayBiCon(00001100), the return value is a binary number 00001000. The common bitwise operators are listed in the table below:

Table Operators

OperatorName
&Bitwise AND
|Bitwise OR
^Bitwise XOR (exclusive OR)
<<Shift left
>>Shift right

For instance, v << n performs a logical shift of the value of v by n bits to the left.

[Program]
○ 8-bit: GrayBiCon(8-bit: x)
8-bit: y ← x
8-bit: z ← x
while (z ≠ 00000000)
z ← z A 1
y ← B
endwhile
return y

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 7 of 20

Question 7

From the answer group below, select the correct answer to be inserted into blank in the description. Here, the array index starts at 1.

The function binarySearch receives four arguments: the first argument is an array specified with the argument arr (the number of elements ≥ 1), the second argument is the value specified with the argument target, the third argument is the lower bound low of the array, and the fourth argument is the upper bound high of the array. The array arr has no duplicate elements and is sorted in ascending order. If arr has an element with the same value as target, this function returns the index of that element, and -1 otherwise.

When the function binarySearch is called as binarySearch({1, 2, 3, 4, 5, 6}, 5, 1, 6), the number of times the string “call” is output is blank.

[Program]
○ integer: binarySearch(integer []: arr, integer: target,
integer: low, integer: high)
integer: mid
if (low > high)
return -1
endif
mid ← integer part of ((low + high) ÷ 2)
if (arr[mid] > target)
output "call"
return binarySearch(arr, target, low, mid - 1)
elseif (arr[mid] < target)
output "call"
return binarySearch(arr, target, mid + 1, high)
else
return mid
endif

Answer group

ITPEC FE Subject B April 2025 — Question 8 of 20

Question 8

From the answer group below, select the correct combination of answers to be inserted into A and B in the program. Here, the array index starts at 1.

The function reverse takes a string inputStr as a parameter and returns the reversed string. Here, the length of the string given to inputStr is 100 or less. In the program, areas outside of the arrays must not be referenced and the undefined value must not be appended to a string.

[Program]
global: character []: stack ← {100 undefined}
global: integer: sp ← 0
○ string: reverse(string: inputStr)
integer: n ← length of inputStr
integer: i
character: x, v
string: outputStr ← ""
for (increase i from 1 to n by 1)
x ← the i-th character of string inputStr
push(x)
endfor
while (sp ≠ A)
v ← pop()
append v to outputStr
endwhile
return outputStr
○ push(character: x)
sp ← sp + 1
stack[sp] ← x
○ character: pop()
character: retvar
B
return retvar

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 9 of 20

Question 9

From the answer group below, select the correct combination of answers to be inserted into A through C in the program.

Given the root of two binary trees, the aim of the following program is to check whether these two trees are identical. Two binary trees are defined as identical if they satisfy the following formal conditions:

  • •Structure: Both trees have the same structure, implying that for every corresponding node in the two trees, the arrangement of the left and right children is the same.
  • •Node Values: Each corresponding node in the two trees must contain the same value. Specifically, if tree T1 has a node N1 with value v1 and tree T2 has the corresponding node N2 with value v2, then v1 = v2.

The function isSameTree takes two instances of class TreeNode as the argument representing the root nodes of two binary trees, and returns true if the trees are identical, or false otherwise. The member variables of TreeNode are listed in the table below:

Table Explanation of the member variables of the class TreeNode

Member variableTypeDescription
valintegerThe integer value of a current node
leftTreeNodeLeft child node
rightTreeNodeRight child node
[Program]
○ boolean: isSameTree(TreeNode: p, TreeNode: q)
boolean: checkLeft, checkRight
if (p = undefined A q = undefined)
return true
endif
if (p = undefined B q = undefined)
return false
endif
if (p.val ≠ q.val)
return false
endif
checkLeft ← isSameTree(p.left, q.left)
checkRight ← isSameTree(p.right, q.right)
return checkLeft C checkRight

Answer group

OptionABC

ITPEC FE Subject B April 2025 — Question 10 of 20

Question 10

From the answer group below, select the correct combination of answers to be inserted into A and B in the program.

The procedure deleteLast removes an element at the end of a doubly linked list. Each element of the doubly linked list is represented by the class ListElement. The table shows the description of the class ListElement. The ListElement-type variable holds a reference to an instance of the class ListElement. The global variable listHead holds a reference to the head element of the doubly linked list. Remember that each element in the doubly linked list has a reference to its previous element and its next element. Here, if the list is empty, listHead is set to undefined.
The procedure handles three main cases: if the list is empty, it outputs "empty." If the list contains only one element, it becomes empty after deletion. If multiple elements are present, it only removes the last element.

Table Class ListElement

Member VariableTypeDescription
dataintegerThe value of an element.
nextListElementReference to the instance that holds the next element in the list.
prevListElementReference to the instance that holds the previous element in the list.
[Program]
global: ListElement: listHead /* A reference to the first element of
the list is stored. */
○ deleteLast()
ListElement: current
if (listHead is undefined)
output "empty"
else
current ← listHead
while (A is not undefined)
current ← current.next
endwhile
if (current.prev is not undefined) // multiple elements are present
B ← undefined
else // only one element is present
listHead ← undefined // empty list
endif
endif

Answer group

OptionAB
Questions 11–20

ITPEC FE Subject B April 2025 — Question 11 of 20

Question 11

From the answer group below, select the correct combination of answers to be inserted into A in the description and B in the program. Here, the array index starts at 0.

The procedure sort receives an integer array arr and prints all the integers in arr in ascending order, separated by commas. The number of elements in arr is ≥ 1. The values of all array elements are in the range of 0-10.

If arr is {9, 3, 2, 0, 9, 3, 0, 1, 5, 3, 8}, at the end of the procedure, it outputs "0, 0, 1, 2, 3, 3, 3, 5, 8, 9, 9, " and the values of the elements of array s will be {A}

[Program]
○ sort(integer []: arr) // prints all the elements in arr in ascending order
integer []: s ← {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
integer: i, j
for (increase i from 0 to (the number of elements in arr) - 1 by 1)
s[arr[i]] ← s[arr[i]] + 1
endfor
for (increase i from 0 to 10 by 1)
if (s[i] > 0)
for (increase j from 0 to s[i] - 1 by 1)
output B and ", "
endfor
endif
endfor
return

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 12 of 20

Question 12

From the answer group below, select the correct answer to be inserted into blank in the program. Here, the array index starts at 1.

The function hammingDistance compares the two-character arrays s1 and s2 that are given as arguments. s1 and s2 have one or more elements. If s1 and s2 do not have the same number of elements, the function returns -1. Otherwise, it returns the number of indices where two arrays have different element values at the same index. The figure shows an example of two character arrays. APPLE and APRIE have different element values at two indices.

APPLEAPRIE

Figure Example of two-character arrays

The table lists examples of s1 and s2 given to the function hammingDistance and the return values. In the program, areas outside of the arrays must not be referenced.

Table Examples of s1 and s2 given to the function hammingDistance and the return values

s1s2Return value
{"a", "p", "p", "l", "e"}{"a", "p", "p", "l", "e"}0
{"a", "p", "p", "l", "e"}{"a", "p", "r", "i", "l"}3
{"a", "p", "p", "l", "e"}{"m", "e", "l", "o", "n"}5
{"a", "p", "p", "l", "e"}{"p", "i", "e"}-1
[Program]
○ integer: hammingDistance(character []: s1, character []: s2)
integer: i, cnt ← 0
if (the number of elements in s1 ≠ the number of elements in s2)
return -1
endif
for (increase i from 1 to the number of elements in s1 by 1)
if (blank)
cnt ← cnt + 1
endif
endfor
return cnt

Answer group

ITPEC FE Subject B April 2025 — Question 13 of 20

Question 13

From the answer group below, select the correct combination of answers to be inserted into A and B in the program. Here, the array index starts at 1.

The procedure maximumSubarray calculates the maximum sum of the subarray of the array T (the number of elements ≥ 1). A subarray is a contiguous portion of the array, for instance, from T[1] to T[3]. It can be as short as one element or as long as the entire array. The procedure finds one of the subarrays with the largest sum of values, and outputs the sum, the first, and the last indices of the subarray. For instance, if the content of the array is {-2, 1, -3, 4, -1, 2, 1, -5, 4}, the output will be 6, 4, and 7 representing the sum, first index, and last index, respectively. Here, the subarray from T[4] to T[7] is {4, -1, 2, 1}.

[Program]
○ maximumSubarray(integer []: T)
integer: n ← the number of elements in T
integer: i, j
integer: first, last /* the first and last indices of the subarray */
integer: sum
integer: max ← T[1] - 1
for (increase i from 1 to n by 1)
sum ← 0
for (increase j from A to n by 1)
sum ← sum + T[j]
if (sum > max)
first ← i
last ← B
max ← sum
endif
endfor
endfor
output max, first, last

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 14 of 20

Question 14

From the answer group below, select the correct combination of answers to be inserted into A and B in the program.

The function cosine(z) returns an approximate value of the cosine value of z degrees. The function uses Maclaurin series expansion for the cosine shown below and can be used to determine cos(y) for values of y radians.

cos(y) = 1 − y22! + y44! − y66! + ⋯

[Program]
○ real: cosine(real: z)
real: y ← z × π ÷ 180 // convert from degrees to radians
real: term ← 1
real: cosy ← term
integer: n ← 0
while (absolute value of A > 0.000000001)
n ← n + 1
term ← term × (-1 × (y B) ÷ (2 × n × (2 × n - 1)))
cosy ← cosy + term
endwhile
return cosy

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 15 of 20

Question 15

From the answer group below, select the correct combination of answers to be inserted into A and B in the description. Here, the array index starts at 1.

The calcDistance returns a value based on array p1, p2 and positive integer n. Assuming that the number of elements in arrays p1 and p2 are the same. The function abs(x) returns the absolute value of x, and pow(a, b) returns a raised to the power of b.
In the case of p1 is {3, 1, 5, 2} and p2 is {4, 6, 2, 3}, the calcDistance(p1, p2, 1) returns A, whereas calcDistance(p1, p2, 2) returns B. As the value of n increases, those of calcDistance(p1, p2, n) converges to 5.

[Program]
○ real: calcDistance(real []: p1, real []: p2, integer: n)
integer: i
real: distance ← 0
real: ex
for (increase i from 1 to number of elements in p1 by 1)
distance ← distance + pow(abs(p1[i] - p2[i]), n)
endfor
ex ← 1 ÷ n /* Division is performed in data type real */
distance ← pow(distance, ex)
return distance

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 16 of 20

Question 16

From the answer group below, select the correct combination of answers to be inserted into A through C in the program.

Craps is a casino dice game in which players bet on the outcomes of the roll of a pair dice. In the rules of the game, a player rolls two dice and finds their sum. There possible outcomes could lead to a win or loss.

1.If the sum is 7 or 11, the player wins.2.If the sum is 2, 3 or 12, the player loses.3.Otherwise (the sum is 4, 5, 6, 8, 9 or 10), the player neither wins nor loses. However, the player continues rolling the dice until they either roll the same (initial) sum again (in which case they win the game) or roll a sum of 7 (in which case they lose the game).

The following program approximates the chance of winning a game of Craps using Monte Carlo method and outputs it. The Monte Carlo method is a technique used to estimate the probability of certain outcomes of an experiment by running multiple trial runs, using random numbers. In the program, the playing Craps is illustrated simply by generating random numbers rather than actually rolling a pair of dice. The function random_int(1, 6) generates a random integer number between 1 and 6, and returns it.
The program also calculates and outputs the relative error of the measured approximate probability of winning Craps. In general, the relative error Er is calculated using the following formula:

Er = | (Pm – Pt) / Pt |

where Pm denotes the measured approximate probability and Pt denotes the theoretical probability. The theoretical probability of winning Craps is known to be 244/495.

[Program]
integer: wins_sum ← 0
integer: lose_sum ← 0
integer: n ← 10000
integer: i, dice1, dice2, sum, newsum
real: result, pt ← (244 ÷ 495)
for (increase i from 1 to n by 1)
dice1 ← random_int(1, 6)
dice2 ← random_int(1, 6)
sum ← dice1 + dice2
if (sum = 7 or sum = 11)
wins_sum ← wins_sum + 1
elseif (sum = 2 or sum = 3 or sum = 12)
lose_sum ← lose_sum + 1
else
do
dice1 ← random_int(1, 6)
dice2 ← random_int(1, 6)
newsum ← dice1 + dice2
if (newsum = sum)
wins_sum ← wins_sum + 1
elseif (newsum = 7)
lose_sum ← lose_sum + 1
endif
while (A)
endif
endfor
result ← B
output result, absolute value of (C)

Answer group

OptionABC

ITPEC FE Subject B April 2025 — Question 17 of 20

Question 17

From the answer group below, select the correct combination of answers to be inserted into A and B in the description.

Recently, an e-commerce company X was cyber-attacked by an attacker. Mr. Y, the security team leader at the company, is investigating the incident and considering future countermeasures. The following is the summary of the incident:

The first half of the attack: An attacker visited company X's website to collect valuable information and knew the name of a senior worker of the IT department who was only responsible for system administration. One day, a receptionist for Company X received a phone call from a man with a fantastic voice. He asked some personal questions about the senior IT guy, Mr. Z. The caller skillfully manipulated the receptionist into giving him personal information about the IT guy. The caller was the attacker who got helpful information for further attacks on the company's server.

The second half of the attack: After that, the attacker dug into social sites and other resources to get additional information about Mr. Z and the servers of Company X, and then he created a password file based on Mr. Z's information and a file with the company server's IP address list. Then, the attacker remotely attacked a server of the company using the password list and an IP address of the server.

Mr. Y implemented two measures as future countermeasures for a similar attack. The measure for the first half of the attack is A. The other for the second half is B.

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 18 of 20

Question 18

From the answer group below, select the most appropriate combination of answers to be inserted into A and B in the description.

Company Z wants to provide secure file transfer service especially for very large files for their customers. Mr. K, the system architect of the company, designed the sequence of uploading, storing, and downloading customer files on the web service. In this system, customers register their email addresses and their public keys during sign up. The associated private keys reside on the customers’ computers and the email address is used as the user id. The requirements for the file transfer service are as follows:

-Customers transfer files between each other by uploading files to or downloading them from the web service provided by Company Z.-When uploading a file, the sender supplies the recipient’s email address and the password that will be used with the particular file (Upload function).-The file uploaded by the sender is encrypted with the supplied password and then stored in the database of the web service. (StoreFile function).-The web service assigns a file id to the uploaded file and notifies the sender of it upon uploading.-The encrypted file can only be decrypted by the sender and the recipient of the file using the password supplied by the sender.-The password is encrypted and sent to the recipient as an email message along with the file id (Message function).-When downloading the file, the recipient supplies the file id and the password. The web service then decrypts the stored file and provides it for the recipient.-Even if the database is leaked, it will be difficult to decrypt the uploaded files stored in the database.

Figure 1 shows the sequence of uploading file by customer P for customer Q.

PServerDatabaseQUpload(Q’s email, file, password)LoadPublicKeys(Q’s email)Q’s public keyStoreFile(A(file, KDF(password)))file idMessage(file id,B(password, Q’s public key))file id

Figure 1 Sequence on file uploading

In this system, Mr.K uses KDF (Key Derivation Function) to improve the strength of the supplied password and uses A and B algorithms to accomplish above requirements. Note that the format of encryption algorithms used here is algorithm(data, key).

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 19 of 20

Question 19

From the answer group below, select the correct combination of answers to be inserted into A and B in the description.

Company V, a small-sized company specializing in manufacturing and selling home appliances, has recently expanded its team of website administrators to five. In addition, they have renovated their website to allow customers to download user manuals for their products. One day, an external security researcher highlighted that files containing a watermark with "For Internal Use" were publicly accessible in the public directory of the company’s website and available for download. Company V has a system that ensures all documents stored in the internal folder have this watermark by default, and a rule exists stating that the watermark must be removed when files are published or shared external. The website administrator immediately confirmed the issue and removed the document from the public directory. Then, the website administrator reported this issue to Company V's security team. The investigation of the security team revealed that the issue was caused by a website administrator accidentally uploading internal documents instead of the intended public catalog files. Those publicly accessible files were a draft version of the catalogs, and they did not contain credential information such as API keys for website management. When uploading files to the website's public directory, another website administrator, other than the uploader, was supposed to verify the correctness of the files. However, they failed to notice the mistake. To prevent similar issues in the future, the security team suggested implementing A to the website administrators. Additionally, to quickly detect issues, the security team suggested implementing B.

Answer group

OptionAB

ITPEC FE Subject B April 2025 — Question 20 of 20

Question 20

From the answer group below, select the correct combination of answers to be inserted into A and B in the description.

Company A recently experienced a security incident where confidential data were exfiltrated by a compromised employee account. Ms. T, a security analyst at Company A, investigated the compromised employee account and found that the password used by the employee's account involved in this breach was a complex password that met the company's password policy. However, the same password was used across several web services. Additionally, Ms. T investigated the login logs of Company A’s system and discovered 1,000 failed login attempts recorded within 3 hours before a successful login was recorded. These failed login logs included attempts to log in with different account IDs and password sets. These login attempts occurred from a county where Company A does not have an office. Company A has no employees who travel abroad.

To prevent future account compromise by the same attack pattern, Ms. T suggested that the system administrators of Company V implement A. Additionally, to quickly detect any account compromise, she suggested implementing a monitoring system to alert administrators of B.

Answer group

OptionAB
Learn
Review
HistoryAI
Profile