a) Can a printer, printing 40 characters per second, keep up with a string of ASCII characters (one byte per symbol) arriving serially at the rate of 300 bps?
1 Bytes = 1 symbol
The number of bits per character is usually 10 thus using 10 bits per word.
Therefore 300 bytes per second = 30 characters per second
So if a printer is printing 40 characters per second and the string of ASCII characters is 30 characters per second according to the above explanation, then the printer can keep up with that number.
What about 1200 bps?
1200 bytes per second implies 120 characters per second
The speed of the printer is far much lower than this and therefore it will not be able to cope up with this stream of data. The printer which can handle this stream of data should be operating at a speed of 120 characters per second or more.
b) Select a subject with which you are familiar and design a pseudo code for giving directions in that subject. In particular, describe the primitives you would use and the syntax you would use to represent them?
Mathematics
Dividing numbers
If value b is 0
- checking the value of b which is the denominator.
Print “you cannot divide by 0”
- Prints this information if the above condition is met
Else print “a/b”
- If the above condition is not met then division is done and the results written.
c) Four prospectors with only one lantern must walk through a mine shaft. At most, two prospectors can travel together and any prospector in the shaft must be with lantern. The prospectors, named Andrews, Blake, Johnson, and Kelly, can walk through the shaft in one minute, two minutes, four minutes, and eight minutes, respectively. When two walk together they travel at the speed of the slower prospector. How can all four prospectors get through the mine shaft in only 15 minutes?
Andrews - 1
Blake - 2
Johnson - 4
Kelly – 8
2 min + 1 min + 4 min + 1 min + 8min
First trip takes 2 min (Andrews and Blake)
Andrews returns 1 min
Second trip takes 8 min (Andrews and Kelly)
Andrews returns 1 min
Third trip takes 4 mins (Andrews and Johnson)
d) Create an algorithm (in English) for the JPEG compression standard (depending on lossless and lossy) Remember than an algorithm is effective, detailed, and unambiguous. An algorithm explains “how” to do something. Just stating “compress” is not an algorithm as it doesn’t explain how.
Algorithm for compression
Reduce the number of bits per sample – breaking the image into 8x8 pixel group
Pass the signal through Fourier or any other transform
Calculate the Spectrum using DCT
Sum the products of the spectral value
End
Note the DCT is better than the Fourier Transform because it has one half cycle basis function.
References
Bailey T.E. (1981) Program design with pseudo code. Kendal Publishers.