bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 8, Problem 47CRP

Explanation of Solution

Define an abstract data type that represents a queue using Java class syntax:

Abstract data type is used to store the data in a structure and provides different method to manipulate the data stored.

// The interface is created using the following method

interface queueADT

{

// Declare a method insert()

public void insert(int data);

// Declare a method delete()

public void delete();

// Declare a method getfront()

public int getfront ();

// Declare a method isempty()

public Boolean isempty()

}

// Interface is implemented by defining the class namelist

class queue implements queueADT

{

// Declare an array list

private int[] list;

// Declare a variable front

private int front;

// Declare a variable rear

private int rear;

// Declare a variable size

private int size;

// Definition of constructor

public queue()

{

// Initialize size is equal to 0

size = 0;

// Initialize rear is equal to 0

rear = 0;

// Initialize front is equal to 0

front = 0;

}

// Definition of insert() method

public void insert(int data)

{

// Assingn value to the list

list[rear]=data;

// Increment the rear

rear++;

// Increment the size

size++;

}

// Definition of delete() method

public void delete()

{

// Check the the value is empty

if(isempty())

{

// Return

return;

}

// Otherwise add the values to the list

for(int i=front; i<rear-1; i++)

{

// Assign the value to the list

list[i] = list [i+1]

}

// Decrement rear

rear--;

// Decrement size

size--;

}

// Definition of getfront() method

public int getfront()

{

// Check the value is empty

if(isempty())

{

// Return

return-1;

}

// Return the front value

return list[front]

}

// Definition of isempty() method

public Boolean isempty()

{

// Check size is equal to 0

if(size==0)

// Return true

return true;

// Otherwise

else

// Return false

return false;

}

// Definition of display() method

public void display()

{

// For loop to print the list using queue

for(int i=front;i<rear;i++)

{

// Print the list

System...

Blurred answer
Students have asked these similar questions
You are tasked with developing a portable system that can be worn to collect health and fitness data. The challenge is to integrate all functions into the smaller form of an ear clip. The device should include heart rate, movement and temperature sensor and wireless communication with a mobile app. Draw a diagram- hardware architecture of the system- including the selection of suitable sensors, communication modules, and an energy-efficient microcontroller. (visualize the components and their connections)
Draw out an example of 3 systems using Lamport’s logical clock and explain the steps in words.
"Systems have become very powerful and sophisticated, providing quality information fordecisions that enable the firm to coordinate both internally and externally."With reference to the above statement compare the operations of any three data gatheringsystems today’s organisations use to aid decision making.

Chapter 8 Solutions

Computer Science: An Overview (13th Edition) (What's New in Computer Science)

Chapter 8.3, Problem 3QE Chapter 8.3, Problem 4QE Chapter 8.3, Problem 5QE Chapter 8.3, Problem 7QE Chapter 8.3, Problem 8QE Chapter 8.3, Problem 9QE Chapter 8.4, Problem 1QE Chapter 8.4, Problem 2QE Chapter 8.4, Problem 3QE Chapter 8.4, Problem 4QE Chapter 8.5, Problem 1QE Chapter 8.5, Problem 3QE Chapter 8.5, Problem 4QE Chapter 8.6, Problem 1QE Chapter 8.6, Problem 2QE Chapter 8.6, Problem 3QE Chapter 8.7, Problem 1QE Chapter 8.7, Problem 2QE Chapter 8.7, Problem 3QE Chapter 8.7, Problem 4QE Chapter 8, Problem 1CRP Chapter 8, Problem 2CRP Chapter 8, Problem 3CRP Chapter 8, Problem 4CRP Chapter 8, Problem 5CRP Chapter 8, Problem 6CRP Chapter 8, Problem 7CRP Chapter 8, Problem 8CRP Chapter 8, Problem 9CRP Chapter 8, Problem 10CRP Chapter 8, Problem 11CRP Chapter 8, Problem 12CRP Chapter 8, Problem 13CRP Chapter 8, Problem 14CRP Chapter 8, Problem 15CRP Chapter 8, Problem 16CRP Chapter 8, Problem 17CRP Chapter 8, Problem 18CRP Chapter 8, Problem 19CRP Chapter 8, Problem 20CRP Chapter 8, Problem 21CRP Chapter 8, Problem 22CRP Chapter 8, Problem 23CRP Chapter 8, Problem 24CRP Chapter 8, Problem 25CRP Chapter 8, Problem 26CRP Chapter 8, Problem 27CRP Chapter 8, Problem 28CRP Chapter 8, Problem 29CRP Chapter 8, Problem 30CRP Chapter 8, Problem 31CRP Chapter 8, Problem 32CRP Chapter 8, Problem 33CRP Chapter 8, Problem 34CRP Chapter 8, Problem 35CRP Chapter 8, Problem 36CRP Chapter 8, Problem 37CRP Chapter 8, Problem 38CRP Chapter 8, Problem 39CRP Chapter 8, Problem 40CRP Chapter 8, Problem 41CRP Chapter 8, Problem 42CRP Chapter 8, Problem 43CRP Chapter 8, Problem 44CRP Chapter 8, Problem 45CRP Chapter 8, Problem 46CRP Chapter 8, Problem 47CRP Chapter 8, Problem 48CRP Chapter 8, Problem 49CRP Chapter 8, Problem 51CRP Chapter 8, Problem 52CRP Chapter 8, Problem 53CRP Chapter 8, Problem 54CRP Chapter 8, Problem 55CRP Chapter 8, Problem 1SI Chapter 8, Problem 2SI Chapter 8, Problem 3SI Chapter 8, Problem 4SI Chapter 8, Problem 5SI Chapter 8, Problem 6SI Chapter 8, Problem 7SI Chapter 8, Problem 8SI

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
An array is defined as a group that consists of similar data types. The array size must be specified by an "int...

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

The functions performed by the flutes on a standard twist drill.

Degarmo's Materials And Processes In Manufacturing

The magnitude of the resultant force, FR . The coordinate direction angles, (α,β, and γ) .

INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)

Knowledge Booster
Background pattern image
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
    C++ Programming: From Problem Analysis to Program...
    Computer Science
    ISBN:9781337102087
    Author:D. S. Malik
    Publisher:Cengage Learning
    Text book image
    Systems Architecture
    Computer Science
    ISBN:9781305080195
    Author:Stephen D. Burd
    Publisher:Cengage Learning
    Text book image
    New Perspectives on HTML5, CSS3, and JavaScript
    Computer Science
    ISBN:9781305503922
    Author:Patrick M. Carey
    Publisher:Cengage Learning
    Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    C++ for Engineers and Scientists
    Computer Science
    ISBN:9781133187844
    Author:Bronson, Gary J.
    Publisher:Course Technology Ptr
    Text book image
    CMPTR
    Computer Science
    ISBN:9781337681872
    Author:PINARD
    Publisher:Cengage
    Computer Fundamentals - Basics for Beginners; Author: Geek's Lesson;https://www.youtube.com/watch?v=eEo_aacpwCw; License: Standard YouTube License, CC-BY