Queries

  1. In 1977, President Jimmy Carter eased the immigration restrictions into the United States. That same year, Fidel Castro emptied his prisons. The following query might have been used by American Immigration officials in determining whether to deny entry to various individuals:

    retrieve NAME where (COUNTRY = Cuba AND AGE > 15 AND CRIME <> political)

  2. The algorithm for determining whether secondary indices help in answering a query, Q, is given below:
       construct parse tree of Q
       mark each leaf that refers to an indexed field
       loop
          for each unmarked node
             if the node is an AND node with 
    		at least one marked child
             or it is an OR node with 
    		both children marked then 
    	    mark the node
          exit when no nodes were marked
       end loop
       if root is marked, then the indices help
    
    What traversal method would require only a single pass through the loop, for any parse tree, to determine whether or not the indices help answer Q?