7-4
At least how many bits are required to indicate the length from 0 mm to 1,000 mm in the
unit of millimeters?
7-5
4
10
1000
1001
PUSH
a)
7-6
Basic theory
There is a device where articles are accumulated upwards from the bottom and taken out
from upwards in sequential order. There are two kinds of operations for this device.
PUSH n: Accumulate an article (number n)
POP:
Extract one article from the top
If no articles are accumulated at the beginning, which of the following is the result of the
operations?
Chapter 7
a)
b)
c)
d)
PUSH 1 → PUSH 5 → POP → PUSH 7 →
POP
PUSH 6 → PUSH 4 → POP → POP → PUSH 3
c)
b)
d)
1
3
3
6
7
4
7
4
3
6
1
3
When the procedure described below is repeated to sort five numbers in ascending order,
how many times is the procedure repeated until sorting is completed?
[The order of data before sorting]
5, 1, 4, 3, 2
[Procedure]
(1) If the 1st data > the 2nd data, replace the 1st and 2nd data.
(2) If the 2nd data > the 3rd data, replace the 2nd and 3rd data.
(3) If the 3rd data > the 4th data, replace the 3rd and 4th data.
(4) If the 4th data > the 5th data, replace the 4th and 5th data.
(5) When no replacement occurs, sorting is completed.
When replacement occurs, repeat the procedure from (1).
a)
b)
c)
d)
1
2
3
4
184