exam4

# exam4 - [WPI] [cs2223] [cs2223 text] [News] [Syllabus]...

This preview shows pages 1–2. Sign up to view the full content.

[WPI] [cs2223] [cs2223 text] [News] [Syllabus] [Exams] cs2223, D97/98 Exam 4 Go to Solution Question 4.1 Laser printers produce gray by printing random patterns of white and black dots. Here are two algorithms for painting a digital picture (matrix of chars) gray. Assume both start with the picture all white, which means all array values are initialized to zero. char picture[480][640]; // global variable void gray1(int xmax, int ymax) { for (int y = 0; y < ymax; y++) for (int x = 0; x < xmax; x++) if (rand()%2) picture[y][x] = 1; // black } void gray2(int xmax, int ymax) { for (int n = 0; n < xmax*ymax/2; n++) { int x = rand() % xmax; int y = rand() % ymax; picture[y][x] = 1; // black } } Compare these algorithms and tell which you would choose and why. Compare the order of the algorithms, the average level of gray produced, the uniformity with which the black dots are distributed, and others criteria you think important. Question 4.2

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/10/2009 for the course CS 2223 taught by Professor Ruiz during the Fall '05 term at WPI.

### Page1 / 2

exam4 - [WPI] [cs2223] [cs2223 text] [News] [Syllabus]...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online