Question: it says here static so it as user , so only i will call the methods public class Node { public T data; public Node

it says here static so it as user , so only iit says here static so it as user , so only i will call the methods

public class Node {

public T data;

public Node next;

public Node() {

data = null;

next = null;

}

public Node(T val) {

data = val;

next = null;

}

// Setters/Getters?

}

public class LinkedQueue implements Queue{

private Node head, tail;

private int size;

/** Creates a new instance of LinkedQueue */

public LinkedQueue() {

head = tail = null;

size = 0;

}

public boolean full() {

return false;

}

public int length (){

return size;

}

public void enqueue(T e) {

if(tail == null){

head = tail = new Node(e);

}

else {

tail.next = new Node(e);

tail = tail.next;

}

size++;

}

public T serve() {

T x = head.data;

head = head.next;

size--;

if(size == 0)

tail = null;

return x;

}

}

4. Write the method public static boolean isPalindrome (Queue ) (user of ADT) that takes as input a queue and returns true if the queue is palindrome false otherwise. The queue should remain unchanged after calling this method The space complexity of the method must be O(1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!