CSC 200 T3 Chapter 8

¡Supera tus tareas y exámenes ahora con Quizwiz!

ANSWER: An empty linked list is indicated by a NIL head pointer.

1. What condition indicates that a linked list is empty?

ANSWER: B STACK

1. Which of the following is a LIFO structure? A. Array B. Stack C. Queue D. Tree

ANSWER: C r,y,z

10. 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

ANSWER: PICTURE

10. The table below represents a portion of a computer's main memory containing a binary tree stored row by row in a contiguous block as described in the chapter. Draw a picture of the tree. Address Contents 50 A 51 B 52 C 53 D 54 E 55 F 56 G

ANSWER: B y,z,r

11. 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

Indirect addressing allows the same instruction to be used to perform the same operation on different items of data by changing the value of the pointer referenced in the instruction.

11. In a machine language, what advantage does indirect addressing offer over immediate and direct addressing?

ANSWER: D, C

11. What sequence of nodes from the tree would be printed if the following recursive procedure were applied to it? (The procedure uses a global stack called Stack that is assumed to begin empty.) procedure printTree (Tree) push the left child of the root node on Stack; if (right branch of Tree is not empty) then (apply the procedure printTree to the right subtree of Tree) pop an entry from Stack and print that node. ________________

ANSWER: C 2n+1-1 nodes

12. If the number of nodes in a binary tree is 2n (where n is a positive integer), then the entire tree would contain at least A. 2n + 1 nodes B. 22n nodes C. 2n + 1 - 1 nodes D. 2n + 2 nodes

ANSWER: AA

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 56, what data is in the left child of the root node? Address Contents 50 AA 51 53 52 00 53 BB 54 00 55 00 56 CC 57 50 58 00 _________________

ANSWER: C 15

13. 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

ANSWER: One

13. 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 53, how many terminal nodes are in the tree? Address Contents 50 AA 51 00 52 00 53 BB 54 00 55 56 56 CC 57 00 58 00 _________________

ANSWER: Three

14. 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 53, how many nodes are on the longest path in the tree? Address Contents 50 AA 51 56 52 00 53 BB 54 00 55 50 56 CC 57 00 58 00 _________________

ANSWER: D and E

15. The table below represents a portion of a computer's main memory containing a binary tree stored row by row in a contiguous block as described in the chapter. What are the children of the node B? Address Contents 50 A 51 B 52 C 53 D 54 E 55 F 56 G

ANSWER: 16

16. If the longest path in a binary tree contains five nodes, what is the maximum number of terminal nodes that could be in the tree? _________________

ANSWER: Box.length

17. If the variable named Box had the user-defined type RectangleType defined by Define type RectangleType to be {real length; real width; real height } What expression would be used to reference the length of Box? _________________

ANSWER: C

17. Suppose a binary tree is implemented as a linked structure in which each node contains both a left child pointer and a right child pointer. Which of the following statements is false? A. The number of nodes in the tree is always at least the number of nodes on the longest path in the tree. B. The number of NIL pointers in the tree is always greater than the number of nodes in the tree. C. Each terminal node in the tree is always at the end of a path that is as least as long as any other path in the tree. D. Both the left child and right child pointers of every terminal node are NIL.

ANSWER: BananaSplit Desert; (The declaration of Desert would use the same syntax as the declarations using the primitive type int.)

18. If the type BananaSplit was defined by a statement such as define type BananaSplit to be {int Banana; int IceCream; int Chocolate; int WhippedCream; int Nuts; int Cherry } what statement would probably be used to declare the variable Desert to be an instance of that type? _________________ ANSWER: BananaSplit Desert; (The declaration of Desert would use the same syntax as the declarations using the primitive type int.)

ANSWER: C = Y

18. The table below represents a portion of a computer's main memory containing a binary tree stored row by row in a contiguous block as described in the chapter. What is the left child of the node V? Address Contents 50 T 51 U 52 V 53 W 54 X 55 Y 56 Z A. W B. X C. Y D. Z

ANSWER: C

19. The table below represents a portion of a computer's main memory containing a binary tree stored row by row in a contiguous block as described in the chapter. What is the parent of the node Z? Address Contents 50 T 51 U 52 V 53 W 54 X 55 Y 56 Z A. T B. U C. V D. Y

ANSWER: Change the cell at address 51 to 54 and change the cell at address 53 to 50.ANSWER: Change the cell at address 51 to 54 and change the cell at address 53 to 50.

2. 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

stacks, top, queues, head, tail

2. Two special forms of lists are the LIFO structures known as _______________ , in which entries are inserted and removed from the ______________ , and FIFO structures known as ________________ , in which entries are removed from the ________________ and inserted at the ________________ .

ANSWER: C Queue

2. Which of the following is a FIFO structure? A. Array B. Stack C. Queue D. Tree

ANSWER: A Immediate addressing

20. In a machine language, the technique in which the data to be manipulated by an instruction is included within the instruction itself is called A. Immediate addressing B. Direct addressing C. Indirect addressing

ANSWER: C Indirect Addressing

21. In a machine language, the technique in which an instruction contains the location of a pointer to the data to be manipulated is called A. Immediate addressing B. Direct addressing C. Indirect addressing

ANSWER: A. 58 B. 53

21. The following represents a portion of a computer's main memory. Address Contents 50 51 51 56 52 53 53 57 54 58 55 50 56 57 57 52 58 53 A. What would be stored at address 50 after executing the instruction "Copy the contents of the memory cell at address 54 to address 50"? ________________ B. What would be stored at address 50 after executing the instruction "Copy the contents of the memory cell pointed to by the cell at address 54 to address 50"? ________________

