Ngân hàng đề / Luyện thi phong cách Bebras

Bebras Practice · Cấp độ 4 / Level 4 (Song ngữ Anh–Việt · Lớp 7–8 · 15 câu)

Điểm: 0/15

Question 1

Dễ · +10 điểm

[Part A · Easy] A sensor transmits temperature readings as a 6-bit unsigned binary integer (weights $32, 16, 8, 4, 2, 1$ from left to right). What decimal integer corresponds to 101101?

Hình minh họa câu 1
Chọn đáp án

Xem đáp án và lời giải

Đáp án: $45$

Answer / Đáp án: 45

Step-by-step (EN): Add weights at 1 positions: $32 + 0 + 8 + 4 + 0 + 1 = 45$.

Giải chi tiết (VI): Cộng các trọng số tại vị trí có bit 1: $32 + 8 + 4 + 1 = 45$.

Computational Thinking / Tư duy Máy tính: 6-bit Unsigned Binary Representation (Biểu diễn số nguyên nhị phân).

Question 2

Dễ · +10 điểm

[Part A · Easy] A Binary Search Tree routes each lookup key K starting from the root: if the test is true (Yes), go left; otherwise (No), go right. Which leaf bucket is reached when searching for K = 35?

Hình minh họa câu 2
Chọn đáp án

Xem đáp án và lời giải

Đáp án: Bucket 29

Answer / Đáp án: Bucket 29

Step-by-step (EN): At root: Is $35 < 40$? Yes $\to$ go left to Key < 20?. Next: Is $35 < 20$? No $\to$ go right to Bucket 29.

Giải chi tiết (VI): Tại gốc: $35 < 40$ là Đúng (Yes) $\to$ rẽ trái tới Key < 20?. Tiếp theo: $35 < 20$ là Sai (No) $\to$ rẽ phải tới ô 29.

Computational Thinking / Tư duy Máy tính: Binary Search Trees — BST Lookup (Tra cứu trên cây tìm kiếm nhị phân).

Question 3

Dễ · +10 điểm

[Part A · Easy] A stack-based calculator evaluates Postfix (Reverse Polish) expressions from left to right: numbers are pushed onto a stack, and each operator (+, -, *) pops the top two numbers $a$ (below) and $b$ (top), computes $a \text{ op } b$, and pushes the result back. For example, 5 2 - gives $5 - 2 = 3$. What is the value of 4 5 + 3 * 7 -?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $20$

Answer / Đáp án: 20

Step-by-step (EN): Trace stack: 4 $\to$ [4]; 5 $\to$ [4, 5]; + $\to$ [9]; 3 $\to$ [9, 3]; * $\to$ [27]; 7 $\to$ [27, 7]; - $\to$ $27 - 7 = 20$.

Giải chi tiết (VI): Theo dõi ngăn xếp: đẩy 4, 5 $\to$ gặp + tính $4+5=9$ $\to$ đẩy 3 $\to$ gặp * tính $9 \times 3 = 27$ $\to$ đẩy 7 $\to$ gặp - tính $27 - 7 = 20$.

Computational Thinking / Tư duy Máy tính: Stack Evaluation of Postfix / RPN Expressions (Tính biểu thức hậu tố bằng ngăn xếp).

Question 4

Dễ · +10 điểm

[Part A · Easy] In this circuit, XOR outputs 1 when its two inputs are different (0,1 or 1,0) and 0 when they are equal; BUF passes its input unchanged (C -> C); AND outputs 1 only when both inputs are 1. For which input triple (A, B, C) does OUT = 1?

Hình minh họa câu 4
Chọn đáp án

Xem đáp án và lời giải

Đáp án: (1, 0, 1)

Answer / Đáp án: (1, 0, 1)

Step-by-step (EN): Formula: OUT = (A XOR B) AND C. For OUT = 1, we must have C = 1 AND A != B. Only (1, 0, 1) satisfies both ($1 \oplus 0 = 1$, and $1 \land 1 = 1$).

Giải chi tiết (VI): Biểu thức đầu ra là OUT = (A XOR B) AND C. Để OUT = 1, bắt buộc C = 1 và A != B. Trong $4$ phương án chỉ có (1, 0, 1) thỏa mãn.

