Problem

As Chapter pointed out, you can define ADT operations in a mathematically formal way by us...

As Chapter pointed out, you can define ADT operations in a mathematically formal way by using axioms. Consider the following axioms for the ADT queue, where queue is an arbitrary queue and item is an arbitrary queue item.

(queue.createQueue()).isEmpty() = true

(queue.enqueue(item)).isEmpty() =false

(queue.createQueue()).dequeue() =error

((queue.createQueue()).enqueue(item)).dequeue() =

queue.createQueue()

queue. isEmpty () = false =>

(queue.enqueue(item)).dequeue() =

(queue.dequeue()).enqueue(item)

(queue.createQueue()) .peek() = error

((queue.createQueue()).enqueue(item)).peek() = item

queue.isEmpty() = false =>

(queue.enqueue(item)).peek() = queue.peek()

a. Note the recursive nature of the definition of peek. What is the base case? What is the recursive step? What is the significance of the isEmpty test? Why is peek recursive in nature while the operation peek for the ADT stack is not?

b. The representation of a stack as a sequence of push operations without any pop operations was called a canonical form. (See 16a in Chapter.) Is there a canonical form for the ADT queue diat uses only enqueue operations? That is, is every queue equal to a queue that can be written with only enqueues? Prove your answer.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 8
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT