CS 1401, Quiz #1

Date: Tuesday, January 24, 2006
Class section (9 am or 10:30 am): ______________________
Name: ______________________________________________________________________
1. Explain why the invention of 0 made computations easier. (Hint: how were numbers represented before that? was it easy to add or subtract these numbers?). Who was the first to invent 0?


Zero was first invented in India. Before the invention of 0, people
used Roman numbers. For example, 2006 would be represented as MMVI,
where M stands for thousands, V for five, and I for one. The problem
with this representation is that arithmetic operations are very difficult.
For example, subtracting 19 from 2006 means subtracting XIX from MMVI.
Before the invention of 0, it was not possible to use the same digits
for one, tens, etc., because there was no easy way to distinguish between
26 (XXVI) and 2006 (MMVI). With 0, it became possible, notations
simplified, and computations became much easier.

2. Describe, step by step, an algorithm that, given three real numbers a, b, and c, returns the values x for which a*x-b=c.


Let us first move b to the other side of the equation, we get
a*x=c+b. This leads to the following algorithm:

* First check whether a = 0.

* If a =/= 0, then compute and return the value x = (c + b)/a

* If a = 0, then check whether c + b = 0.

  * If c + b = 0, then every real number x is a solution

  * If c + b =/= 0, then the original equation has no solutions.