Software Developer calculations with worked answers
Developers do not spend their days on arithmetic, but a few calculations explain why some code is fast and some slow, and how computers store data. Knowing how many comparisons a binary search needs, or reading a hexadecimal value in a debugger, makes you a sharper programmer and helps with test questions on efficiency and data representation. Every example below was generated for this page and checked by separate code.
How this guide was made
Written for this site with AI assistance, then checked automatically before publishing. The topic table, sample questions, worked examples and study plan are generated from this site’s question bank: each worked example is recalculated by separate code, and each sample answer says where it came from.
The guide deliberately states no salaries, grades, pass marks or exam dates. Those change, and they could not be checked here, so take them from the advert itself.
This site is independent and is not affiliated with MIFOTRA or any employer.
Worked examples
Try each one on paper first. Every figure is generated and then recalculated by separate code before it is published.
Worst-case comparisons in a binary search
A sorted array holds 10000 records. In the worst case, how many comparisons does a binary search need, and how many would a linear search need?
Show the working
- Each binary-search comparison halves what is left, so the worst case is ⌊log₂ n⌋ + 1 comparisons.
- log₂(10000) ≈ 13.29, so ⌊13.29⌋ + 1 = 14
- A linear search may have to check every record: 10000 comparisons. That gap is what O(log n) versus O(n) means in practice.
Answer: 14 comparisons (binary) versus 10000 (linear)
Converting hexadecimal to decimal and binary
Convert 0x2FB7 to decimal and to binary.
Show the working
- Expand by place value: 2×16^3 + F×16^2 + B×16^1 + 7×16^0
- = 8192 + 3840 + 176 + 7 = 12215
- For binary, write each hex digit as four bits: 0010 1111 1011 0111
Answer: 12215 decimal, 0010 1111 1011 0111 binary
Converting an octet from decimal to binary
Convert 244 to an 8-bit binary octet.
Show the working
- Subtract the largest place value that fits, mark a 1, and repeat: 128 64 32 16 8 4 2 1.
- 244 = 128 + 64 + 32 + 16 + 4
- Mark those places with 1 and the rest with 0: 11110100
Answer: 11110100
Worst-case comparisons in a binary search
A sorted array holds 100000 records. In the worst case, how many comparisons does a binary search need, and how many would a linear search need?
Show the working
- Each binary-search comparison halves what is left, so the worst case is ⌊log₂ n⌋ + 1 comparisons.
- log₂(100000) ≈ 16.61, so ⌊16.61⌋ + 1 = 17
- A linear search may have to check every record: 100000 comparisons. That gap is what O(log n) versus O(n) means in practice.
Answer: 17 comparisons (binary) versus 100000 (linear)
Converting hexadecimal to decimal and binary
Convert 0x5ED5 to decimal and to binary.
Show the working
- Expand by place value: 5×16^3 + E×16^2 + D×16^1 + 5×16^0
- = 20480 + 3584 + 208 + 5 = 24277
- For binary, write each hex digit as four bits: 0101 1110 1101 0101
Answer: 24277 decimal, 0101 1110 1101 0101 binary
Converting an octet from binary to decimal
Convert the binary octet 11011100 to decimal.
Show the working
- Write the place values under each bit: 128 64 32 16 8 4 2 1.
- Add the place values where the bit is 1: 128 + 64 + 16 + 8 + 4
- = 220
Answer: 220
Worst-case comparisons in a binary search
A sorted array holds 1000000 records. In the worst case, how many comparisons does a binary search need, and how many would a linear search need?
Show the working
- Each binary-search comparison halves what is left, so the worst case is ⌊log₂ n⌋ + 1 comparisons.
- log₂(1000000) ≈ 19.93, so ⌊19.93⌋ + 1 = 20
- A linear search may have to check every record: 1000000 comparisons. That gap is what O(log n) versus O(n) means in practice.
Answer: 20 comparisons (binary) versus 1000000 (linear)
Converting hexadecimal to decimal and binary
Convert 0xAB49 to decimal and to binary.
Show the working
- Expand by place value: A×16^3 + B×16^2 + 4×16^1 + 9×16^0
- = 40960 + 2816 + 64 + 9 = 43849
- For binary, write each hex digit as four bits: 1010 1011 0100 1001
Answer: 43849 decimal, 1010 1011 0100 1001 binary
Why these calculations matter to developers
Binary search steps show concretely what O(log n) means: a million sorted records need only about twenty comparisons, while a linear search may need a million. That difference decides whether an application stays fast as its data grows. Hexadecimal appears in colour codes, memory addresses, character encodings and hashes. Binary underlies bit flags, permissions and how integers are stored.
Using the results in design decisions
Efficiency estimates help you choose between approaches before writing code. If a feature searches a list on every request, estimate how large the list could become and how many comparisons that means. When the numbers grow quickly, a sorted structure, an index or a hash map is worth the extra effort.
Common questions
Why is binary search faster than linear search?
Each comparison halves the remaining search space, so the number of steps grows with the logarithm of the list size rather than with the size itself. It does require the data to be sorted first.
Why do programmers use hexadecimal?
Each hexadecimal digit stands for exactly four bits, so long binary values become short and readable. Colours, memory addresses and hash values are commonly written in hexadecimal for that reason.
More Software Developer guides
- Software Developer exam: what is tested and how to prepare
- Software Developer practice questions with answers
- Software Developer interview questions and answers
- 30-day Software Developer exam study plan
- Software Developer skills and qualifications
- Software Developer job description and duties
- How to become a Software Developer in Rwanda
- Software Developer exam mistakes to avoid
- Software Developer key topics and quick reference
- Software Developer CV: what to include
- Certifications worth getting as a Software Developer