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 sum receives an integer array array with at least two elements and two positive integers k and m (k < m ≤ number of elements in array). It calculates the sum of even elements of the array array whose indices are from k to m.
Answer group
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.
In statistics, the mode is the value that occurs most frequently in a dataset. For example, the mode of the integer array {2, 1, 1, 9, 6, 6, 2, 5, 6} is 6, as it occurs most often. The function findMode receives an integer array arr as a dataset and returns the mode for it.
Answer group
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.
Given an array of positive integers and a target sum, the problem is to find the subarray whose sum is equal to the target sum. A subarray is a part of the given array composed of contiguous elements. For example, when the target sum is 14, the shaded subarray in the figure satisfies the given condition.
Figure Example of an array
The procedure subArraySum receives an integer array arr and an integer value targetSum as arguments and finds the subarray whose sum is equal to the target sum. If a subarray that satisfies this condition is found, it prints their starting and ending indices, and finishes the task. Otherwise, it prints the message “No subarray found”.
Answer group
From the answer group below, select the correct combination of answers to be inserted into A through C in the program.
The procedure reverse_digits receives one positive integer argument named num and outputs both the original integer and the integer with its digits reversed. Assume that the ones digit of num is not 0.
Example:Number is 456, output 654Number is 23407, output 70432
Answer group
From the answer group below, select the correct combination of answers to be inserted into A and B in the program.
Prime numbers are the positive integers that are only divisible by the number itself and 1. Procedure printPrime receives the integer N (N ≥ 1) as an argument and prints the first N prime numbers. For example, printPrime( will print “2 3 5 7 11 13”.
Answer group
From the answer group below, select the correct answer to be inserted into blank in the description.
Class Rectangle represents a two-dimensional figure, and class Cuboid represents a three-dimensional figure. The class Cuboid is a subclass of the class Rectangle. Figures 1 and 2 explain the classes Rectangle and Cuboid, respectively.
Figure 1 Class Rectangle
Figure 2 Class Cuboid
When the program is executed, it is expected to produce the output “blank”.
Answer group
From the answer group below, select the correct combination of answers to be inserted into A and B in the program.
A singly linked list can be reversed using the following recursive procedure.
Let head be the first element of the list, and let elm be undefined.
(a) Reverse the order of the elements in the list starting from head, and set the next element of the last element in the reversed list—that is, the next element of head—to elm.
To “reverse the order of the elements in the list starting from head,” reverse the list starting from the next element of head, and then connect head to the end of the reversed list. In other words, execute (a) by setting head as elm, and the next element of head as head.
The recursive function reverseList reverses a singly linked list and returns the head of the reversed list. Initially, the function reverseList is called as reverseList(. Here, head is the head of the singly linked list before reversal and is of type ListElement. The table provides an explanation of the member variables of the class ListElement. ListElement-type variables store references to instances of the class ListElement.
Table Explanation of the member variables of the class ListElement
Answer group
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.
Stack stores data using first-in, last-out ordering. Here, the items stored in the stack are integer values, and the stack is controlled by the procedure push and the function pop. The procedure push adds an item given as an argument to the top of the stack, and the function pop removes the top item from the stack and returns it. The global variable stck is an array of 10 integers that stores the stack items, and the global variable tos is the pointer that points to the topmost item of the stack.
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 traverse traces through a vertex of the graph in Figure 1, and outputs all vertex numbers in the graph. One of the vertex numbers of the graph is specified with the argument k. The global 2-dimensional array graph represents the graph in Figure 1. Each element graph[i,j] is equal to 1 if there is an edge between vertices i and j, and 0 otherwise. The array visited stores boolean values, where visited[i] indicates whether vertex i of the graph has been visited or not during the procedure. When the procedure is called as traverse(, the output is in the order blank.
Figure 1 Graph that is handled by the program
Here, the procedure traverse uses a queue represented by the class Queue. Figure 2 provides an explanation of the class Queue.
Figure 2 Explanation of the class Queue
Answer group
From the answer group below, select the correct combination of answers to be inserted into A and B in the program.
The procedure insertAfter inserts an element into a singly linked list at the position after an existing element with a specific data value. The argument targetData is a string type data that represents the value of the existing element in the list, after which a new element is to be inserted. If no corresponding element exists, no action is taken. The argument newData is also a string type data represents the value of the new element to be inserted.
The class Element represents each element of the linked list. The figure explains the constructor and the member variables of the class Element. Element-type variables store references to instances of the class Element. A reference to the first element in the list is pre-stored in the global variable head.
Figure Class Element
Answer group
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 bubble sort compares adjacent elements in an array and swaps them if they are out of order. It makes multiple passes through an array. The bubble sort can be modified to stop early if it finds that the array has become sorted. The function quickBubble is modified from conventional bubble sort, which sorts the elements in ascending order, to recognize a sorted array and stop early. For example, the sorting of the unordered array {18, 1, 8, 6, 2, 9, 12, 14, 7, 11} is completed in six passes.
Answer group
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 containsSubstring receives two-character arrays str and seq as arguments, and returns a boolean value indicating whether the character array str contains the sequence seq as a substring. The character array str contains seq as a substring if every sequence of consecutive characters in seq exists somewhere in the sequence of characters in str, in the same order. For example, containsSubstring( returns true, and containsSubstring( returns false. Assume that the number of elements in str and seq is one or more.
Answer group
From the answer group below, select the correct combination of answers to be inserted into A through C in the program.
Binary Search Trees (BST) are a fundamental data structure where each node has at most two children: a left child and a right child. The key property of a BST is that each value of all nodes in its left subtree are less than the value of the node, and each value of all nodes in its right subtree are greater than the value of the node. The table shows the member variables of the class Node. Node-type variable holds a reference to an instance of the class Node. Each node in a BST has a different value.
Table Member variables of class Node
The function remove removes a node with the same key value as the argument key from the BST specified by the argument node and returns the resulting BST. The function searches for a node with the same key value, and if the found node (call it X here) does not have a right subtree, the function returns its left subtree. If X has a right subtree, the function locates the node (call it Y here) with the smallest key value in the right subtree, replaces the key value of X with that of Y, and then removes Y. If there is no node with the same key value in the BST, the function performs no operations. The procedure test demonstrates this behavior by removing 1 node from a BST containing 7 nodes. The figure shows the BST before and after node removal.
Figure BST before and after node removal
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.
A 3 × 3 normal magic square is a 3 × 3 matrix where the sum of the elements for each row, each column, and each diagonal is the same. The square contains the numbers 1 to 9, exactly as shown in the figure.
Figure 3 × 3 normal magic square
The function checkMagicSquare receives a two-dimensional 3 × 3 integer array (matrix) m containing the numbers 1 to 9, and returns whether the given matrix is a magic square or not.
Answer group
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.
Inverse document frequency (IDF) is a metric used to evaluate the importance of a word in a document relative to a document collection. The function calcIDF receives a string term and an array of strings corpus as arguments, and calculates and returns the IDF score for the term based on the given corpus. The corpus of documents corpus is given as a string array. An example of corpus that indicates 3 documents is as follows:
The table shows the description of the functions used in the program.
Table Functions
Traditionally, IDF is computed using the following formula:
IDF(t) = log ( N1 + df(t) )
Where N is the total number of documents, t refers to a specific term or word in a document, and df(t) is the number of documents containing the term t.
For example, the return value of calcIDF( is log(3 ÷ (1 + 2)) = 0 when array corpus is assigned as shown in the above example. Because the total number of documents is 3, and the total number of documents that include the word “ITPEC” is 2.
Answer group
From the answer group below, select the correct combination of answers to be inserted into blank in the program. Here, the array index starts at 0.
The Jaccard similarity index, J, measures the similarity between two sets by computing the ratio of the number of elements in their intersection to the number of elements in their union, i.e., J(A, B) = |A∩B| / |A∪B|, where A and B represent sets, ∩ and ∪ represent the intersection and the union set operations, respectively, and |…| is the operator to calculate the number of elements in a set. The intersection operation builds a new set taking members that are common to both sets; while the union operation builds a set taking all members of both sets, where each member will appear only once. For instance, A = {3, 4, 6, 7} and B = {2, 4, 5}, then A∩B = {4}, A ∪ B = {2, 3, 4, 5, 6, 7}, |A| = 4, | B| = 3, |A∩B| = 1, and |A∪B| = 6.
The function jaccardSimilarity calculates the Jaccard similarity stated above and returns it. The definitions of variables used in the function are stated in the below table.
Table Variable definitions
Answer group
From the answer group below, select the most appropriate combination of answers to be inserted into A and B in the description.
Company P is a small business that recently formed a data analytics team to perform business data analytics using internal business data. This data is stored on a database system configured with a synchronous (real-time) mirror. The database is backed up regularly. The database servers and IT infrastructure are maintained by a third-party IT support provider.
A junior data analyst was mistakenly granted database superuser privileges to the production database. This decision was made due to a lack of security understanding in the company. The data analyst, unfamiliar with the sensitivity of their access level, was tasked with executing a series of routine database queries and migrations. However, due to an error in a script, the data analyst accidentally ran a command that dropped critical tables, resulting in a significant loss of data. This caused the company’s internal applications to stop working.
The company engaged their IT support provider, and the database system was quickly put back in service by A. To prevent this incident from happening again, their IT support provider recommended that the company implement B.
Answer group
From the answer group below, select the most appropriate combination of answers to be inserted into A and B in the description.
Company Q is a mid-sized online retailer selling a wide range of daily necessities to a large number of general consumers. Customers are required to create an account and log in to the company’s e-commerce website to make purchases. The e-commerce website is constructed using an open-source content management system (CMS) with various plugins. It is hosted on the company’s on-premise web servers located in the Demilitarized Zone (DMZ). Customer data is stored in the database installed on the web server as well. Since the e-commerce site received orders from many customers, availability of the e-commerce website is critical, and the maximum tolerable downtime (MTD) is limited to one hour per week.
The server is protected by a packet filtering firewall that permits access only through ports 80 and 443. Mr. K is an administrator responsible for both the operations and security of the company’s e-commerce website. He maintains the configuration of the firewall and other security measures as well as patch management. For patching the company’s e-commerce website, compatibility testing is important to maintain website stability. It takes at least three days to complete compatibility testing for one component. Due to limited human resource, it is unrealistic to perform compatibility tests in parallel and finish them quickly. Therefore, the patch management rule is to apply patches for the web server’s OS and the core CMS components within a week of their release, while updates for other components including plugins are scheduled to be applied within six months. Patches for the web server’s OS and the core CMS components are released on a monthly basis, while updates for other components including plugins are released each month as well.
One day, Company Q’s e-commerce website was compromised and the database on the webserver was accessed by an unauthorized third party. The investigation revealed that this was caused by an unpatched vulnerability in a plugin enabled on the CMS. This plug-in was critical to the functioning of the e-commerce website. The latest version of the plugin, which includes a fix for this vulnerability, was released by the vendor three months ago. The exploitation of this vulnerability has been reported publicly since last month. Company Q was still conducting compatibility testing, and the update to the latest version was scheduled for a later time.
To prevent similar incidents from occurring, Mr. K is required to revise the patch management rules for Q’s e-commerce website. In consideration of the workload associated with compatibility testing, Mr. K proposed updating the patch management rule for the e-commerce website to A. Furthermore, as a protective measure to prevent the servers from exploitation during the interim period before patches are applied, Mr. K proposed B.
Answer group
From the answer group below, select the correct combination of answers to be inserted into A and B in the description.
Company R is a software company that sells video editing software for consumers. The company has branch offices in multiple countries, all managed by its head office. In Company R’s customer support department, customer satisfaction surveys are sent to selected customer who have received support. The survey results are aggregated at each branch, and must be sent to the customer survey analysis team at the head office every day. Ms. T at the customer survey analysis team at the head office is responsible for managing and securing the survey data. The considerations for collecting survey data from each branch office are as follows:
Ms. T decided to adopt a new method in which the branch offices upload the survey data, encrypted using file encryption, to a shared folder. She set up this shared folder with access permissions granted to both the head office and branch office staff, and instructed the branch office staff to upload the encrypted survey data to it. Taking into account the considerations related to collecting information from the branches, Ms. T decided to use A as the encryption method. In this method, the key used for encrypting the survey data is encrypted using the public key of B .
Answer group
From the answer group below, select the most appropriate combination of answers to be inserted into A and B in the description.
Company S is a software company that develops web applications. Some of web applications that Company S develops are open-sourced. The web application code is made publicly available in a repository accessible to anyone. These open-source web applications include features that interact with external services using API keys.
One day, an external security researcher reported to Company S’s security team that the code published in the company’s repository contained an API key. Company S immediately made the repository private and deactivated the API key. Upon further investigation, it was found that a developer on the web application development team accidentally hard-coded the API key when testing a new feature, and committed the code to the source code repository. As a result, this allowed unauthorized users to access external services using the API key.
To prevent a recurrence of such an incident, the security team has proposed adding a coding rule that instead of hard-coding the secrets including the API, use environment variables that allow the application code to be accessed dynamically. Additionally, the team suggested A to detect any secrets that might have been missed by this rule before committing code to a publicly accessible repository. Furthermore, to minimize damage in case any secrets still evade detection, he proposed B.
Answer group