hanegreefs.com/Business Information SystemsBIS
Home › Worked problems

Worked problems

Problems written for this site in the style of the exam and the exercise sessions, with numbers wherever a calculation exists.

Quick reference

ProblemTopicUnitsMain exam skill
1Which byte is the letter?L4convert between binary, decimal and ASCII
2While or Repeat: how often does it run?L3, P2trace a loop and count its rounds
3Predict the output of a Python programP3, P5trace lists, functions and errors exactly
4The grade converter as a functionP2, P4turn a selection into a function with return and test it
5Critical path of a video projectL6compute earliest and latest dates, slack and the critical path
6Cost of a task with three resource typesL6cost work, material and cost resources
7From class diagram to tablesL7map associations with foreign keys and junction tables
8Advanced filter criteriaL7combine AND and OR in a criteria range
9Network links and Moore's lawL8count links per topology and compute exponential growth
10Is the ERP project worth it?L9compute payback and ROI and discuss implementation risk
11A web shop's burn rateL10compute monthly result, runway and break-even conversion
12Password policy and cloud costL11compute password combinations and compare cloud with own hardware

Problem 1: Which byte is the letter?

Bits, bytes and ASCII · Related: Lecture 4

The problem

An exam question shows four bytes, 01000111, 01001010, 01000101 and 01001001, and asks which one stands for the capital letter J. You know that A is 65 in ASCII and the capitals follow in alphabetical order.

Method

  1. Find the decimal value of the target character: count from A = 65.
  2. Convert each byte: add the position values 128, 64, 32, 16, 8, 4, 2, 1 where the bit is 1.
  3. Compare; check the answer by converting it back.
Worked example

Find J

J is the tenth letter, so J = 65 + 9 = 74.

1

01000111

64 + 4 + 2 + 1 = 71 = G
2

01001010

64 + 8 + 2 = 74 = J
3

01000101

64 + 4 + 1 = 69 = E
4

01001001

64 + 8 + 1 = 73 = I
Answer

The answer is 01001010. Small letters start at 97 (a), so j would be 106 = 01101010: only the bit worth 32 differs.

Think further

  • Every capital letter starts with 010 (64 + a number up to 26).
  • The bit worth 32 switches between capital and small letter.
  • A byte holds 0 to 255, so 8 bits are enough for all ASCII characters.
Common trapRead the bits from the right: the rightmost bit is worth 1, the leftmost 128.
Try it

Practice question

Which character is 01010011? And what is the byte of the digit 7, knowing that the digit 0 is 48 in ASCII?

Show the answer
  • 64 + 16 + 2 + 1 = 83 = S.
  • Digit 7 = 48 + 7 = 55 = 32 + 16 + 4 + 2 + 1 = 00110111.

Problem 2: While or Repeat: how often does it run?

Tracing algorithms · Related: Lecture 3, Python 2

The problem

Two algorithms start with X = 10. Algorithm 1: While X < 10 do Write X; X ← X + 3 EndDo. Algorithm 2: Repeat Write X; X ← X + 3 Until X >= 10. Then both are run again with X = 4. What does each write?

Method

  1. For While, test the condition before each round; for Repeat, run the body first and test after.
  2. Keep a table with the value of X and the output per round.
  3. Stop the moment the stop condition holds: While stops when the condition is False, Repeat when it is True.
Worked example

Start values 10 and 4

Trace each case.

1

X = 10, While

10 < 10 is False: nothing is written
2

X = 10, Repeat

writes 10, X = 13, 13 >= 10 is True: stops after one round
3

X = 4, While

writes 4, 7; X becomes 10 and the loop stops
4

X = 4, Repeat

writes 4, X = 7, not yet; writes 7, X = 10, stop
Answer

With 10 the loops differ (no output versus 10); with 4 both write 4 and 7. A Repeat loop always runs at least once.

Think further

  • In Python the While version is a while loop; the Repeat version is while True with a break at the end.
  • Equivalent loops must give the same output for every start value, including the edge cases.
Common trapRepeat stops when the condition becomes True, While when it becomes False: the conditions are each other's opposite.
Try it

Practice question

Rewrite algorithm 2 in Python so that it behaves exactly like the Repeat loop, and give the output for X = 9.

Show the answer
  • x = 9; while True: print(x); x += 3; if x >= 10: break
  • Output: 9 (then x = 12 and the loop stops).

Problem 3: Predict the output of a Python program

Reading code · Related: Python 3, Python 5

The problem

Predict what this program prints: def f(lst): / lst.append(len(lst)) / return lst[-1] * 2; then data = [5, 3], x = f(data), print(x, data), print(f(data) + f([])), print(data[4]).

