LearnIPAReviewHistoryAI
Profile
AboutHow I passedFeedback
LearnIPA
Review
History
Profile
LearnIPAReviewHistoryAI
Profile
AboutHow I passedFeedback
IPA FE Subject B first sample

Questions IPA Japan published in 基本情報技術者試験 科目Bのサンプル問題, translated into English, with IPA's answers. ITPEC is based on the same exams, so they are good practice for ITPEC too.

Question 1

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

The admission fee of a certain facility is 100 yen for ages 0 to 3, 300 yen for ages 4 to 9, and 500 yen for ages 10 and above. The function fee receives an integer of 0 or more that represents an age as its argument and returns the admission fee.

[Program]
○ integer: fee(integer: age)
integer: ret
if (age is 3 or less)
ret ← 100
elseif (blank)
ret ← 300
else
ret ← 500
endif
return ret

Answer group

Question 2

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 following program reverses the order of the elements of the integer-type array array.

[Program]
integer []: array ← {1, 2, 3, 4, 5}
integer: right, left
integer: tmp
for (increase left from 1 to (the quotient of the number of elements in array ÷ 2) by 1)
right ← A
tmp ← array[right]
array[right] ← array[left]
B ← tmp
endfor

Answer group

OptionAB
Question 3

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

The procedure append adds the character given as the argument to a singly linked list. Each element of the singly linked list is represented by the class ListElement. The figure shows the explanation of the class ListElement. ListElement-type variables store references to instances of the class ListElement. The global variable listHead stores a reference to the head element of the singly linked list. When the list is empty, listHead is undefined.

Member variableTypeDescription
valcharacterThe character to be stored in the list.
nextListElementReference to the instance that holds the next character in the list. Its initial state is undefined.
ConstructorDescription
ListElement(character: qVal)Initializes the member variable val with the argument qVal.

Figure Explanation of the class ListElement

[Program]
global: ListElement: listHead ← undefined
○ append(character: qVal)
ListElement: prev, curr
curr ← ListElement(qVal)
if (listHead is A)
listHead ← curr
else
prev ← listHead
while (prev.next is not undefined)
prev ← prev.next
endwhile
prev.next ← B
endif

Answer group

OptionAB
Question 4

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

A matrix in which most of the elements are 0 is called a sparse matrix. The following program converts a matrix stored in a two-dimensional array into a data structure suitable for storing a sparse matrix, in order to reduce the amount of data of the matrix.
The function transformSparseMatrix converts the matrix given as a two-dimensional array in the argument matrix into an array of integer-type arrays, and returns it. When the function transformSparseMatrix is called as transformSparseMatrix({{3, 0, 0, 0, 0}, {0, 2, 2, 0, 0}, {0, 0, 0, 1, 3}, {0, 0, 0, 2, 0}, {0, 0, 0, 0, 1}}), the return value is {{A}, {B}, {C}}.

[Program]
○ integer [][]: transformSparseMatrix(integer [,]: matrix)
integer: i, j
integer [][]: sparseMatrix
sparseMatrix ← {{}, {}, {}} /* an array that has three arrays with 0 elements as its elements */
for (increase i from 1 to the number of rows of matrix by 1)
for (increase j from 1 to the number of columns of matrix by 1)
if (matrix[i, j] is not equal to 0)
add the value of i to the end of sparseMatrix[1]
add the value of j to the end of sparseMatrix[2]
add the value of matrix[i, j] to the end of sparseMatrix[3]
endif
endfor
endfor
return sparseMatrix

Answer group

OptionABC
Question 5

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

This is a program that, for any two different characters c1 and c2, calculates the ratio at which c2 appears immediately after c1 in the English words contained in a group of English words. English words consist of lowercase English letters only. When the last character of an English word is c1, that position is not included in the calculation of the ratio. For example, in the group of English words consisting of the four English words “importance,” “inflation,” “information,” and “innovation” shown in the figure, let c1 be “n” and c2 be “f”. Other than the last characters of the English words, there are five “n”s, and of these, two have “f” as the next character. Therefore, the ratio to be calculated is 2 ÷ 5 = 0.4. When the sequence of c1 and c2 never appears, the ratio is defined as 0 regardless of the number of occurrences of c1.

importanceThe nextcharacter is “c”inflationThe nextcharacter is “f”informationThe nextcharacter is “f”innovationThe nextcharacter is “n”The nextcharacter is “o”Not included inthe calculationof the ratio

Figure Example of a group of English words consisting of four words

In the program, the group of English words is stored in the Words-type global variable words. The table shows an explanation of the methods of the class Words. In this question, the operator “+” for strings represents the concatenation of strings. Also, the operator “÷” for integers performs the calculation as real numbers.

Table Explanation of the methods of the class Words

MethodReturn valueDescription
freq(string: str)integerReturns the number of occurrences of the string str in the group of English words.
freqE(string: str)integerReturns the number of English words that end with the string str in the group of English words.
[Program]
global: Words: words /* stores the group of English words */
/* returns the ratio at which c2 appears immediately after c1 */
○ real: prob(character: c1, character: c2)
string: s1 ← a string consisting only of the one character c1
string: s2 ← a string consisting only of the one character c2
if (words.freq(s1 + s2) is greater than 0)
return blank
else
return 0
endif

Answer group

Question 6

Company A, a manufacturer, sells products to individuals by using an EC site (hereinafter, Company A’s EC site is referred to as site A). On site A, Company A’s products and services can be searched, and site A has a login function and manages information such as the names and email addresses (hereinafter, member information) of individuals who have registered in advance to use site A (hereinafter, members). Site A runs on Company B’s PaaS, and uses the DBMS and the application server on the PaaS.
Company A outsources the development and operation of site A to Company C. The outsourcing contract between Company A and Company C states that Company C implements the countermeasures against vulnerabilities in the Web application programs.

Recently, an incident occurred in which a vulnerability in a Web site operated by another company in the same industry as Company A was exploited and personal information was leaked. Therefore, Company A requested Company D, which provides security assessment services, to perform a vulnerability assessment of site A. As a result of the vulnerability assessment, multiple security vulnerabilities that require countermeasures were pointed out. Figure 1 shows the findings from Company D.

(i) The DBMS used by site A has a known vulnerability, and there is a risk of an attack that exploits the vulnerability.(ii) The OS of the application server used by site A has a known vulnerability, and there is a risk of an attack that exploits the vulnerability.(iii) The login function has a vulnerability, and there is a risk that, of the information stored in the database of site A, information that is not disclosed to members is viewed.

Figure 1 Findings from Company D

QuestionFrom the answer group, select the appropriate combination of the organizations that deal with each of item numbers (i) through (iii) in Figure 1.

Answer group

Option(i)(ii)(iii)
LearnIPA
Review
History
Profile