CSE 2320 - Assignments

Not Graded Practice for Assignment 5


Practice Question 1

Modify the list-based implementation of stacks, as defined in files lists.c, stacks.h and stacks_lists.c, so that:


Practice Question 2

Modify the list implementation in lists.c and lists.h so that:


Practice Question 3

(This is Problem 4.31 from the textbook).

A letter means put and an asterisk means get in the sequence

E A S * Y * Q U E * * * S T * * * I O * N * * *.
Give the sequence of values returned by the get operations when this sequence of operations is performed on an initially empty FIFO queue.


Practice Question 4

(This is Problem 4.34 from the textbook).

An uppercase letter means put at the beginning, a lowercase letter means put at the end, a plus sign means get from the beginning, and an asterisk means get from the end in the sequence

E A s + Y + Q U E * * + s t + * + I O * n + + *.
Give the sequence of values returned by the get operations when this sequence of operations is performed on an initially empty deque.


Practice Question 5

(This is Problem 5.1 from the textbook).

Write a recursive program to compute lg(N!).


Practice Question 6

(This is Problem 5.2 from the textbook).

Modify Program 5.1 to compute N! mod M, so that overflow is no longer an issue. Try running your program for M = 997 and N = 103, 104, 105, and 106 in order to get an indication of how your programming system handles deeply nested recursive calls.


Practice Question 7

(This is Problem 5.5 from the textbook).

Provide a nonrecursive implementation of Euclid's algorithm.


Practice Question 8

(This is Problem 5.7 from the textbook).

Give the recursive depth of Euclid's algorithm when the input values are two consecutive Fibonacci numbers (FN and FN+1).


Practice Question 9

(This is Problem 5.9 from the textbook).

Write a recursive program to evaluate postfix expressions.


Practice Question 10

(This is Problem 5.10 from the textbook).

Write a recursive program to evaluate infix expressions. You may assume that operands are always enclosed in parentheses.


Practice Question 11

(This is Problem 5.11 from the textbook).

Write a recursive program that converts infix expressions to postfix.


Practice Question 12

(This is Problem 5.12 from the textbook).

Write a recursive program that converts postfix expressions to infix.


(Challenge) Practice Question 13

(This is Problem 4.36 from the textbook).

Given two sequences, give an algorithm for determining whether or not it is possible to add plus signs and asterisks to make the first produce the second when interpreted as a sequence of deque operations in the sense of Exercise 4.36.


Back to the list of assignments.