Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In java please complete TODO 5 public class CSC300Queue [ private Node back, front; static boolean showMeSuccessfalse; // change to true to also show tests
In java please complete TODO 5
public class CSC300Queue [ private Node back, front; static boolean showMeSuccessfalse; // change to true to also show tests that pass static class Node public Node (char item, Node next) public char item; public Node next; this.itemitem; this.next next; // isEmpty // determine if the queue is empty // since back is the first node in the linked list, if back is null-there is no linked list, hence the queue is empty public boolean isEmpty() return back -null; /I frontItem // return the item at the front of the queue without removing it // precondition: queue is not empty // this example illustrates checking to see if the precondition is satisfied and this is often called 'peek handling the error if it is not public char frontItem ) [ if backnull) /7 there are no nodes so the queue is empty, client failed else if (front-= null) // this should not happen, if so the programme r failed ! else throw new NoSuchElementException("there is no front item in an empty queue!") throw new NoSuchElementException("an internal error has occurred in CSC300Queue: null front pointer"); return front.item // backItem // return the item at the back of the queue without altering the queue // precondition: queue is not empty // this example illustrates checking to see if the precondition is satisfied and handling the error if it is not public char backItem) if ( backnull) // queue is empty, user failed ! throw new NoSuchElementException("the queue is empty!") else return back.itemStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started