Method

  1. Trace the list: functions that append change the caller's list.
  2. Evaluate every call in order, left to right.
  3. Check every index against the current length.
Worked example

Step by step

data starts as [5, 3].

1

x = f(data)

appends len 2: data = [5, 3, 2]; returns 2 × 2 = 4
2

print(x, data)

4 [5, 3, 2]
3

f(data)

appends 3: data = [5, 3, 2, 3]; returns 6
4

f([])

appends 0 to a new list; returns 0; sum 6 + 0 = 6
5

print(data[4])

data has 4 elements (indexes 0 to 3): IndexError
Answer

Output: 4 [5, 3, 2], then 6, then the program stops with an IndexError.

Think further

  • The list is shared with the function (side effect), the number is not.
  • Output before an error is still printed.
Common trapDo not forget that the first call already changed data before the second print.
Try it

Practice question

What would print(x, data) show if f started with lst = lst + [len(lst)] instead of append?

Show the answer
  • lst + [...] builds a new list, so data stays [5, 3].
  • x is still 4: output 4 [5, 3].

Problem 4: The grade converter as a function

Writing Python · Related: Python 2, Python 4

The problem

Write a function grade(mark) that returns "F" below 60, "D" below 70, "C" below 80, "B" below 90, "A" up to 100, and "Error" for a mark above 100 or below 0. Then read a mark, call the function and print "The grade = ..." .

Method

  1. Handle invalid input first.
  2. Use an if and elif chain from low to high; the first True branch wins.
  3. Return the letter; print only in the main program.
  4. Test each boundary: -1, 0, 59, 60, 89, 90, 100, 101.
Worked example

A solution and its tests

One possible solution.

1

Guard

if mark < 0 or mark > 100: return "Error"
2

Chain

if mark < 60: return "F" / elif mark < 70: return "D" / elif mark < 80: return "C" / elif mark < 90: return "B" / else: return "A"
3

Main program

m = int(input("Mark: ")); print("The grade =", grade(m))
4

Tests

59 F, 60 D, 89 B, 90 A, 100 A, 101 Error, -1 Error
Answer

Return makes the function testable; the main program only reads and prints.

Think further

  • The order of the elif tests matters: testing mark < 90 first would give B for 55.
  • This is exercise f3 of the coding lab in Python 2.
Common trapWriting print inside the function and then print(grade(m)) shows the letter and then None.
Try it

Practice question

Change the function so that it also accepts marks with decimals and rounds them to the nearest whole number first. Which test value shows the difference?

Show the answer
  • Start with mark = round(mark).
  • Test 59.6: rounds to 60, so D instead of F.

Problem 5: Critical path of a video project

Project management · Related: Lecture 6

The problem

Tasks: A script 5 days; B production boards 3 days after A; C pick locations 2 days after A; D auditions 2 days after C; E rehearse 2 days after B and D; F shoot video 2 days after E; G log footage 1 day after F. All links are finish-to-start.

Method

  1. Forward pass: earliest finish = earliest start + duration; a task starts at the latest finish of its predecessors.
  2. Backward pass from the project end: latest finish = the earliest latest start of the successors.
  3. Slack = latest finish − earliest finish; tasks with zero slack form the critical path.
Worked example

Forward and backward

Durations in working days.

1

Forward

A 0 to 5; B 5 to 8; C 5 to 7; D 7 to 9; E max(8, 9) = 9 to 11; F 11 to 13; G 13 to 14
2

Backward

G 14; F 13; E 11; B and D must end by 9; C by 7; A by 5
3

Slack

B: 9 − 8 = 1 day; all others 0
Answer

Project length 14 working days; critical path A, C, D, E, F, G. If B slips 1 day nothing changes; if it slips 2 days the project ends a day later.

Think further

  • Adding a milestone "pre-production complete" of 0 days after B and D changes nothing in the length.
  • Extra people on a critical task can shorten the project only if the work can be shared.
Common trapThe start of E depends on the LATEST of its predecessors, not the earliest.
Try it

Practice question

Auditions (D) take 4 days instead of 2. What is the new project length and the new slack of B?

Show the answer
  • C ends 7, D ends 11, E starts 11.
  • Length 16 days; B can end by 11, earliest 8: slack 3 days.

Problem 6: Cost of a task with three resource types

Project management · Related: Lecture 6

The problem

Hold auditions lasts 2 days of 8 hours. Assigned: a director at 22.00 per hour, an assistant at 800.00 per week (40 hours), 3 video tapes at 5.00 each and a catering cost of 250. The director works full time, the assistant at 50%.

