Read chapter 4 of the book Blown To Bits, pages 109-137. (Feel free to read the whole chapter if the material interests you.)
Suppose that Alice simulates the roll of a pair of dice by defining the roll function below, calling it twice:
def roll() return rand(6) + 1 endBob realizes that the roll of a pair of dice results in a sum of 2 through 12, inclusive, so he simulates the roll of a pair of dice by defining the roll function below, calling it only once:
def roll() return rand(11) + 2 end
Are these equivalent in terms of their behavior over time as we generate roll after roll? Why or why not?
(http://en.wikipedia.org/wiki/File:Kernel_Layout.svg)
Based on the diagram, what role does the kernel play? Be specific. (HINT: Each arrow indicates that a specific layer communicates with the layer above or below it to request or receive something.)
[ [ [255,0,0] , [0,255,0] ],[ [0,0,255] , [255,255,255] ],[ [0,0,0] , [0,0,0] ] ]
We can remove the red components of an image using the following function in Ruby:
def remove_red(image) num_rows = image.length num_columns = image[0].length for row in 0..num_rows-1 do for column in 0..num_columns-1 do green = image[row][column][1] blue = image[row][column][2] image[row][column] = [0, green, blue] end end return nil end
It is possible to accelerate the performance for the remove_red function by modifying it to perform the work on the different pixels concurrently instead of following the ordering given by the loops. Could the same be done for the problem of implementing a function that returns an array of n pseudorandom numbers generated using a linear congruential generator? Why or why not?
1. Write a personal message to the faculty member on the inside of a card (10 minutes). 2. Hand draw a scene with the club logo on the cover of the card with colored pencils. (15 minutes) 3. Cut out and form a special envelope for the card out of a sheet of premium paper. (3 minutes) 4. Seal the card in the envelope with glue, look up and write the address of the faculty member, and put a stamp on the card. (2 minutes)
Assume each comparator (i.e. the circles) takes time t to compare its two elements and output its results and that the time for a data value to go from one comparator to the next negligible. We wish to sort 1000 sets of 6 integers each.