| CS 242, Section 002 | Sonoma State University | Spring, 2026 |
|
Discrete Structures for Computer Science
|
||
|
Instructor: Henry M. Walker
Lecturer, Sonoma State University | ||
Notes:
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.
Which of the following are binary search trees? (In each case justify your answer.)
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.
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 |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |