Have you ever tried to do a Web search and got way too many links (hits) to be helpful? Perhaps you tried to add another word, in the hopes of narrowing the search down. With some search engines, that will work. For other search engines, that can actually give you more results, because rather than requiring both words, the engine only needs one of them to consider a site to be a hit. Thats the dierence between AND and OR. Heres a paragraph that might appear on a Web page: Welcome to my cheese fan site! I love all kinds of cheese, from asagio to zamorano, imported from countries from Argentina to Wales (and many domestic cheeses too)! These pages have my thoughts and opinions on every- thing Ive tried. Some yummy recipes, too. Enjoy! 1. Following are some possible Web searches. Decide if the search will register this page as a hit (assuming this para- graph is all thats on the page). Remember: AND means both words have to be on the page; OR means at least one of the two has to be there. (a) cheese AND mozzarella (b) cheese OR mozzarella (c) cheese AND Argentina (d) sardo AND Argentina Sardo is an Argentinean cheese. 2. Search engines compare the text on a Web page to the words given for the search. If a word appears on the page, the search engine considers this TRUE. If the word doesnt, If the search word appears within a word on the pagefor example, port appears inside importedthis is considered TRUE. the engine considers this FALSE. Decide if the following words are TRUE or FALSE for the paragraph above. (a) cheese (b) mozzarella (c) Argentina (d) sardo 3. To the search engine, AND and OR are operators, sort of like addition and multiplication. They are called Boolean operators, which can work with only two numbers, Boolean operators are particularly useful with computer programming and creating spreadsheets. TRUE and FALSE. Once the engine determines if a word is TRUE or FALSE, it evaluates the whole expression. De- termine how the following should be evaluated. Problems with a Point: March 12, 2002 c EDC 2001 Web search operations: Problem 2 (a) TRUE AND TRUE (Ex: cheese AND Argentina) (b) TRUE AND FALSE (Ex: cheese AND mozzarella) (c) FALSE AND TRUE (Ex: sardo AND Argentina) (d) FALSE AND FALSE (Ex: mozzarella AND sardo) (e) TRUE OR TRUE (Ex: cheese OR Argentina) (f) TRUE OR FALSE (Ex: cheese OR mozzarella) (g) FALSE OR TRUE (Ex: sardo OR Argentina) (h) FALSE OR FALSE (Ex: mozzarella OR sardo) You can make more complicated expressions, too. For example, to nd cheddar cheeses specically from Vermont or Wisconsin, search for cheddar AND (Vermont OR Wisconsin). As with arithmetic operations, evaluate expressions inside parentheses rst. Then evaluate from left to right. 4. Evaluate the following expressions as TRUE or FALSE. (a) TRUE AND (FALSE OR TRUE) (b) FALSE OR (TRUE AND TRUE) (c) (TRUE OR FALSE) AND (TRUE AND FALSE) (d) (FALSE AND FALSE) OR (TRUE AND TRUE) Both AND and OR are called binary operations because you The prex bi- means two and the prex uni- means one. need two objects to combine. (Addition and multiplication are binary operations, tooyou need two numbers to add or mul- tiply together.) Unary operations need only one objectfor ex- ample, absolute value is a unary operation. There is a unary Boolean operator: NOT, which simply changes a value to the other: NOT TRUE is FALSE and NOT FALSE is TRUE. Evaluate NOT before you evaluate AND or OR. 5. Your cheese search might give too many sites with recipes. Would the sample Web page be a hit for the search cheese AND NOT recipes? 6. Evaluate the following expressions: (a) TRUE AND NOT TRUE (b) FALSE OR NOT TRUE (c) TRUE AND NOT FALSE (d) FALSE OR NOT (TRUE AND NOT TRUE) (e) NOT [TRUE AND NOT (FALSE OR NOT TRUE)] 7. Challenge: A famous result of Boolean algebra gives an This result is one of De Morgans formulas. equivalent expression for NOT (a AND b) using OR. Fill in the blanks so the two expressions evaluate the same, whether a and b are TRUE or FALSE: NOT (a AND b) is the same as OR . Problems with a Point: March 12, 2002 c EDC 2001 Web search operations: Answers 1 Answers 1. (a) not a hit (b) hit (c) hit (d) not a hit 2. (a) TRUE (b) FALSE (c) TRUE (d) FALSE 3. (a) TRUE Teachers Note: Some students may have trouble with the idea that TRUE and FALSE are numbers. Try not to push the concept; students should be able to see that if one thing is true and another thing is false, you cant say that, together, theyre true. At best its half-true. Since were only working with two possibilitiestrue and falsewe have to say this expression (true and false) is false. Teachers Note: Perhaps as an extension, you might have students replace TRUE with the number 1 and FALSE with the number 0. (Much computer software interprets Boolean values in this way.) Ask if there are arithmetic operations that correspond to the Boolean operations. (AND works like multiplication. OR almost works like addition, except for TRUE OR TRUE, because 1 +1 isnt 1.) (b) FALSE (c) FALSE (d) FALSE (e) TRUE (f) TRUE (g) TRUE (h) FALSE 4. (a) TRUE (b) TRUE (c) FALSE (d) TRUE 5. No, its not a hit. 6. (a) FALSE (b) FALSE (c) TRUE (d) TRUE (e) FALSE 7. NOT (a AND b) is the same as NOT a OR NOT b. Teachers Note: As an additional challenge, students could prove that this formula can be extended to any number of variablesfor example, NOT (a AND b AND c) is the same as NOT a OR NOT b OR NOT c. Problems with a Point: March 12, 2002 c EDC 2001