CS 242, Section 002 Sonoma State University Spring, 2026
 
Discrete Structures for Computer Science
Instructor: Henry M. Walker

Lecturer, Sonoma State University
Professor Emeritus of Computer Science and Mathematics, Grinnell College

Notes:


Assignment 12 (Graphs and Trees)

  1. Are there any graphs with 3 or more vertices for which a breadth-first search and a depth-first search must yield exactly the same output, starting at a given vertex? If so, describe this type of graph and any requirement(s) for the starting vertex. If not, explain why not.

  2. Which of the following are binary search trees? (In each case justify your answer.)


    tree examples
  3. Given a binary tree, write pseudocode for a procedure that will return the number of nodes that have no (non-null) left children. The initial call for the procedure should be:

           printNullLeft (root);
        

    Note: If you prefer to write this procedure in C, C++, or Python, you may, provided you also provide appropriate code for the structure of a node with data and designators for the left and right children.

  4. Given a binary search tree and given integers low and high, write pseudocode for a procedure that will print values in all nodes that are between low and high. (In this work, any nodes containing the values low or high should be included in the output.) The initial call for the procedure should be:

           printLevel (root, low, high);
        

    This code should be as efficient as possible, so that processing should not visit any more nodes than are necessary.

    Note: As in the previous problem, if you prefer to write this procedure in C, C++, or Python, you may, provided you also provide appropriate code for the structure of a node with data and designators for the left and right children.


created October 25, 2025
revised October-November, 2025
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.