Back to course

Computing Fundamentals

20 minintermediateModule 6: Engineering Foundations (Optional)Continues from hat-physics-mechanics
20 min · Module 6: Engineering Foundations (Optional) · Foundation

Why This Matters

This lesson is optional background, not a section of the HAT-1 paper. HAT-1 tests reasoning only, so nothing here is examined directly. It is included because candidates applying to computer science and software engineering programmes often want their first-course computing material refreshed before graduate study, and because number systems and Boolean logic sharpen the quantitative and analytical reasoning the test does examine.

These questions are the most predictable on the whole paper. There are only a few topics, each has one standard method, and the answers can be verified by hand. The marks are there to be taken, and the way to lose them is to have never converted a binary number under a clock.

A Simple Model

Three operations cover most of this area. Learn them as procedures, not as facts.

  1. Base conversion: write place values, multiply and add.
  2. Code tracing: keep a table with one column per variable and one row per iteration.
  3. Boolean evaluation: reduce one operator at a time, writing the intermediate result.

Every one of these has a visible working, which is why these questions reward method more than insight. Do the working on paper even when the answer feels obvious.

The Actual Detail

Number systems. Binary is base 2, octal base 8, decimal base 10, hexadecimal base 16. The place values are powers of the base, starting at the right with the base to the power zero.

BinaryPlace valuesDecimal
10118 + 0 + 2 + 111
11118 + 4 + 2 + 115
1000000027128

Hexadecimal covers exactly four binary bits per digit, which is why it is everywhere in computing: 0 to 9 then A to F, where A is 10 and F is 15. So FF is 15 × 16 + 15, which is 255, the largest value in one byte.

Converting decimal to binary means repeated division by two, reading the remainders upwards. Converting back means adding the place values where a 1 appears.

Data and storage units. A bit is one binary digit, a byte is 8 bits, a kilobyte is 1024 bytes, a megabyte is 1024 kilobytes, and so on in powers of 1024. A byte can hold 256 distinct values, so it represents unsigned numbers from 0 to 255, or signed numbers from −128 to 127 in the usual twos-complement convention.

Control flow and tracing. A for loop repeats a known number of times; a while loop repeats while a condition holds and can run forever if the condition never changes. To trace either, tabulate the variables after each iteration rather than trying to follow the whole run in your head — off-by-one errors and accumulated sums are exactly what the table exposes.

sum = 0
for i = 1 to 4:
    sum = sum + i

After i = 1 the sum is 1, after 2 it is 3, after 3 it is 6, and after 4 it is 10. The final value is 10, not 4 × something and not 1 + 2 + 3 + 4 + 4.

Arrays and indexing. Most languages number array elements from zero, so the first element is at index 0 and the last of an array of size n is at index n − 1. Many exam questions are built entirely on this convention.

Boolean logic. AND is true only when both inputs are true, OR is true when at least one is, and NOT inverts. Since AND binds more tightly than OR, the expression A OR B AND C groups as A OR (B AND C). Where the question uses brackets, evaluate inside first.

Algorithm basics. Linear search checks elements one by one and needs up to n comparisons; binary search on sorted data halves the range each time and needs about log₂(n) steps, so a thousand items take roughly ten comparisons instead of a thousand. Bubble sort and insertion sort are simple but slow on large inputs, while merge sort is faster because it divides the work. Questions at this level ask for the number of steps or for which algorithm is appropriate, not for proofs.

Watch for the off-by-one trap. "Repeats 1 to n" includes both ends and runs n times; "i < n" starting from 0 runs n times; "i <= n" starting from 0 runs n + 1 times. Write the first two iterations before you commit to an answer.

A Real Example

Trace the loop: total = 0; for i = 1 to 4; total = total + (i × i); print total.

Rather than following the code in your head, build the table.

ii × itotal after
111
245
3914
41630

The answer is 30, the sum of the first four squares. The table is the method: each row depends only on the row above, so a mistake is located immediately rather than discovered at the end when no option matches.

Notice also what the table protects against. The two common wrong answers are 16, from reading only the final value of i × i, and 10, from summing the values of i instead of their squares. Both come from losing track mid-trace, which a table makes impossible.

Try It

What is the binary number 1101 in decimal?

What is the hexadecimal number 2A in decimal?

An array has 10 elements and is indexed from 0. Which index holds the last element?

Check Your Understanding

Without looking back: how many distinct values can one byte hold, and why do programmers use hexadecimal at all?

The answer is: 256 values, from 0 to 255 unsigned; and because each hexadecimal digit maps exactly onto four binary bits, so it writes binary compactly without ambiguity.

Fill in the blanks from memory:

Binary is base , and hexadecimal is base . One byte contains bits. In a zero-based array of size n, the last valid index is n minus .

Apply It

Write out ten conversions by hand, five binary to decimal and five decimal to binary, then the same for hexadecimal. Time yourself on the second set.

Drills that cover the likely questions

Convert 1011, 11001, 11111111, 100101 and 10101010 to decimal. Convert 9, 21, 64, 100 and 200 to binary, by repeated division by two.

Then convert FF, 1A, 80 and C7 to decimal, and check each against its binary form: C7 is 1100 0111, which is 199. Working in both directions cements the relationship between four bits and one hexadecimal digit, and that relationship is what most questions in this area actually test.

Finally, trace the sum loop from this lesson but with a twist: start the total at 10 and loop i from 2 to 5 adding i × i. Build the table first, then compare your result with a direct addition. If the two agree, your tracing procedure is reliable; if they disagree, the table shows you where it went wrong, which is the entire reason for the table.

Connect

Computing fundamentals and digital logic overlap more than candidates expect. Gates are the physical layer beneath everything in this lesson, and the final concept covers them along with the small set of standard results that most questions in that area reuse.