Quiz on Chapter 9 | Introduction to Programming Using Java

Quiz on Chapter 9 | Introduction to Programming Using Java

 

Quiz on Chapter 9

 

  1. Explain what is meant by a recursive
  2. Consider the following subroutine:

Quiz on Chapter 9 | Introduction to Programming Using Java

 

Show the output that would be produced by the subroutine calls printStuff(0),

 

85 3 Quiz on Chapter 9 | Introduction to Programming Using Java

 

  1. Suppose that a linked list is formed from objects that belong to the class

86 2 Quiz on Chapter 9 | Introduction to Programming Using Java

 

Write a subroutine that will count the number of zeros that occur in a given linked list of ints. The subroutine should have a parameter of type ListNode and should return a value of type int.

  1. What are the three operations on a stack?
  2. What is the basic difference between a stack and a queue?
  3. What is an activation record? What role does a stack of activation records play in a computer?
  4. Suppose that a binary tree of integers is formed from objects belonging to the class

87 2 Quiz on Chapter 9 | Introduction to Programming Using Java

 

Write a recursive subroutine that will find the sum of all the nodes in the tree. Your subroutine should have a parameter of type TreeNode, and it should return a value of type int.

  1. What is a postorder traversal of a binary tree?
  2. Suppose that a <multilist> is defined by the BNF rule

Quiz

88 2 Quiz on Chapter 9 | Introduction to Programming Using Java

 

 

be any sequence of letters. Give five different <multilist>’s that can be generated by this rule. (This rule, by the way, is almost the entire syntax of the programming language LISP! LISP is known for its simple syntax and its elegant and powerful semantics.)

  1. Explain what is meant by parsing a computer program.

Generic Programming and Collection Classes

How to avoid reinventing the wheel? Many data structures and algorithms, such as those from Chapter 9, have been studied, programmed, and re-programmed by generations of computer science students. This is a valuable learning experience. Unfortunately, they have also been programmed and re-programmed by generations of working computer professionals, taking up time that could be devoted to new, more creative work.

A programmer who needs a list or a binary tree shouldn’t have to re-code these data structures from scratch. They are well-understood and have been programmed thousands of times before. The problem is how to make pre-written, robust data structures available to programmers. In this chapter, we’ll look at Java’s attempt to address this problem.

 

Quiz on Chapter 9 | Introduction to Programming Using Java

 

SEE MORE:

Leave a Comment