1. What are thenecessary steps to implement isEmpty() ? Note that this returns t
ID: 3618084 • Letter: 1
Question
1. What are thenecessary steps to implement isEmpty()? Note that this returns the valueTrue or the value False.
2. What are thenecessary steps to implement Peek()? Note that this will return a list node pointercalled S that is either null (anempty queue) or points to the same list node asFront, but without removing any nodes from thequeue.
3. There is a listnode pointer called Sthat points to a list node.What are the necessary steps to add this list node to the stack,that is to implements Enqueue( S)? Remember toconsider the various states in which the queue couldbe.
4. TheDequeue() operation will remove a node from the list. Thenode that is removed is pointed to by a list node pointercalled S. The Dequeue() operation will return the list nodepointer Sto whomever called it. Whatare the steps necessary to implement Dequeue()? Again, remember to consider all the variousstates in which the queue could be.
Explanation / Answer
1. What are thenecessary steps to implement isEmpty()?Note that this returns the value True or thevalue False.
return front ! = null;
2. What are thenecessary steps to implement Peek()?Note that this will return a list node pointer calledS thatis either null(an empty queue) or points to the samelist node as Front, butwithout removing any nodes from thequeue.
return front;
3. There is a list node pointer calledS thatpoints to a list node. What are the necessary steps to add thislist node to the stack, that is to implementsEnqueue( S )? Remember to consider the various states inwhich the queue could be.
4. The Dequeue() operation will remove a node from the list. Thenode that is removed is pointed to by a list node pointercalled S. The Dequeue() operation will return the list nodepointer Sto whomever called it. What are thesteps necessary to implement Dequeue()?Again, remember to consider all the various states in which thequeue could be.
Node temp = front;
front = front.next();
if(front == null) rear =null;
return temp;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.