Skip to main content
ZhimaYuandi

PREDICT · EXPERIMENT · EXPLAIN

Computer Science Fundamentals, Hands On

Five ideas that are easy to mix up. Make a prediction, try a real experiment, then explain what happened.

For students, developers and learners reviewing these fundamentals for China’s software qualification exams. Basic familiarity with the terms is helpful; start with any topic. This is not a complete exam course.

5 experiments5 self-checks with explanationsStart anywhere
01

Addresses & memory

Paging Address Translation

Split an address and see how a page table changes the frame while preserving the offset.

01 · Predict first

If the logical address stays the same but the frame changes, does the offset change?

02 · Try the experiment

  1. Open the lab and choose “Try the lab”. Keep “Logical address A” at 0x2C7D and “Page size S” at 4096.
  2. Inspect the address split and page table: page 2, offset 3197 (0xC7D); page 2 initially maps to frame 6.
  3. Check the physical address 0x6C7D. Then change page 2’s frame number to 5 and inspect the result.
Open the lab

In the lab, open Learn → Return to this route to come back to this check. Your browser’s Back button also works.

6 × 4096 + 3197 = 27773 = 0x6C7D. Changing the frame changes its base address.

The address of a page-table entry is not the final physical address. This task uses basic paging.

03 · Check your understanding

With the same logical address and page size, change page 2’s frame number to 5. What is the physical address?
See the answer and explanation

B · 0x5C7D

The offset remains 0xC7D. Physical address = 5 × 4096 + 3197 = 23677 = 0x5C7D. Neither the original logical address nor the frame base alone is the result.

02

Computer networks

IP Addressing & Subnetting

Use an address and mask to find a subnet, then distinguish network, broadcast and usable host addresses.

01 · Predict first

If 192.168.10.77/26 and .127 share a subnet, can .127 be assigned to an ordinary host?

02 · Try the experiment

  1. Open “Live lab”. In “Try an example”, select “Example /26”. Use IPv4 address 192.168.10.77 with mask 255.255.255.192.
  2. Click “See results”. Find network address .64, broadcast address .127 and usable range .65–.126.
  3. Open “Compare addresses” and enter 192.168.10.110, 192.168.10.127 and 192.168.10.128 in turn. Check both subnet membership and address roles.
Open the lab

In the lab, open Learn → Return to this route to come back to this check. Your browser’s Back button also works.

This /26 block contains 64 addresses and 62 ordinary usable host addresses. .127 is the broadcast address; .128 belongs to the next subnet.

Sharing a subnet does not guarantee connectivity; routing, firewalls and links are outside this check.

03 · Check your understanding

Which is a usable ordinary host address in the same subnet as 192.168.10.77/26?
See the answer and explanation

C · 192.168.10.126

The block spans .64–.127. Excluding network address .64 and broadcast address .127 leaves .65–.126, so .126 is suitable. .128 is outside this subnet.

03

Process synchronization

Semaphore P/V Operations

Step through P, V and the wait queue in a textbook signed-semaphore model.

01 · Predict first

When S = −2, does one V wake one waiter or run all waiting processes to completion?

02 · Try the experiment

  1. Open the mutual-exclusion lab. Start with mutex = 1 and click the process buttons A, B, then C.
  2. Observe values 0, −1 and −2 as B and C join the wait queue. Click A again to perform its critical-section work.
  3. Click A again to release the resource. Check the value, ready process and remaining waiter after V.
Open the lab

In the lab, open Learn → Return to this route to come back to this check. Your browser’s Back button also works.

V changes −2 to −1 and wakes B while C waits. B becomes ready; it has not already completed its critical section.

This demo uses FIFO wake-up order; that is not a universal operating-system scheduling guarantee.

03 · Check your understanding

In this model, S = −2 and the wait queue is B, C. What follows one V(S)?
See the answer and explanation

C · S = −1; B is ready and C keeps waiting

V increments first. Because the new value is still ≤ 0, one waiter is woken. This FIFO demo wakes B, which resumes after its original P without decrementing again. Waking does not imply immediate execution.

04

Relational databases

Database Normalization Lab

Use functional dependencies and attribute closure to reason about candidate keys and partial dependencies.

01 · Predict first

If a student can take multiple courses, can student ID S alone determine course C and grade G?

02 · Try the experiment

  1. In “Find the problem”, keep “Rename a department”. Choose a prediction, click “Run this operation” and inspect the inconsistent department names.
  2. Open “Candidate keys” and keep “Enrollment · partial dependency”: S→ND, D→M, SC→G.
  3. Select only S and click “Apply one dependency” until the closure is complete. Add C and repeat, then click “Reveal every candidate key”.
Open the lab

In the lab, open Learn → Return to this route to come back to this check. Your browser’s Back button also works.

S⁺ = {S,N,D,M}, missing C and G. (SC)⁺ covers all attributes, and SC is the only candidate key. Non-prime attributes N and D depend on S, a proper subset of SC, so the relation has partial dependencies and violates 2NF.

Keys and normal forms depend on business constraints, not just whether sample rows happen to repeat.

03 · Check your understanding

Under S→ND, D→M and SC→G, why is S alone not a candidate key?
See the answer and explanation

B · S cannot determine course C or grade G

S determines N and D, then M through D, but not C. Without C, SC→G cannot derive G. S does not determine every attribute, so it is neither a superkey nor a candidate key.

05

Concurrency & isolation

Transaction Isolation Lab

Compare interleaved and serial orders to identify an overwrite based on a stale value.

01 · Predict first

Stock starts at 20. Two transactions subtract 1 and 2. If both first read 20, must the final stock be 17?

02 · Try the experiment

  1. Open “Schedule transactions”. Select “Lost update” and “RC · Read committed”. Expand “Initial stock”, set it to 20 and click “Apply stock”.
  2. Click “Run next preset step” eight times. Compare each transaction’s read, local calculation and final committed value.
  3. Reset, then manually finish all four T1 steps before all four T2 steps. Compare the final stock.
Open the lab

In the lab, open Learn → Return to this route to come back to this check. Your browser’s Back button also works.

The interleaved demo ends at 18; serial execution ends at 17. T2 overwrites T1’s committed 19 with 18 calculated from its stale read of 20.

This abstract model reads, calculates in the application, then writes a constant. It does not emulate a particular database or an atomic UPDATE stock = stock - n.

03 · Check your understanding

Why does the interleaved demo finish at 18 rather than 17 after both orders?
See the answer and explanation

C · T2 overwrites T1’s 19 with 18 computed from a stale read

Read committed avoids reading another transaction’s uncommitted data, but does not merge deductions for this program. Both read a committed 20, calculate 19 and 18 separately, then the later constant write overwrites the earlier update.

Opening a lab, marking a review and answering correctly are different records. Answers reflect your most recent submission; check again after changing a choice. One correct answer is not a mastery certificate.