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.
From the answer group below, select the correct answer to be inserted into blank in the description.
When the program is executed, the output 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.
The function fizzBuzz returns “divisible by 3” if the value given as the argument is divisible by 3 and not divisible by 5, “divisible by 5” if it is divisible by 5 and not divisible by 3, and “divisible by 3 and 5” if it is divisible by 3 and 5. In all other cases, it returns “divisible by neither 3 nor 5”.
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 makeNewArray receives an integer-type array with two or more elements as its argument and returns an integer-type array. When the function makeNewArray is called as makeNewArray(, the value of the element at index 5 of the returned array 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.
The function gcd finds the greatest common divisor of the two positive integers num1 and num2 given as arguments, by using the properties (1) through (3) below.
num1 and num2 are equal, the greatest common divisor of num1 and num2 is num1.(2)When num1 is greater than num2, the greatest common divisor of num1 and num2 is equal to the greatest common divisor of (num1 - num2) and num2.(3)When num2 is greater than num1, the greatest common divisor of num1 and num2 is equal to the greatest common divisor of (num2 - num1) and num1.Answer group
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 √x2 + y2. The function pow, which is used by the function calc, receives a positive real number a as the first argument and a real number b as the second argument, and returns the value of a raised to the power of b as a real-type value.
Answer group
From the answer group below, select the correct answer to be inserted into blank in the program.
The function rev receives the 8-bit type argument byte, and returns the value with the order of its bits reversed. For example, when the function rev is called as rev(, the return value is 11010010.
Here, operator ∧ represents a bitwise logical product, operator ∨ represents a bitwise logical sum, operator >> represents a logical shift to the right, and operator << represents a logical shift to the left. For example, value >> n performs a logical shift of the value of value by n bits to the right, and value << n performs a logical shift of the value of value by n bits to the left.
Answer group
From the answer group below, select the correct answer to be inserted into blank in the program.
The function factorial receives a non-negative integer n as an argument, and returns its factorial. The factorial of a non-negative integer n is 1 when n is 0; otherwise, it is the number obtained by multiplying together all the integers from 1 to n.
Answer group
From the answer group below, select the correct answer to be inserted into blank in the description.
This program performs operations on a priority queue. A priority queue is a queue where the handled elements have a priority assigned to them, and the elements are extracted with the order of the highest priority first. The class PrioQueue represents a priority queue. The Figure shows an explanation of the class PrioQueue. Here, the priority is the integer value 1, 2, or 3, and the smaller the value the higher the priority.
When the procedure prioSched is called, the order of the output is blank.
Figure Explanation of the class PrioQueue
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 procedure order outputs all the node numbers while traversing the subtree of the binary tree in the figure whose root is the node specified by the argument. The global array tree represents the binary tree in the figure. Each element of the array tree is an array that stores the node numbers of the children of the corresponding node, in the order of the left child and then the right child. For example, the element at index 1 of the array tree is an array consisting of the node numbers of the children of node number 1, and it stores node number 2 of the left child and node number 3 of the right child as the array {2, 3}.
When the procedure order is called as order(, the node numbers are output in the order blank.
Figure Binary tree handled by the program
Answer group
From the answer group below, select the correct answer to be inserted into blank in the program.
The procedure delNode deletes the element at the position specified by the argument pos from a singly linked list. The argument pos is a positive integer that is equal to or less than the number of elements in the list. The position at the head of the list is 1.
The class ListElement represents an element of a singly linked list. The table shows an explanation of the member variables of the class ListElement. ListElement-type variables store references to instances of the class ListElement. A reference to the head element of the list is pre-stored in the global variable listHead.
Table Explanation of the member variables of the class ListElement
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.
When the function binSort is called as binSort(blank), the array of the return value contains no undefined elements, and its values are arranged in ascending order.
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 function simRatio compares the two character-type arrays s1 and s2, each with one or more elements, that are given as arguments, and if their numbers of elements are equal, returns (the number of pairs of elements with the same index whose characters match ÷ the number of elements in s1) as a real number, as an index of how similar the sequences of the arrays are. For example, the return value is 1 when all elements of the arrays match, and 0 when none of the elements match.
If the numbers of elements of the two arrays are not equal, the function returns −1.
The table shows examples of s1 and s2 given to the function simRatio and the return values. In the program, areas outside the arrays must not be referenced.
Table Examples of s1 and s2 given to the function simRatio and the return values
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 search returns the index of the element if the value specified by the argument target is contained in the array specified by the argument data, and returns −1 if it is not contained. data is sorted in ascending order, and there are no duplicate values.
The function search has a defect. For example, in the case of data where blank, an infinite loop occurs.
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.
This is a program that, based on an array that has one or more elements and is sorted in ascending order, returns five values that characterize the array.
When the function summarize is called as summarize(, the return value is blank.
Answer group
From the answer group below, select the correct combination of answers to be inserted into A and B in the description.
In tic-tac-toe, the move with which you have the highest possibility of winning is determined. With the following procedure, the state transitions of the game are represented as a tree structure, and the evaluation value of each node other than the root is calculated. As a result, the move with the highest evaluation value among the children of the root is regarded as the move with the highest possibility of winning. A move selected by you is represented by ○, and a move selected by the opponent is represented by ×.
When the game is in the state of the root at the top of the figure, there are three moves you can select. Of them, the evaluation value of the child pointed to by A is A, and the evaluation value of the child pointed to by B is B.
Figure State transitions of tic-tac-toe
Answer group
From the answer group below, select the correct answer to be inserted into blank in the program. The same answer goes into both blanks blank. Here, the array index starts at 1.
The program converts a Unicode code point to a UTF-8 encoding. In this question, “(16)” after a numerical value indicates a hexadecimal value.
Each Unicode character is given an integer value that is known as a code point. UTF-8 is one of the methods of encoding Unicode characters, and a character with a code point that ranges from 800(16) to FFFF(16) is encoded to a 3-byte value as below.
Let the bit pattern with a 3-byte length be 1110xxxx 10xxxxxx 10xxxxxx. The code point represented in binary is stored right-justified in the underlined “x” positions in the bit pattern, and 0 is stored in any leftover “x” positions. This 3-byte value is the UTF-8 encoding.
For example, when 3042(16), the code point of the hiragana character “あ”, is represented in binary, it is 11000001000010. When this is stored right-justified in the “x” positions in the bit pattern shown above, it is 1110xx11 10000001 10000010. When 0 is stored in the two leftover “x” positions, the UTF-8 encoding of “あ”, 11100011 10000001 10000010, is obtained.
The function encode converts a Unicode code point that is passed as an argument to UTF-8 encoding, and returns an integer-type array that stores it one byte per element in order from the start. It is assumed that only an integer value that ranges from 800(16) to FFFF(16) is passed to encode as an argument.
Answer group
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.
Figure 1 Findings from Company D
Answer group
Company A is a company with 1,000 employees that conducts IT development. There are 50 employees in the General Affairs Department and 50 in the Sales Department, and the others belong to the Development Department. 90% of the members of the Development Department are stationed at customer sites. Currently, the usage of PCs at Company A is as shown in Figure 1.
Figure 1 Usage of PCs at Company A
Company A considered it inefficient for members of the Development Department stationed at customer sites to come to Company A’s office only to use the business system, and decided to consider permitting members of the Development Department stationed at customer sites to use their personally owned PCs for business (BYOD) and to make VPN connections.
Answer group
Company A is a mail-order company with 200 employees. It sells household goods, gift items, etc. to general consumers. Product Z, one of the products it handles, is handled by the Z Sales Section.
[Work of the Z Sales Section]
Currently, the staff of the Z Sales Section perform order management work and inquiry handling work for product Z. Figure 1 shows the procedure of the order management work for product Z.
Figure 1 Procedure of the order management work
[Operation privileges of J system]
The Z Sales Section has established the following usage policies for J system.
J system implements a function that grants users the operation privileges necessary for their work.
Recently, since the order management work for product Z has been growing with an increase in orders, it was decided to outsource part of it to Company B (hereinafter, an employee of Company B who performs the input work of the order management work for product Z is referred to as a Company B salesperson for product Z, and an employee of Company B who views the input results of the Company B salespersons for product Z and, if there are deficiencies, verbally asks Company A to send them back is referred to as a Company B sales manager for product Z).
For the outsourcing, the Z Sales Section communicated the following requirements on J system to the Information Systems Department.
Based on the above, the Information Systems Department summarized in Table 1 the operation privileges to be granted to each user from now on, and had them checked by C, the information security leader of the Z Sales Section.
Table 1 Draft of operation privileges
Answer group for A
Company A is a company with 500 employees that deals in dietary supplements. The operation of Company A’s information systems, including its servers and firewall (hereinafter, FW), is handled by the Information Systems Department.
One day, there was an audit by the Internal Audit Department, and when Department Manager B of the Information Systems Department explained the operational status of the FW as shown in Figure 1, the findings shown in Table 1 were received.
Figure 1 Operational status of the FW
Table 1 Findings from the Internal Audit Department
Department Manager B decided to consider improvement measures for the findings in Table 1.
Answer group