Explanation of Question 4 from Japan’s 2025 FE Examination Section B Public Sample Problems

www.youtube.com In this video, we provide a thorough explanation of Question 4, “Array Pattern Matching,” from Japan’s 2025 FE Examination Section B Public Sample Problems. The ability to correctly count how many times statements are executed and how many times conditional expressions evaluate to true is an essential skill for succeeding in Section B. This video focuses not only on identifying the correct answer but also on teaching how to trace the program step by step. The function used in this problem, search, scans through the character array data and finds every position where the sequence of elements matches the array key exactly. It then returns an array containing the starting indices of all matching locations. In this case, the task is to determine how many times the conditional expression on line β evaluates to true when calling search({"a","b","a","b","c","a","b","c"},{"a","b","c"}). The video starts by confirming the number of elements in data (8) and key (3), and then identifies how many times the outer loop executes. Since lenData − lenKey + 1 equals 8 − 3 + 1 = 6, the outer loop runs with i taking values from 1 to 6. From there, we trace each comparison step inside the inner loop for every value of i. Special attention is given to identifying where the comparison fails when i = 1, and how all comparisons succeed for i = 3 and i = 6, resulting in 3 and 6 being added to the result array. By writing out the actual contents of the arrays and tracing each check, the video makes it easy to see exactly when the condition on line β is evaluated and when it becomes true. The final conclusion is that the conditional expression on line β evaluates to true a total of 8 times. Thus, the correct answer is choice “ク,” and the search function returns the array {3, 6}. Through this explanation, you will learn the fundamental structure of array-search algorithms, how to properly handle indices, and how to perform precise tracing without missing any execution counts. This content is especially useful for examinees who want to move beyond “guessing” and start answering Section B programming questions with clear, logical confidence.