Method

  1. Work resources: hours on the task × hourly rate; convert weekly or daily rates first.
  2. Units below 100% reduce the hours worked.
  3. Material: quantity × unit price. Cost resource: the amount itself.
  4. Add everything.
Worked example

Total cost

Step by step.

1

Director

16 h × 22.00 = 352.00
2

Assistant

800 / 40 = 20.00 per hour; 50% of 16 h = 8 h; 8 × 20.00 = 160.00
3

Tapes

3 × 5.00 = 15.00
4

Catering

250.00
Answer

Total = 352 + 160 + 15 + 250 = 777.00.

Think further

  • If the assistant worked 100% while keeping the duration constant, the cost would rise to 320.
  • Cost resources do not depend on duration or units.
Common trapA weekly rate is not a daily rate: divide by 40 hours, not by 5.
Try it

Practice question

The task is extended to 3 days with the same assignments. What is the new total?

Show the answer
  • Director 24 h × 22 = 528.
  • Assistant 12 h × 20 = 240.
  • Tapes 15, catering 250: total 1,033.

Problem 7: From class diagram to tables

Databases · Related: Lecture 7

The problem

A training company has Trainer, Course and Participant. Each course has exactly one trainer, a trainer gives many courses. A participant can follow many courses and a course has many participants; for each participation the company stores the score.

Method

  1. One table per class with a primary key.
  2. Association with multiplicity 1 on one side: foreign key in the table on the other side.
  3. Many-to-many: extra table with both foreign keys; association class attributes go there.
  4. Check 1NF: one value per cell.
Worked example

The tables

Primary keys underlined in words, foreign keys marked FK.

1

Trainer

Trainer(trainerID, name, email)
2

Course

Course(courseID, title, date, trainerID FK)
3

Participant

Participant(participantID, name, company)
4

Participation

Participation(participantID FK, courseID FK, score), key = both foreign keys
Answer

Four tables: the many-to-many association with its score becomes the table Participation.

Think further

  • A column "courses" with a list in Participant would break 1NF.
  • If a participant may take the same course twice, add a date to the key or use a surrogate key.
Common trapThe foreign key goes on the "many" side: Course gets trainerID, not Trainer a list of courses.
Try it

Practice question

Add Location: every course takes place at one location, a location hosts many courses. Which table changes?

Show the answer
  • New table Location(locationID, address).
  • Course gets locationID as foreign key.

Problem 8: Advanced filter criteria

Spreadsheet databases · Related: Lecture 7

The problem

A customer list has the fields City, Segment and Revenue. You want all Brussels customers in segment B2B with revenue above 10,000, plus every customer in Ghent regardless of segment or revenue.

Method

  1. Copy the field names above the criteria range.
  2. Conditions that must hold together go on the same row (AND).
  3. Alternatives go on separate rows (OR).
  4. Leave a cell empty when a field does not matter in that row.
Worked example

The criteria range

Fields City, Segment, Revenue.

1

Row 1

Brussels | B2B | >10000
2

Row 2

Ghent | (empty) | (empty)
3

Effect

a record is shown if it matches row 1 completely, or row 2
Answer

Two criteria rows. Try the same filter in the advanced filter lab.

Think further

  • An AutoFilter can combine columns only with AND; the advanced filter handles OR between rows.
  • The result can be copied to another place and duplicates can be removed.
Common trapPutting Brussels and Ghent in the same row asks for customers in both cities at once: no result.
Try it

Practice question

Write the criteria range for customers with revenue between 5,000 and 20,000 in any city.

Show the answer
  • Use the Revenue field twice in the header.
  • One row: >=5000 and <=20000 under the two Revenue columns.

Problem 9: Network links and Moore's law

IT in business · Related: Lecture 8

The problem

A company with 12 branches compares a fully connected network with a star around its head office (one of the 12). Its IT manager also expects the number of transistors per chip to grow with Moore's law over the next 8 years.

Method

  1. Fully connected: n(n − 1) / 2 links.
  2. Star with the centre among the n nodes: n − 1 links.
  3. Moore: factor 2years / 2.
Worked example

Links and growth

n = 12, 8 years.

1

Fully connected

12 × 11 / 2 = 66 links
2

Star

12 − 1 = 11 links
3

Moore

28 / 2 = 24 = 16 times as many transistors
Answer

66 versus 11 links; 16 times more transistors after 8 years.

Think further

  • The star is cheap but the head office is a single point of failure.
  • A mesh between the largest branches is a middle way.
Common trapn(n − 1) / 2, not n2: each link connects two nodes and is counted once.
Try it

Practice question

How many extra links does a fully connected network need when a 13th branch joins? And with the 18-month variant of Moore, what is the factor after 6 years?

