Professional Documents
Culture Documents
4
This assignment must be handed in before 09.15 on Friday the 24/9-2010.
Multiple Choice
Chapter
6
1. Which of the following is not a control statement?
Chapter
8
6. Which of the following is a LIFO structure?
8. Suppose you were going to retrieve items of data that you would later need to process in the opposite
order from that in which they were retrieved. Which of the following would be the best structure in which
to store the items?
9. If a stack contained the entries w, x, y, z (from top to bottom), which of the following would be the
contents after two entries were removed and the entry r was inserted?
A. w, x, r B. y, z, r C. r, y, z D. r, w, x
10. If a queue contained the entries w, x, y, z (from head to tail), which of the following would be the
contents after two entries were removed and the entry r was inserted?
A. w, x, r B. y, z, r C. r, y, z D. r, w, x
11. If the longest path in a binary tree contained exactly four nodes, what is the maximum number of nodes
that could be in the entire tree?
A. 4 B. 7 C. 15 D. 31
12. The table below represents a portion of a computer’s main memory containing a binary tree. Each node
consists of three cells, the first being data, the second being a pointer to the node’s left child, and the third
being a pointer to the node’s right child. If the nil pointer is represented by 00 and the tree’s root pointer
contains 50, which of the following is a picture of the tree?
Address Contents
50 A
51 56
52 53
53 B
54 00
55 00
56 C
57 00
58 00
A. B. C.
Fill-‐in-‐the-‐blank/Short-‐answer Questions
Chapter 6
1. In contrast to _______________ languages such as English and Spanish, programming languages are
2. Indicate how each of the following types of programming languages is classified in terms of generation
(first generation, second generation, or third generation).
3. List four data types that occur as primitive types in many high-level programming languages.
____________________ ____________________
____________________ ____________________
4. What encoding system is commonly used to encode data of each of the following types?
A. Integer ___________________________
B. Real __________________________
C. Character ___________________________
5. In programming languages that use + to mean concatenation of character strings, the expression
“2x” + “3x”
________________
if (X = 5) goto 50
goto 60
50 print the value of Z
goto 100
60 print the value of Y
100 . . .
Chapter
8
7. Answer the following questions in terms of the tree below.
B. Three nodes that are siblings are _______ , ________, and ________ .
________________
Chapter 6
Chapter 8
NIL pointer, top, root, tree, abstraction, stack, pointer, user-defined data type, queue, list, linked structure
Chapter
6
1. Explain the distinction between translating a program (in a high-level language) and interpreting the
program.
4. Explain why key words in a programming language are often reserved words.
Chapter
8
5. The table below represents a portion of a computer’s main memory containing a linked list. Each entry
consists of two cells, the first being data, the second being a pointer to the next entry. If the nil pointer is
represented by 00 and the list’s head pointer contains 52, modify the memory cells so the data at address 50
replaces the second entry in the list.
Address Contents
50 AA
51 00
52 BB
53 58
54 CC
55 00
56 DD
57 00
58 EE
59 54