Quiz 8b

AMES 5

Quantitative Computer Skills

Quiz 8b, Feb. 25, 1999

(Closed book and notes, Choose one best answer, Use green scantron form)

1. A bubble sort algorithm

(a) arranges bubbles according to size. (b) is a fast way to sort a list that is hard to understand.

(c) is a slow way to sort a list that is easy to understand. (d) has nothing to do with lists.

(e) arranges sizes according to their bubbles.

2. The output of the program IF a>b then (new line) PRINT "swap" (new line) ELSE (new line) PRINT "don't swap" (new line) END IF (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

3. The output of the program IF b>a then (new line) PRINT "swap" (new line) ELSE (new line) PRINT "don't swap" (new line) END IF (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

4. The output of the program IF "b">a then (new line) PRINT "swap" (new line) ELSE (new line) PRINT "don't swap" (new line) END IF (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

5. The output of the program IF "b">"a" then (new line) PRINT "swap" (new line) ELSE (new line) PRINT "don't swap" (new line) END IF (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

6. The output of the program IF "ba">"bb" then (new line) PRINT "swap" (new line) ELSE (new line) PRINT "don't swap" (new line) END IF (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

7. The output of the program IF "bb">"bb" then (new line) PRINT "swap" (new line) ELSE (new line) PRINT "don't swap" (new line) END IF (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

8. The output of the program IF "bb">"ba" then (new line) PRINT "swap" (new line) ELSE (new line) PRINT "don't swap" (new line) END IF (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

9. The output of the program IF "a">"b" then (new line) LET c$="a" (new line) ELSE (new line) LET c$="b" (new line) END IF (new line) PRINT c$ (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

10. The output of the program IF "b">"a" then (new line) LET c$="a" (new line) ELSE (new line) LET c$="b" (new line) END IF (new line) PRINT c$ (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

11. The output of the program LET a1$="a" (new line) LET a2$="b" (new line) IF a1$>a2$ then (new line) LET c$=a1$ (new line) ELSE (new line) LET c$=a2$ (new line) END IF (new line) PRINT c$ (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

12. The output of the program LET a1$="b" (new line) LET a2$="a" (new line) IF a1$>a2$ then (new line) LET c$=a1$ (new line) ELSE (new line) LET c$=a2$ (new line) END IF (new line) PRINT c$ (new line) END is

(a) an error message (b) swap (c) don't swap (d) a (e) b

13. The output of the program LET a1$="b" (new line) LET a2$="a" (new line) PRINT a1$;a2$; (new line) IF a1$>a2$ then (new line) LET c$=a1$ (new line) LET a1$=a2$ (new line) LET a2$=c$ (new line) PRINT " swap "; (new line) ELSE (new line) PRINT " don't swap "; (new line) END IF (new line) PRINT a1$;a2$ (new line) END is

(a) an error message (b) ba swap ab (c) ab swap ba (d) ba don't swap ba (e) ab don't swap ab

14. The output of the program LET a1$="a" (new line) LET a2$="b" (new line) PRINT a1$;a2$; (new line) IF a1$>a2$ then (new line) LET c$=a1$ (new line) LET a1$=a2$ (new line) LET a2$=c$ (new line) PRINT " swap "; (new line) ELSE (new line) PRINT " don't swap "; (new line) END IF (new line) PRINT a1$;a2$ (new line) END is

(a) an error message (b) ba swap ab (c) ab swap ba (d) ba don't swap ba (e) ab don't swap ab

15. The output of the program LET a1$="az" (new line) LET a2$="aa" (new line) PRINT a1$;a2$; (new line) IF a1$>a2$ then (new line) LET c$=a1$ (new line) LET a1$=a2$ (new line) LET a2$=c$ (new line) PRINT " swap "; (new line) ELSE (new line) PRINT " don't swap "; (new line) END IF (new line) PRINT a1$;a2$ (new line) END is

(a) an error message (b) azaa swap aaaz (c) aaaz swap azaa

(d) aaaz don't swap aaaz (e) azaa don't swap azaa

16. The output of the program LET a1$="aa" (new line) LET a2$="az" (new line) PRINT a1$;a2$; (new line) IF a1$>a2$ then (new line) LET c$=a1$ (new line) LET a1$=a2$ (new line) LET a2$=c$ (new line) PRINT " swap "; (new line) ELSE (new line) PRINT " don't swap "; (new line) END IF (new line) PRINT a1$;a2$ (new line) END is

(a) an error message (b) azaa swap aaaz (c) aaaz swap azaa

(d) aaaz don't swap aaaz (e) azaa don't swap azaa

17. The output of the program DIM list$(1) (new line) MAT READ list$(3) (new line) DATA c,b,a (new line) MAT PRINT list$; (new line) END is

(a) an error message (b) abc (c) cba (d) cab (e) bac

18. The output of the program DIM list$(1) (new line) MAT READ list$(3) (new line) DATA b,a,c (new line) CALL sort(list$) (new line) MAT PRINT list$; (new line) END (new line) SUB sort(a$()) (new line) DO (new line) LET sorted$="true" (new line) FOR i = 1 to 2 (new line) IF a$(i)>a$(i+1) then (new line) LET c$=a$(i) (new line) LET a$(i)=a$(i+1) (new line) LET a$(i+1)=c$ (new line) LET sorted$="false" (new line) END IF (new line) NEXT i (new line) LOOP until sorted$="true" (new line) END SUB is

(a) an error message (b) abc (c) cba (d) cab (e) bac

 

Quiz 9 (takehome: due in section next week) PP4.4, PP4.5, PP5.5, PP5.6