Show the answer
  • 13 × 12 / 2 = 78, so 12 extra links (one to every existing branch).
  • 26 / 1.5 = 24 = 16.

Problem 10: Is the ERP project worth it?

Enterprise applications · Related: Lecture 9

The problem

A wholesaler can implement ERP for 450,000 euro. Expected savings: 120,000 a year from lower inventory and 60,000 a year in administration. Licences and support cost 30,000 a year. The system should last 6 years.

Method

  1. Net yearly benefit = savings − running costs.
  2. Payback = investment / net yearly benefit.
  3. ROI over the life time = (total net benefit − investment) / investment.
  4. Discuss what happens if the implementation fails (the lecture's failure rates).
Worked example

Payback and ROI

Amounts in euro.

1

Net yearly benefit

120,000 + 60,000 − 30,000 = 150,000
2

Payback

450,000 / 150,000 = 3 years
3

ROI over 6 years

(6 × 150,000 − 450,000) / 450,000 = 100%
Answer

Payback in 3 years and an ROI of 100% over 6 years, on paper.

Think further

  • If the inventory savings appear only half, the net benefit falls to 90,000 and payback to 5 years.
  • With 60 to 80% of ERP projects failing on ROI, the business case needs top management support, training and clean data migration.
Common trapDo not forget the yearly running costs: payback on gross savings looks a year shorter than it is.
Try it

Practice question

How large must the yearly savings be for payback within 2.5 years?

Show the answer
  • Net benefit needed: 450,000 / 2.5 = 180,000.
  • Savings = 180,000 + 30,000 = 210,000 a year.

Problem 11: A web shop's burn rate

New business models · Related: Lecture 10

The problem

A new fashion web shop has 20 million euro in the bank and costs of 2.5 million a month. It gets 2 million visitors a month, 0.5% of them order, the average order is 120 euro and the gross margin is 45%.

Method

  1. Orders = visitors × conversion rate.
  2. Gross profit = orders × order value × margin.
  3. Monthly result = gross profit − costs; runway = cash / monthly loss.
  4. Break-even conversion = costs / (visitors × order value × margin).
Worked example

The numbers

Per month.

1

Orders

2,000,000 × 0.5% = 10,000
2

Gross profit

10,000 × 120 × 45% = 540,000
3

Monthly loss

2,500,000 − 540,000 = 1,960,000
4

Runway

20,000,000 / 1,960,000 = about 10.2 months
5

Break-even conversion

2,500,000 / (2,000,000 × 120 × 0.45) = about 2.3%
Answer

The shop loses almost 2 million a month and has about 10 months; it needs about 2.3% conversion to break even.

Think further

  • This is the Boo.com trap: costs built for a global scale before customers arrive.
  • Levers: lower costs, more visitors, better conversion (a site that works on every device), higher margin.
Common trapThe conversion rate is a percentage: 0.5% is 0.005, not 0.5.
Try it

Practice question

The shop cuts costs to 1.5 million a month. What are the new runway and the break-even conversion?

Show the answer
  • Loss = 1,500,000 − 540,000 = 960,000; runway = 20.8 months.
  • Break-even = 1,500,000 / 108,000,000 = about 1.4%.

Problem 12: Password policy and cloud cost

Current trends · Related: Lecture 11

The problem

An office wants a password rule and a new server. Option 1: 8 characters from letters and digits (62 characters). Option 2: 12 lowercase letters. An attacker tries 100 billion guesses a second. For the server: buy one for 9,000 euro plus 1,800 a year maintenance, or rent cloud capacity for 400 euro a month.

Method

  1. Combinations = characterslength; time = combinations / guesses per second.
  2. Own server cost after m months = purchase + maintenance × m / 12.
  3. Cloud cost after m months = fee × m; break-even where both are equal.
Worked example

Passwords and costs

Step by step.

1

Option 1

628 = about 2.18 × 1014: about 36 minutes
2

Option 2

2612 = about 9.54 × 1016: about 11 days
3

Break-even

9,000 + 150 m = 400 m, so m = 36 months
Answer

The longer lowercase password is more than 400 times stronger here. Own server and cloud cost the same after 36 months (14,400 euro each).

Think further

  • Real attacks also use dictionaries, so a long passphrase of unrelated words beats a short complex password.
  • The cloud is cheaper the first three years and scales; the own server keeps data in house.
Common trapEach extra character multiplies the combinations; it does not add to them.
Try it

Practice question

How long would the attacker need for 10 characters from 94 symbols? After how many months is the cloud more expensive if the fee rises to 500 a month?

Show the answer
  • 9410 = about 5.4 × 1019: about 17 years.
  • 9,000 + 150 m = 500 m: m = about 25.7, so from month 26.