Computational Thinking / Tư duy Máy tính: XOR & Boolean Circuit Synthesis (Cổng XOR và phân tích mạch tổ hợp).

Question 5

Dễ · +10 điểm

[Part A · Easy] A dictionary contains $1{,}000$ words sorted in strict alphabetical order. Using Binary Search (always checking the middle word of the remaining range and eliminating half), what is the maximum number of word comparisons needed in the worst case to determine whether a target word is in the dictionary?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $10$

Answer / Đáp án: 10

Step-by-step (EN): Since $2^9 = 512 < 1{,}000 < 1{,}024 = 2^{10}$ (halving: $1000 \to 499 \to 249 \to 124 \to 61 \to 30 \to 14 \to 6 \to 2 \to 1 \to 0$), at most $10$ comparisons are required.

Giải chi tiết (VI): Vì $2^9 = 512 < 1.000 < 1.024 = 2^{10}$, mỗi lần so sánh thu hẹp tối thiểu một nửa khoảng tìm kiếm nên trong trường hợp xấu nhất cần tối đa $10$ lần so sánh.

Computational Thinking / Tư duy Máy tính: Logarithmic Complexity $O(\log_2 N)$ (Độ phức tạp logarit của tìm kiếm nhị phân).

Question 6

Trung bình · +20 điểm

[Part B · Medium] An autonomous delivery cart travels along one-way streets from depot A to customer F. Numbers on arrows indicate energy cost (in Wh). What is the minimum energy cost from A to F?

Hình minh họa câu 6
Chọn đáp án

Xem đáp án và lời giải

Đáp án: $13$

Answer / Đáp án: 13

Step-by-step (EN): Run Dijkstra from A:

  • d(A) = 0, d(C) = 2
  • d(B) = min(6, d(C)+3) = 5 (A->C->B)
  • d(E) = min(d(C)+7, d(B)+2) = min(9, 7) = 7 (A->C->B->E)
  • d(D) = min(d(B)+4, d(E)+1) = min(9, 8) = 8 (A->C->B->E->D)
  • d(F) = min(d(D)+5, d(E)+6) = min(13, 13) = 13.

Giải chi tiết (VI): Áp dụng thuật toán Dijkstra từ A:

  • d(A) = 0, d(C) = 2
  • d(B) = min(6, 2+3) = 5 (qua A->C->B)
  • d(E) = min(2+7, 5+2) = 7 (qua A->C->B->E)
  • d(D) = min(5+4, 7+1) = 8 (qua A->C->B->E->D)
  • d(F) = min(8+5, 7+6) = 13.

Computational Thinking / Tư duy Máy tính: Edge Relaxation in Dijkstra's Algorithm (Làm chặt cạnh trên đồ thị có hướng).

Question 7

Trung bình · +20 điểm

[Part B · Medium] A packet router sends a token from top-left (1, 1) to bottom-right G = (4, 4) moving only Right (R) or Down (D) by 1 cell per step, never entering the two blocked dark cells (2, 2) and (3, 3). How many distinct shortest paths exist from (1, 1) to (4, 4)?

Hình minh họa câu 7
Chọn đáp án

Xem đáp án và lời giải

Đáp án: $4$

Answer / Đáp án: 4

Step-by-step (EN): Build the $4 \times 4$ DP path-count table (dp[r][c] = dp[r-1][c] + dp[r][c-1], with 0 at blocked cells):

  • Row 1: 1, 1, 1, 1
  • Row 2: 1, X(0), 1, 2
  • Row 3: 1, 1, X(0), 2
  • Row 4: 1, 2, 2, 4.

Thus there are $4$ distinct paths.

Giải chi tiết (VI): Lập bảng quy hoạch động dp[r][c] = dp[r-1][c] + dp[r][c-1] (các ô khóa gán bằng 0):

  • Hàng 1: 1, 1, 1, 1
  • Hàng 2: 1, 0, 1, 2
  • Hàng 3: 1, 1, 0, 2
  • Hàng 4: 1, 2, 2, 4.

Vậy tại ô (4, 4) có đúng $4$ đường đi.

Computational Thinking / Tư duy Máy tính: 2D Dynamic Programming on Grids (Quy hoạch động đếm đường đi trên lưới).

