Algorithm and Programming
39 questions · IT Passport
There is a series of numbered boxes stacked as shown in the figure below. The operations described in the table below are performed in the sequence of operations 1 through 4. When the operation 4 is completed, which of the following shows the status of the stacked boxes?
Fig.
Table
The data is exchanged between variable A and variable B. When variable TMP is used to temporarily store data, which of the following is the procedure for exchanging data correctly? Here, “x ← y” represents that the data of “x” is replaced with the data of “y”.
There exist four (4) states numbered 1 through 4. The four (4) states are connected as shown in the figure below, and the state transition occurs in a clockwise or counter-clockwise direction.
If the current state is 1, which of the following is the state that is reached after the procedure below is performed twice?
[Procedure]
The number of the current state is multiplied by 11, and the result is divided by 3. The process below is performed based on the remainder of the division.
- •When the remainder is 0, a transition to the next state occurs in the clockwise direction.
- •When the remainder is 1, a transition to the next state occurs in the counter-clockwise direction.
- •When the remainder is 2, a transition to the second state occurs in the clockwise direction.
The procedure findBanknotes outputs the number of 10,000 and 1,000 banknotes required to represent a specified amount of money, in that order, ensuring the minimum number of banknotes is used. The argument amount passed to the procedure must be a non-negative multiple of 1,000. If it is not, the procedure outputs an error message. Which of the following is the correct combination of answers to be inserted into A and B in the program?
A hollow square is an n × n matrix whose first and last rows along with the first and last columns are filled with stars (“*”), where n denotes an integer. All other positions inside the matrix other than the borders are filled with spaces. If n is 5, the hollow square is shown as below.
The procedure printHollowSquare prints a hollow square based on the value of n. Which of the following is the correct answer to be inserted into blank in the program? Here, the value n is at least 3 and is passed as an argument to the procedure.
Which of the following is a term for a list of instructions to a computer that are written in a human-readable programming language?
The procedure calculateElectricBill receives electricity usage that accepts the units (non-negative value) and returns the amount of electricity bills. The pricing structure is given as: For the first 100 units, the cost is $10 per unit. Any units exceeding 100 are charged at $15 per unit. Which of the following is an appropriate piece of code to be inserted into blank in the program?
A program uses loops to display results based on whether the cycle numbers are odd or even. The execution result of the program is shown below.
Which of the following is an appropriate combination of pieces of code to be inserted into A through C in the program?
In the data structure called a queue that is suitable for performing first-in first-out (FIFO) processing, values are stored in the order of “8”, “1”, “6”, and “3”, and then two (2) values are removed consecutively. Which of the following is the last value that is removed?
As shown in Figure 1, there is a box that generates two (2) numerical values B1 and B2 when two (2) positive integers A1 and A2 are entered. B1 has the same value as A2, and B2 is the remainder of A1 divided by A2. In Figure 2, when two (2) boxes are connected, and 49 is entered as A1 and 11 is entered as A2 in the left box, what is the value of B2 generated from the right box?
Figure 1
Figure 2
At a certain company, employees get a medical allowance equal to 5% of their monthly base salary in addition to their monthly base salary. If the total of the monthly base salary and medical allowance is more than 5,000, a 20% tax is deducted from the total. In the program below, the function calculateTotalSal receives the monthly base salary as an argument and returns the monthly total salary after tax deduction. Which of the following is the correct combination of pieces of code to be inserted into A and B in the program? Here, the monthly base salary is a multiple of 100.
Which of the following is the appropriate way for extracting data from a stack that stores multiple data?
In the program below, the function subTotal receives an integer array inputarr as an argument, returns an array arr in which the sum of all elements of original array inputarr up to that location is stored in the same location. Which of the following is the correct combination of pieces of code to be inserted into A and B in the program. Here, the size of the array inputarr is greater than 1, and elements outside the bounds of the array must not be accessed, and the array index starts at 1.
The function calGrade receives the student’s score and returns the grade. The score is an integer. If the score is greater than or equal to 80, the function calGrade returns “A”; if the score is between 65 and 79, it returns “B”; between 50 and 64, it returns “C”; and otherwise, it returns “Fail.” Which of the following is an appropriate piece of code to be inserted in blank in the program?
The procedure described below is sequentially performed for two (2) variables x and y, starting with step (1). When the procedure is completed, what is the resulting value of x?
There is a device that stacks products from the bottom to the top, and removes the products sequentially from the top. There are only two (2) operations for this device.
Nothing is stacked at the start, and three (3) products arrive in the order A, B, then C. If only one (1) device is used, when the products are removed with POP operations, which of the following is an impossible order of removal?
The program performs circular left shifting on the array elements. For example, after circular left shifting, the initial array {1, 2, 3, 4, 5} becomes {2, 3, 4, 5, 1}. Which of the following is an appropriate combination of pieces of code to be inserted in A and B in the program?
Which of the following is the appropriate reason for using a style sheet in the creation of a website?
Which of the following is an appropriate description concerning machine language?
A power company charges electricity bill shown in the table below.
Function computeBill receives the number of units used per month as an argument and returns the electricity bill in 1/100 dollars. Which of the following is an appropriate combination of pieces of code to be inserted in A and B in the program?
In a markup language, with the purpose of displaying on a screen and printing, it is possible to directly embed not only the document content, but also the document structure and layout information, and the character font and size information. Which of the following is classified into such a markup language?
The procedure draw receives a non-negative integer number n for input. When the value of n is 6, the procedure outputs the six lines shown below. Which of the following is an appropriate combination of pieces of code to be inserted in A and B in the program?
There is a program that displays text in accordance with the specifications below. When the original text described below is displayed, in what point size does the program display the underlined character string? Here, the first character of the original text is displayed in 10 points.
[Specifications]
The characters between <B> and </B> are displayed one point larger than the preceding character.
The characters between <S> and </S> are displayed one point smaller than the preceding character.
Each of <B> </B> and <S> </S> must be used as a pair, and both of them can be nested with each other.
[Original text]
The system administrator promotes and implements <B>department-level<B> or
<S>group-level</S> computerization</B> from a user’s <S>standpoint</S>.</B>
Which of the following is an appropriate description concerning the Java language?
Algorithms are important when a computer is used. Which of the following is an appropriate explanation of an algorithm?
As shown in Figure 1, there is a processing unit which reads two positive integer input values A1 and A2, and then writes two integer output values B1 and B2. B1 is equal to A2, and B2 is the remainder of A1 divided by A2. In Figure 2, two processing units with the same function as the above are connected in series. When A1=15 and A2=6 are given to the left-hand unit in Figure 2, what is the output value of B1 for the right-hand unit?
Figure 1
Figure 2
When the process that is shown in the flowchart is ended, which of the following is the value of x?
Note: The condition of the either boundary of the iteration indicates the end condition.
In a queue, three (3) elements 33, 27, and 12 are enqueued in this order. After the element 45 is enqueued to this queue, two (2) elements are retrieved (or dequeued). Which of the following is the second element to be retrieved?
Which of the following represents a processing procedure of a program graphically?
Which of the following is the method for describing the logical structure of a sentence in XML?
A stack is a first-in last-out data structure. By using a stack, a device receives data from the right side, changes their order and sends them to the left side, as shown in the figure below. There are three (3) types of operations available on the device, as described below.
When the device receives X, Y, and Z in this order from the right side, which of the following is the order in which the device cannot send them to the left side even if the operations (1) to (3) are combined?
Among the program control structures, which of the following is classified as a “while-type” loop structure?
Among the items A through C described below about programming languages, which of the following is the list that contains all of the appropriate items?
Which of the following is an appropriate description concerning the usage of HTML (Hyper Text Markup Language) tags?
In the data structure called a queue that is suitable for performing first-in first-out (FIFO) processing, values are stored in the order of “8”, “1”, “6”, and “3”, and then a value is removed twice continuously. Which of the following is the value that is obtained by the second removal?
A markup language specifies the character color according to the “Syntax and meaning of the markup language definition section” below. When an element (parent) contains another element (child), the child inherits the parent’s specifications, but priority is given to the child-specific specifications if the child and the parent have different values specified for the same attribute. When the text in the “Example” below is displayed according to this rule, which of the following is the appropriate display attribute for the underlined character string? Here, “<strong>character string</strong>” specifies the character string to be emphasized, for example by using bold font.
Which of the following is an appropriate explanation of an algorithm that is used on a computer?