An algorithm based on observation - Shelving books in alphabetical order
By: Kathryn Barrett
Special thanks to Christine!
int step one = are all your books taken off the shelf in order to be organized?
int step two = does the first bookyou pick up have an author whose last name starts with the letter "a"?
int step three = does the second book you pick up have an author whose last name starts with the same letter as the first book you placed?
int step four = are there more books to be shelved?
call int step one
if true, continue to step two
else, take books off shelf until int step one is true
call int step two
if true, place the book so the spine is vertical on the far left side of the shelf and continue to int step three
else, place the book so the spine is vertical in a location on the shelf approximate to the letters in the alphabet starting from left to right and continue to int step three
call int step three
if true, place the book so the spine is vertical di
rectly next to your first book and continue to int step four
else, place the book so the spine is vertical in a location on the shelf approximate to the letters in the alphabet starting from left to right and continue to int step four
call int step four
if true, repeat step two followed by step three until
else, your books are shelved in alphabetical order
No comments:
Post a Comment