|Public Scratchpad||Download, Select Code To D/L|
1. This is a problem because although efficient on short arrays, it does not scale (i.e. O(n-squared) type algorithm). Better to sort the arrays (or copies of the arrays) first (assuming sortable elements), then you can simply hopscotch along them both comparing elements, and shuttling matches to a new array. Depends on arrays being sorted efficiently.2.
3. Request manager gets request, asks translator for standard query form, gives that to DB interface, gives result to output translator. As much as possible the input/output handlers are subclasses of main input and output superclasses . Request manager sets up a queue (FIFO) of requests, each one containing it's own "blackboard" space to be used at will by each of the components. Of course, if the database is a bottleneck, it might be wise to do I/O with one program/thread and queue them to the db program/thread so that request fetching/output is not blocked by this step. Of course output is still throttled by the db, but assuming variable input rate, it should "catch up" during slow request times.#!/usr/bin/ruby -w class Array def my_reverse tmp = self.dup #function is destructive new =  while tmp.size > 0 new.push( tmp.pop ) end return new end end a = ['foo', 'bar', 'baz', 'cheeze whiz'] puts a.my_reverse