This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: ensure switch is still set A1 ‐ A3 move engine forward past switch set switch A1 ‐ A2 reverse engine back to join train endif Question 2 answer gets 1 if N < 0 then negative gets 1 N gets ‐ N else negative gets 0 endif while N>0 do answer gets answer * 2 N gets N ‐ 1 endwhile if negative=1 then answer = 1/answer endif answer contains 2 N Question 3 Assume a table top where CD's can be temporarily placed. while the box is not empty do if the CD at the top of the box is a bargain CD then move CD from top of box to bargain bin else move CD from top of box to table top while table top is not empty do if the leftmost slot is empty then move CD from table top to leftmost slot e l s e if the CD to the left of the leftmost empty slot > CD on table top then m o v e C D t o t h e l e f t o f t h e leftmost empty slot one slot right e l s e move CD on table top to the leftmost empty slot e n d i f e n d i f endwhile endif endwhile...
View Full Document
This note was uploaded on 02/28/2011 for the course MATH 101 taught by Professor Duke during the Spring '11 term at University of Ottawa.
- Spring '11