3.26. Discussion Questions

  1. Convert the following values to binary using “divide by 2.” Show the stack of remainders.

    • 17

    • 45

    • 96

  2. Convert the following infix expressions to prefix (use full parentheses):

    • (A+B)*(C+D)*(E+F)

    • A+((B+C)*(D+E))

    • A*B*C*D+E+F

  3. Convert the above infix expressions to postfix (use full parentheses).

  4. Convert the above infix expressions to postfix using the direct conversion algorithm. Show the stack as the conversion takes place.

  5. Evaluate the following postfix expressions. Show the stack as each operand and operator is processed.

    • 2 3 * 4 +

    • 1 2 + 3 + 4 + 5 +

    • 1 2 3 4 5 * + * +

  6. The alternative implementation of the Queue ADT is to use a list such that the rear of the queue is at the end of the list. What would this mean for Big-O performance?

  7. What is the result of carrying out both steps of the linked list add method in reverse order? What kind of reference results? What types of problems may result?

  8. Explain how the linked list remove method works when the item to be removed is in the last node.

  9. Explain how the remove method works when the item is in the only node in the linked list.

You have attempted of activities on this page
Next Section - 3.27. Programming Exercises