FUNCTION: findlitfic (Array books)

@author Millie Niss
@version 1.0
@param array, books containing pointers to all "fiction" and/or "literature" books in the store, in the order in which they are shelved
@return the index, i, in books where a good book is located or -1 if none exists in the store
/**
 *
* *
*
*
*
*/

guaranteed to terminate because array is finite

some good books are eliminated to avoid risk of choosing a trashy book

we do not modify the array that is passed in

method applies only to paperbacks (soft cover books issued after a more expensive edition) 


Algorithm:

Let val be an integer which will be the return value.  val will contain the index of the first good book or -1 if there is no good book in the store.  

Initialize val by setting it to -1.

Initialize length by setting it to the number of books in the store.

Make a new array called isgood of length length. Set isgood[i] = true for i in the range
[0, ... length - 1]. 

Loop through i in [0, ... , length - 1].

For each element, books[i], set isgood[i] to false if books[i] satisfies any of the "elimination criteria" listed below.  When you are done, go through the isgood array from the beginning and find the first position i where the value of isgood[i] is (still) true.

Elimination Criteria
  1. book's title indicates that I have already read the book
  2. book is a mass paperback printed after 1985 ("Mass paperbacks" are the smaller, thicker kind of softcover which is printed on bad paper.  The larger kind on better paper are "trade paperbacks."  Random House's "Vintage International" line popularized the trade paperback for novels in the U.S.)
  3. the cover does not show bare breasts unless they are of a cup size less than or equal to those used on minor martyred saints in religious art during the Renaissance
  4. you know the author personally and they can't write their way out of a paper bag
  5. book is published by a publisher of trashy books or book is in a trashy line of a major commercial publisher
  6. price › $20
  7. book is part of a series
  8. the back cover uses a sans-serif font for the main text
  9. there is metallic-colored lettering anywhere on the cover
  10. the back cover text is in a font size greater than 18 point
  11. cover imagery uses pastel shades
  12. cover is textured so that letters are in bas-relief
  13. cover art contains a closeup photo headshot of one or two people
  14. cover art reproduces a painting by Michelangelo, Rembrandt, or Van Gogh
  15. the word "spiritual" is used anywhere on the back cover
  16. there are photos or drawings on more than 25% of the cover surface
  17. book is described as "a novel of X," e.g. War of the Roses: A Novel of Olde England
  18. a blurb is written by a famous author who has a reputation for blurbing absolutely anyone for the right price
  19. a blurb is written by someone who is an authority on an "issue" raised by the book rather than on literature
  20. there is any text in an "Old English" font
  21. cover image depicts futuristic scene using photorealism
  22. cover art includes a depiction of an item of female apparel or a cosmetic
  23. book is endorsed by a politician
  24. book is advertised as "based on" a film or video game
  25. main character is a member of royalty of a non-obscure country
  26. there is any mention of or allusion to the Kennedy family
  27. ditto neanderthals, unicorns, dragons, IT start-ups, Wall Street, 9/11 or any other historic terrorist act which took place after 1970, bears, Armani suits, sushi, yuppies, The White House, Woodstock
  28. setting described as "quaint" or "traditional"
  29. "neglected modern classic"
  30. plot based around a faddish kind of science (e.g. "Bumping Around All Together evokes the new science of Chaos to explain how simple rules can generate the complex behavior found in turbulent flows.")
  31. a word in the book's title is defined on the back cover
  32. author is known for his/her series of detective novels
  33. author uses La or Le in their last name as a separate particle (e.g. "Pyramid Tryst by Shelley Le Grand is a dazzling story of love in the City of Light.  Readers will moan along in the titllating climax in which the heroine makes torrid love with a resident of the blighted suburbs in the famous glass pyramid designed by I. M. Pei for the courtyard of the Louvre." )
  34. the word "erotic" is used anywhere on the cover (The word "sex" is ok as are obscene words with the same meaning, although these words do not improve the book's chances)
  35. brand names are mentioned repeatedly on the cover
  36. author's photo is equestrian

Exercises for the reader:

  1. Create an algorithm that captures your preferred method of finding summer beach reading.
  2. This algorithm resembles a well-known classical algorithm.  Name it and compare it with that algorithm.
  3. Make a set of elimination criteria for some other kind of book or for the same kind of book in another country.  Examples might be "contemporary poetry in Italy" or "computer books in Canada," etc.
  4. How do the time and space requirements for this algorithm vary as the number of books and/or the number of elimination criteria increases?  Use "big-oh" notation if you are familiar with it. 
  5. Research blurbs in "literary fiction" to come up with a list of eminent blurbers whose blurb discredits a book.
  6. Rewrite this algorithm using a more modern programming paradigm, for example functional programming, object-oriented programming, distributed (parallel) algorithm with k processors, etc.  Compare and contrast your version with mine. Which versions require a substantial modification of the basic algorithm? If the difference is only one of style, what does that say about the programming paradigm you used?
  7. What percentage, on average, of new novels are considered "good" according to this algorithm?
  8. This is an inefficient algorithm for choosing the books I want; design a better one.  (Hint: think about iterative algorithms on the theoretical level and caching on the practical level.  Before you start writing out complex classical searching and sorting algorithms, think about using library routines and also about whether the likely size of the arrays justifies using a complicated method.  This is supposed to be for finding a book in my local store, not on Amazon.com.)
  9. Find examples of "good books" (by any definition) which are rejected by my algorithm for a reason other than having already been read by me.
  10. Why would I include a criterion that obviously eliminates one or more of my favorite books? What happens when you remove a single elimination criterion?  Think about both literary and computational consequences.
  11. How would I need to modify my criteria if I wanted to choose the same books in another market?  What do the differences imply about the readers in each place?
  12. Formalize the task of finding a book and discuss the optimal algorithm under your set of assumptions.  What happens when you alter your assumptions?
  13. Is the task of finding a good book made harder or easier if most of the books look very similar?
  14. Does choosing a book using this algorithm follow the usual model of supply and demand in a free market?
  15. If you were a buyer for a bookstore and you learned that your patrons were using this algorithm to choose books, how would you modify your purchasing choices and/or the layout of your store?  What if the patrons all used this algorithm but each had their own set of elimination criteria?
  16. Do the data structures matter?  For example, what would change if the input were a linked list or a hash table instead of an array?  Does it matter what the array contains (pointers to book objects, ISBN numbers, book titles, the book objects themselves, etc.)?
  17. This is a method for finding books in a bricks-and-mortar store.  How would you modify it to find similar books online?  Would it matter how the online bookstore's website was designed? 
  18. Is it reasonable to ask for a list of books in the order they are shelved?  How would you get this list in a typical store inventory database?
  19. Is this an algorithm for a person or a computer to use?  Does it make a difference? I designed this algorithm as a description of what I actually do, not as a prescription (recipe) for choosing books. Does it make a difference? How would you convert my algorithm into advice for my grandmother on what book to buy me for my Birthday?  How do the previous questions shed light on this one?