Comp210
Due: 97.Feb.18 (Wed.) in class
Here is the informal description of the inputs that your programs will process.
A circuit segment can be either a resistor, a serial segment, or a parallel segment.
A (simple) resistor has only one interesting property: a resistance, which is a real number, greater or equal to 0.0, or the symbol 'infinity.
A serial segment consists of an arbitrary number of segments
connected in a row:
(see postscript for picture).
The total resistance of a serial segment is the sum of the individual
resistances. In other words, the entire segment behaves like a single
resistor with that total resistance:
Rseg = Sumi=1n (Ri)
If one of the segments in the series has infinite resistance, then
Rseg = 'infinity
A parallel segment consists of an arbitrary number of segments that
are connected to a common starting and ending point
(see postscript for picture).
The total resistance of a parallel segment is the inverted sum of the
inverted resistances of the segments:
Rseg = 1 / Sumi=1n (1/Ri)
If one of the segments has no resistance, then the total resistance is just
0; if one of the segments has infinite resistance, that segment
contributes nothing to the sum of inverses.
If all of the segments have infinite resistance, i.e., the sum above
is 0, then the whole parallel segment has inifinite resistance.
(list 2 5 8 3 9 7 1)
yields output
(list (list 2) (list 5) (list 8) (list 3) (list 9) (list 7) (list 1))
.
(mergesort (list 2 3 5 8) (list 1 7 9)) = (list 1 2 3 5 7 8 9)
.
(list (list 2 5) (list 3 8) (list 7 9) (list 1))
yields output
(list (list 2 3 5 8) (list 1 7 9))
.
(list 8.7 +0.2 +0.5 +13.4)
yields the output
(list 8.7 8.9 9.4 22.7)
.