Question 8

Trung bình · +20 điểm

[Part B · Medium] A lexical scanner starts at S0 and reads the character stream a a b b a a b from left to right. In which state does the scanner finish?

Hình minh họa câu 8
Chọn đáp án

Xem đáp án và lời giải

Đáp án: S0

Answer / Đáp án: S0

Step-by-step (EN): Trace step by step: S0 $\xrightarrow{a}$ S1 $\xrightarrow{a}$ S1 $\xrightarrow{b}$ S3 $\xrightarrow{b}$ S3 $\xrightarrow{a}$ S2 $\xrightarrow{a}$ S2 $\xrightarrow{b}$ S0.

Giải chi tiết (VI): Truy vết từng ký tự: S0 $\xrightarrow{a}$ S1 $\xrightarrow{a}$ S1 $\xrightarrow{b}$ S3 $\xrightarrow{b}$ S3 $\xrightarrow{a}$ S2 $\xrightarrow{a}$ S2 $\xrightarrow{b}$ S0.

Computational Thinking / Tư duy Máy tính: State Transition Simulation (Mô phỏng máy trạng thái hữu hạn).

Question 9

Trung bình · +20 điểm

[Part B · Medium] A video rendering pipeline consists of $5$ stages (T1–T5) with durations in minutes (m) and dependency arrows shown. Unlimited CPU cores are available for parallel execution. What is the earliest completion time (in minutes) of T5?

Hình minh họa câu 9
Chọn đáp án

Xem đáp án và lời giải

Đáp án: $16$

Answer / Đáp án: 16

Step-by-step (EN): Earliest finish times (EFT):

  • EFT(T1) = 5, EFT(T2) = 4
  • EFT(T3) = EFT(T1) + 6 = 11
  • EFT(T4) = max(EFT(T1), EFT(T2)) + 8 = max(5, 4) + 8 = 13
  • EFT(T5) = max(EFT(T3), EFT(T4)) + 3 = max(11, 13) + 3 = 16 minutes.

Giải chi tiết (VI): Tính thời điểm hoàn thành sớm nhất (EFT):

  • T1 xong lúc $5\text{m}$; T2 xong lúc $4\text{m}$.
  • T3 chờ T1: xong lúc $5 + 6 = 11\text{m}$.
  • T4 chờ cả T1 và T2: bắt đầu lúc $\max(5, 4) = 5\text{m}$, xong lúc $5 + 8 = 13\text{m}$.
  • T5 chờ cả T3 và T4: bắt đầu lúc $\max(11, 13) = 13\text{m}$, xong lúc $13 + 3 = 16$ phút.

Computational Thinking / Tư duy Máy tính: DAG Scheduling & Critical Path T1 -> T4 -> T5 (Phân tích đường găng).

Question 10

Trung bình · +20 điểm

[Part B · Medium] Six conference talks have start and end times: [9:00–10:30], [9:30–10:15], [10:15–11:00], [10:30–12:00], [11:00–11:45], and [11:45–12:30]. One auditorium can host only one talk at a time (a new talk may start at the exact minute the previous talk ends). What is the maximum number of talks that can be scheduled in this auditorium?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $4$

Answer / Đáp án: 4

Step-by-step (EN): Use the Earliest Finish Time greedy algorithm (sort by end time): 1) Pick [9:30–10:15] (ends earliest at 10:15). 2) Next compatible: [10:15–11:00]. 3) Next compatible: [11:00–11:45]. 4) Next compatible: [11:45–12:30]. Total $= 4$ non-overlapping talks.

Giải chi tiết (VI): Áp dụng thuật toán tham lam chọn việc kết thúc sớm nhất: 1) Chọn [9:30–10:15] 2) Chọn [10:15–11:00] 3) Chọn [11:00–11:45] 4) Chọn [11:45–12:30]. Tổng cộng xếp được tối đa $4$ bài không chồng lấn.

Computational Thinking / Tư duy Máy tính: Interval Scheduling — Greedy Earliest-Finish-Time Algorithm (Lập lịch đoạn thẳng tham lam).

Question 11

Khó · +30 điểm

