Docsity

Sample Assignment 1 - Programming Languages | CS 401, Assignments of Programming Languages

Toggle sidebar
bg1
CS 405/505 ASSIGNMENT #1
Due Thursday, August 23, 2007, 9:45 P. M.
Fill in the Blank.
1. Name:
2. I have satisfied the prerequisites of CS 303 Algorithms and Data Structures and CS 350
Formal Languages and Automata, or equivalent, each with a grade of C or better.
Signature:
True or False.
For each of the problems below, indicate whether it is true or false. Justify your answer in either
case.
3. A context-free grammar defining a deterministic context-free language may always be con-
verted into a deterministic pushdown automaton.
4. The context-free grammar below is ambiguous.
Sโ†’if (e) S|if (e) Selse S|s
5. It is not possible to implement a tree data structure where interior nodes have an arbitrary
number of children (e.g. some nodes may have 1 child, some 2, some 3, etc.).
Short Answer.
6. Assume a binary tree object with functions value,left and right to return the value of
the current node, left subtree, and right subtree, respectively. Using an actual programming
language or pseudo-code, write a function postorder to print the values of all nodes in the
tree using a post-order traversal. Please write your answer on back.

Partial preview of the text

Download Sample Assignment 1 - Programming Languages | CS 401 and more Assignments Programming Languages in PDF only on Docsity!

CS 405/505 ASSIGNMENT

Due Thursday, August 23, 2007, 9:45 P. M.

Fill in the Blank.

  1. Name:
  2. I have satisfied the prerequisites of CS 303 Algorithms and Data Structures and CS 350 Formal Languages and Automata, or equivalent, each with a grade of C or better.

Signature:

True or False.

For each of the problems below, indicate whether it is true or false. Justify your answer in either case.

  1. A context-free grammar defining a deterministic context-free language may always be con- verted into a deterministic pushdown automaton.
  2. The context-free grammar below is ambiguous. S โ†’ if (e) S | if (e) S else S | s
  3. It is not possible to implement a tree data structure where interior nodes have an arbitrary number of children (e.g. some nodes may have 1 child, some 2, some 3, etc.).

Short Answer.

  1. Assume a binary tree object with functions value, left and right to return the value of the current node, left subtree, and right subtree, respectively. Using an actual programming language or pseudo-code, write a function postorder to print the values of all nodes in the tree using a post-order traversal. Please write your answer on back.