Algorithm and Programming

Algorithm and Programming

61 questions · Fundamental Engineering · 51–61

Practice

Which of the following is a binary search tree?

When the procedure described below is executed in sequence for an empty stack and empty queue, what is the value assigned to variable x? Here, the functions used in the procedure are defined as follows:

[Function definitions] push(y):pushes data y onto the top of the stack. pop():removes the data from the top of the stack and returns it as the function value. enq(y):inserts data y at the tail of the queue. deq():removes the data from the head of the queue and returns it as the function value.

[Procedure]

  push(a)

  push(b)

  enq(pop())

  enq(c)

  push(d)

  push(deq())

  x ← pop()

For a function f(x, y) defined below, what is the value of f(775, 527)? Here, x mod y represents the remainder after division of x by y.

f(x, y): if y = 0 then return x else return f(y, x mod y)

The flowchart below shows the algorithm of concatenating two character strings in X and Y, with the resulting character string in Z. Which of the following is the appropriate pair of operations to insert in the blanks, A and B? Here, X and Y are character arrays of dimensions m and n, respectively, where the i-th character of each string is stored as the i-th element of the character array.

StartLoop 1k:1, 1, mALoop 1Loop 2k:1, 1, nBLoop 2End

Note:

The description in Loop 1 indicates that variable k varies from 1 to m by 1. So does Loop 2.

OptionAB

Data A, B, C and D are entered as an input sequence. Which of the following is a possible output sequence by only using a single stack?

For integers x and y (x > y ≥ 0), a function F(x, y) is defined as follows. What is the value F(231, 15)? Here, x mod y represents the remainder after division of x by y.

F(x, y) =
x(when y = 0)F(y, x mod y)(when y > 0)

In a web environment, which of the following is the name of a program that runs on a web server and achieves dynamic processing?

Which of the following is a binary search tree whose keys are numbers assigned to nodes in natural order?

Function F(n) is a recursively defined integer function that calculates the factorial of n for any non-negative integer n. Which of the following is an appropriate expression for the blank A?

F(0) = 1

F(n) = A (if n > 0)

What is the result of the procedure in the flowchart below, when x and y are positive integers?

Starts0txt < yYesEndNott − yss + 1
OptionValue of sValue of t

In a direct organization file that has a range of storage addresses one (1) through six (6), the data is stored under the conditions below. Which of the following is the key value of the data that is stored in address one (1)?

[Conditions](1)Data is stored in the order of key values three (3), four (4), eight (8), 13, 14, and 18.(2)The storage address is the value that is the remainder obtained by dividing the key value of data by five (5) and then adding one (1) to it.(3)If the storage address is already occupied, the data is stored in the next address. This process is repeated until the data is stored. The next address of the last address is the first address.(4)In the initial status, nothing is stored in the file.