ANSWER: x + n(7(I - 1) + J - 1)

3. Suppose the expression X[1, 1] referred to the first-row, first-column entry in a two-dimensional array with 5 rows and 7 columns. If the array is stored in row-major order beginning at memory address x and each entry in the array requires n memory cells, what address polynomial would be used to compute the address of the beginning of the entry X[I, J]? ________________

ANSWER: Change the cell at address 55 to 56.

3. 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 56 is inserted at the end of the list. Address Contents 50 AA 51 00 52 BB 53 58 54 CC 55 00 56 DD 57 00 58 EE 59 54

ANSWER: A ARRAY

3. Which of the following is static in the sense that it does not change size or shape as information is stored and retrieved? A. Array B. Stack C. Queue D. Tree

ANSWER: x + n(5J + I)

4. Suppose the expression X[0, 0] referred to the first-row, first-column entry in a two-dimensional array with 5 rows and 7 columns. If the array is stored in column-major order beginning at memory address x and each entry in the array requires n memory cells, what address polynomial would be used to compute the address of the beginning of the entry X[I, J]? ________________

ANSWER: B Stack

4. 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? A. Traditional linked list B. Stack C. Queue D. Tree

ANSWER: PICTURE

4. 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 53, draw a picture of the tree showing the data in each node? Address Contents 50 AA 51 56 52 00 53 BB 54 00 55 50 56 CC 57 00 58 00

ANSWER: C, D, A

5. If a queue contained the entries B, C, D (from head to tail), what would be the contents of the queue (again from head to tail) after one entry was removed and the entry A was inserted?

ANSWER: C Y

5. Suppose a binary tree contained the nodes W, X, Y, and Z. If W and X were children of Y, and Z had no children, which node would be the root? A. W B. X C. Y D. Z

ANSWER: To keep it from crawling through memory unchecked.

5. Why is a queue normally implemented as a circular queue?

ANSWER: A

6. Suppose a binary tree contained the nodes W, X, Y, and Z, and each node had at most one child. How many terminal nodes would be in the tree? A. One B. Two C. Three D. Undetermined

ANSWER: A The entry X[1,2] would appear before X[2,1]

7. If the two-dimensional array X were stored in row-major order, then in the block of main memory containing X, which of the following would be true? A. The entry X[1,2] would appear before X[2,1]. B. The entry X[1,2] would appear after X[2,1]. C. The entry X[1,2] would be in the same location as X[2,1]. D. None of the above

ANSWER: In the direction of its tail

7. In which direction does an unchecked queue crawl through memory (in the direction of its head or in the direction of its tail)? ________________

ANSWER: DD, CC, AA

8. The table below represents a portion of a computer's main memory containing a linked list. Each list entry consists of two cells, the first being data and the second being a pointer to the next list entry. If the nil pointer is represented by 00 and the list's head pointer contains 56, what are the data entries in the list? (List the entries in the order they occur in the list.) Address Contents 50 AA 51 00 52 BB 53 58 54 CC 55 50 56 DD 57 54 58 EE 59 00 _________________

ANSWER: B Number of rows in the array

8. Which of the following is not used when determining the location of an entry in a two-dimensional homogeneous array stored in row-major order? A. Indices B. Number of rows in the array C. Address polynomial D. Number of columns in the array

Direct adressing allows the address of the data to be manipulated is included in the instruction. indirect addressing allows the location of a pointer to the data to be manipulated is included in the instruction.

9. What is the distinction between direct addressing and indirect addressing?

ANSWER: D NIL pointer

9. Which of the following is not a means of locating an entry in a linked storage structure? A. Head pointer B. Child pointer C. Root pointer D. NIL pointer

ANSWER: A. A B. B, C, and D C. E, F, G, and D D. B

NEED PICTURE 1. Answer the following questions in terms of the tree below. A. The root node is ________ . B. Three nodes that are siblings are _______ , ________, and ________ . C. The terminal nodes are _________________________________________ . D. The node with only one child is _________ .

ANSWER: G, C, A

NEED PICTURE 10. What sequence of nodes from the tree would be printed if the following recursive procedure were applied to it? (The procedure uses a global stack called Stack that is assumed to begin empty.) procedure printTree (Tree) if (Tree is not empty) then (push the current node on Stack; apply the procedure printTree to the right subtree of Tree) if (Stack is not empty) then (pop an entry from Stack and print that node) ________________

ANSWER: C

NEED PICTURE 16. 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.

ANSWER: A, C, G

NEED PICTURE 9. What sequence of nodes from the tree would be printed if the following recursive procedure were applied to it? procedure printTree (Tree) if (Tree is not empty) then (print the root of Tree; apply the procedure printTree to the right subtree of Tree) ________________

ANSWER: C

NEED PICTURE 14. The nodes in which of the trees below will be printed in alphabetical order by the following recursive procedure? procedure printTree (Tree) if (Tree is not empty) then (print the root node; apply the procedure printTree to the right subtree of Tree; apply the procedure printTree to the left subtree of Tree) A. B. C.


Conjuntos de estudio relacionados

Pharm Made Easy 4.0- The Reproductive and Genitourinary Systems Test

View Set

Chapter 25: The Child with Gastrointestinal Dysfunction

View Set

To Kill a Mockingbird Chapter 1-7

View Set

Internet, Intranets, and Extranets

View Set

NURS114: Chapter 2 Collecting Subjective Data

View Set