Questions IPA Japan published in 令和6年度 基本情報技術者試験 科目B 公開問題, translated into English, with IPA's answers. ITPEC is based on the same exams, so they are good practice for ITPEC too.
From the answer group below, select the correct answer to be inserted into blank in the program.
The function maximum receives three different integers as arguments, and returns the maximum value among them.
Answer group
From the answer group below, select the correct answer to be inserted into blank in the program.
The function convDecimal receives as an argument a string of one or more characters that consists only of “0” and “1”, and returns the integer value obtained by interpreting the string as an unsigned binary number. For example, when “10010” is given as an argument, 18 is returned.
The function int, which is used by the function convDecimal, returns the integer value 0 if the character given as an argument is “0”, and returns the integer value 1 if it is “1”.
Answer group
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 vertices of the graph shown in Figure 1 are numbered with integers in order, starting from 1. The graph is an undirected graph, and there is at most one edge between any two vertices. One edge can be represented by an integer-type array with two elements, whose elements are the numbers of the vertices at both ends. For example, {1, 3} represents the edge whose end points are vertex 1 and vertex 3. The whole graph can be represented by an array that stores all the two-element arrays representing the edges contained in the graph (hereinafter referred to as the array of edges). The number of elements in the array of edges is equal to the number of edges in the graph. The graph in Figure 1 can be represented as the array of integer-type arrays {{1, 3}, {1, 4}, {3, 4}, {2, 4}, {4, 5}}.
Figure 1 Example of a graph
The function edgesToMatrix converts an array of edges into an adjacency matrix. An adjacency matrix is a square matrix whose numbers of rows and columns are equal to the number of vertices contained in the graph, and its element in row i, column j is 1 when there is an edge connecting vertex i and vertex j, and 0 otherwise. The diagonal elements of the matrix are all 0, and in the case of an undirected graph, it is a symmetric matrix. Figure 2 shows the adjacency matrix that represents the graph in Figure 1.
Figure 2 Adjacency matrix that represents the graph in Figure 1
The function edgesToMatrix receives the array of edges as the argument edgeList and the number of vertices of the graph as the argument nodeNum, and returns an integer-type two-dimensional array that represents the adjacency matrix.
Answer group
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 merge receives the integer-type arrays data1 and data2, which are sorted in ascending order, and returns an integer-type array sorted in ascending order that is made by merging them.
When the function merge is called as merge(, the line /*** α ***/ is blank.
Answer group
From the answer group below, select the correct combination of answers to be inserted into A through C in the program. Here, the array index starts at 1.
There is order data that records, for each order, the list of the items purchased in one order. The table shows an example of the order data.
Table Example of order data
From the order data, the degree of association Lxy, which shows the tendency of item x and item y to be purchased in the same order, is calculated by the following formula.
Lxy = Mxy × total number of ordersKx × Ky
Here, Mxy represents the number of orders in which item x and item y were purchased in the same order, Kx represents the number of orders in which item x was purchased, and Ky represents the number of orders in which item y was purchased. In the example in the table, MAB is 2, the total number of orders is 6, KA is 4, and KB is 3, so the degree of association LAB between item A and item B is (2 × 6) / (4 × 3) = 1.0.
The procedure putRelatedItem outputs, based on the order data stored in the global variable orders, one of the items that have the largest degree of association with the item given as the argument, and that degree of association. In the program, an item is represented by a string, an order by an array of the purchased items, and the order data by an array of orders. The order data is assumed to contain two or more kinds of items. In addition, no item other than the items in the order data is given as the argument.
Answer group
Company A is a trading company with 450 employees, and since last year it has been promoting telework from home as part of its work style reform. Figure 1 shows the system environment of Company A.
Figure 1 System environment of Company A (excerpt)
As telework became established, employees asked whether the situation could be improved, because connections from the in-house PCs to the internet had become extremely slow and were hindering their work. An investigation of the traffic between Company A’s internal network and the internet revealed that, compared with before telework was introduced, it had increased markedly during business hours. Therefore, the Information Systems Department decided to make a change to the network settings that enables a direct connection to Company A’s cloud services during telework, without going through either Company A’s internal network or the in-house PC.
When B, the information security leader of Company A, examined whether the setting change would cause any information security problems, B found that there were several problems. One of them is that the risk of unauthorized access to Company A’s cloud services increases. B therefore decided to ask the Information Systems Department to take a countermeasure to reduce the risk.
Answer group