[Part C · Hard] A recursive function $f(n)$ on non-negative integers is defined by:

  • $f(0) = 1$, $f(1) = 2$
  • If $n \geqslant 2$ is even: $f(n) = f(n / 2) + 3$
  • If $n \geqslant 3$ is odd: $f(n) = f(n - 1) + 2$

Compute the exact value of $f(26)$.

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $18$

Answer / Đáp án: 18

Step-by-step (EN): Evaluate along the call chain 26 -> 13 -> 12 -> 6 -> 3 -> 2 -> 1:

  • $f(1) = 2$
  • $f(2) = f(1) + 3 = 5$
  • $f(3) = f(2) + 2 = 7$
  • $f(6) = f(3) + 3 = 10$
  • $f(12) = f(6) + 3 = 13$
  • $f(13) = f(12) + 2 = 15$
  • $f(26) = f(13) + 3 = 18$.

Giải chi tiết (VI): Tính ngược theo dây chuyền gọi đệ quy 1 -> 2 -> 3 -> 6 -> 12 -> 13 -> 26:

  • $f(1) = 2$
  • $f(2) = 2 + 3 = 5$
  • $f(3) = 5 + 2 = 7$
  • $f(6) = 7 + 3 = 10$
  • $f(12) = 10 + 3 = 13$
  • $f(13) = 13 + 2 = 15$
  • $f(26) = 15 + 3 = 18$.

Computational Thinking / Tư duy Máy tính: Recursion & Binary Decomposition (Đệ quy chia đôi theo biểu diễn nhị phân).

Question 12

Khó · +30 điểm

[Part C · Hard] A snowplow needs to traverse every street in the diagram at least once (Eulerian trail) without lifting its blade — meaning it traverses each edge exactly once — starting at one intersection and ending at another. Which pair of intersections must be its {Start, Finish}?

Hình minh họa câu 12
Chọn đáp án

Xem đáp án và lời giải

Đáp án: {B, C}

Answer / Đáp án: {B, C}

Step-by-step (EN): Check vertex degrees: $\deg(A) = 2$ (even), $\deg(D) = 2$ (even), $\deg(B) = 3$ (odd), $\deg(C) = 3$ (odd). By Euler's Theorem, a trail visiting every edge exactly once exists iff there are $0$ or $2$ odd-degree vertices, and when there are $2$, the trail must start and end at those two odd vertices {B, C}!

Giải chi tiết (VI): Tính bậc của từng đỉnh: $\deg(A) = 2$ (chẵn), $\deg(D) = 2$ (chẵn), $\deg(B) = 3$ (lẻ), $\deg(C) = 3$ (lẻ). Theo Định lý Euler, đường đi qua mọi cạnh đúng $1$ lần khi có $2$ đỉnh bậc lẻ bắt buộc phải xuất phát và kết thúc tại hai đỉnh bậc lẻ {B, C} (ví dụ B -> A -> C -> B -> D -> C).

Computational Thinking / Tư duy Máy tính: Eulerian Trails & Vertex Degree Parity (Đường đi Euler & Tính chẵn lẻ bậc đỉnh).

Question 13

Khó · +30 điểm

[Part C · Hard] A Quadtree compresses a $2^k \times 2^k$ black-and-white image recursively:

  • If all pixels in the current square have the same color, create 1 leaf node.
  • Otherwise, create 1 internal root node and split the square into $4$ equal quadrants (top-left, top-right, bottom-left, bottom-right), compressing each quadrant recursively.

How many total nodes (counting both internal nodes and leaf nodes) are in the Quadtree of this $4 \times 4$ image?

Hình minh họa câu 13
Chọn đáp án

Xem đáp án và lời giải

Đáp án: $9$

Answer / Đáp án: 9

Step-by-step (EN): 1) Whole $4 \times 4$ has mixed colors $\to$ $1$ root node, split into four $2 \times 2$ quadrants:

  • Top-left (11 / 11): uniform dark $\to$ $1$ leaf node.
  • Bottom-left (00 / 00): uniform white $\to$ $1$ leaf node.
  • Bottom-right (11 / 11): uniform dark $\to$ $1$ leaf node.
  • Top-right (00 / 01): mixed! $\to$ $1$ internal node + $4$ single-pixel leaf nodes ($1 + 4 = 5$ nodes).

