EBK STARTING OUT W/JAVA:...DATA...
EBK STARTING OUT W/JAVA:...DATA...
4th Edition
ISBN: 9780134757179
Author: GADDIS
Publisher: PEARSON CO
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 20, Problem 4FTE

Explanation of Solution

Program purpose:

The given program is used to implement queue using linked list.

Syntax error:

An error that occurs on the source code of a program is referred as a “syntax error”, because the computer programs strictly follow the syntax rules. If the code fails to prove its language syntax format, then the compiler will throw an error.

Error in the code:

The operator “++” cannot be applied to a reference.  Use front = front.next;

Correct statement:

/*removing the element from front by moving front to the next node.*/

front= front.next;

Corrected code:

//A linked implementation of a queue

int dequeue()

{

    //checks whether the queue is empty

    if(empty())

/*throws exception EmptyQueueException indicating the queue is empty*/

        throw new EmptyQueueException();

    /*if the queue is not empty then,

    front element is reserved to a variable*/

    int value= front...

Blurred answer
Students have asked these similar questions
Find the output of the following program code if the following values have been inserted into abcQ: 1 2 4 5
Find the error in each of the following code segments // A linked implementation of a queue int dequeue() { if(empty()) throw new EmptyQueueException(); int value = front.value; front ++; return value; }
In linked list implementation of a queue, the important condition for a queue to be empty is? a) FRONT is null  b) REAR is null  c) LINK is empty  d) FRONT == REAR-1
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education