Total nodes $= 1 + 1 + 1 + 1 + 5 = 9$.

Giải chi tiết (VI): 1) Toàn ảnh $4 \times 4$ lẫn hai màu $\to$ tạo $1$ nút gốc và chia thành $4$ góc $2 \times 2$:

  • Góc trên-trái (11 / 11): đồng màu đen $\to$ $1$ nút lá.
  • Góc dưới-trái (00 / 00): đồng màu trắng $\to$ $1$ nút lá.
  • Góc dưới-phải (11 / 11): đồng màu đen $\to$ $1$ nút lá.
  • Góc trên-phải (00 / 01): lẫn màu $\to$ $1$ nút trong chia tiếp thành $4$ nút lá $1 \times 1$ ($5$ nút).

Tổng số nút $= 1 + 1 + 1 + 1 + 5 = 9$ nút.

Computational Thinking / Tư duy Máy tính: Quadtree Spatial Indexing & Hierarchical Compression (Cây tứ phân nén không gian ảnh).

Question 14

Khó · +30 điểm

[Part C · Hard] A cache holds at most $3$ pages using the Least Recently Used (LRU) eviction policy: whenever a requested page is not in the cache and the cache is full, the page that was accessed longest ago is evicted. Starting from an empty cache, the CPU requests pages in order: A, B, C, A, D, B, E. Which $3$ pages remain in the cache at the end?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: {B, D, E}

Answer / Đáp án: {B, D, E}

Step-by-step (EN): Track cache ordered from Least Recently Used $\to$ Most Recently Used: 1) A: [A] 2) B: [A, B] 3) C: [A, B, C] 4) A (hit! refresh A): [B, C, A] 5) D (miss, evict LRU B): [C, A, D] 6) B (miss, evict LRU C): [A, D, B] 7) E (miss, evict LRU A): [D, B, E].

Giải chi tiết (VI): Theo dõi thứ tự trong cache từ dùng lâu nhất $\to$ vừa mới dùng: 1–3) Nạp A, B, C: [A, B, C] 4) Gọi lại A (trúng cache, A lên mới nhất): [B, C, A] 5) Nạp D (đẩy B ra): [C, A, D] 6) Nạp B (đẩy C ra): [A, D, B] 7) Nạp E (đẩy A ra): còn {B, D, E}.

Computational Thinking / Tư duy Máy tính: Operating Systems — LRU Cache Replacement Algorithm (Thuật toán thay thế trang LRU).

Question 15

Khó · +30 điểm

[Part C · Hard] Two players take turns removing stones from a single pile of $29$ stones. On each turn, a player must remove $1$, $2$, $3$, or $4$ stones. The player who takes the last stone wins. How many stones must the first player remove on the opening move to guarantee a win against any defense?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $4$

Answer / Đáp án: 4

Step-by-step (EN): Winning invariants are multiples of $1 + 4 = 5$ left for the opponent ($0, 5, 10, 15, 20, 25$): whenever the opponent removes $k \in \{1{,}2{,}3{,}4\}$ stones, you remove $5 - k$ stones! Since $29 = 5 \times 5 + 4$, the first player must remove $4$ stones to leave $25$.

Giải chi tiết (VI): Các trạng thái thua (để lại cho đối thủ) là bội của $1 + 4 = 5$ ($0, 5, 10, 15, 20, 25$), vì sau đó dù đối thủ bốc $k \in \{1{,}2{,}3{,}4\}$ viên, người đi trước luôn bốc bù $5 - k$ viên! Vì $29 = 25 + 4$, nước đầu tiên người thứ nhất phải bốc đúng $4$ viên (để lại $25$ viên).

Computational Thinking / Tư duy Máy tính: Combinatorial Game Theory — Modulo Invariants (Bất biến đồng dư trong trò chơi đối kháng).

Cài đặt ứng dụng O₂ Education

Thêm O₂ Education vào Màn hình chính trên iPhone / iPad để học nhanh như ứng dụng gốc:

  1. Nhấn biểu tượng Chia sẻ trên thanh công cụ Safari.
  2. Cuộn xuống và chọn Thêm vào MH chính (Add to Home Screen).
  3. Nhấn Thêm ở góc trên bên phải để hoàn tất.