Question: 1. java code for a Queue class (with all the standard queue methods) using a singly linked list. Assume that the enqueue(), dequeue() and peek()
1. java code for a Queue class (with all the standard queue methods) using a singly linked list. Assume that the enqueue(), dequeue() and peek() methods are never called on a queue of size less than two. include the runtime of each method.
public class Queue{
private Node head;
private Node tail;
private int size;
public Queue{
head = null;
tail = null;
size = 0;
public void enqueue(int value){
public int dequeue(){
private int size(){
private boolean isEmpty(){
private int front(){
2.java code for a stack class for zebbs(zebb objects-instances of a class called zebb) with all the standard stack methods using an array. include a field declarations and a constructor. Assume pop() and peek() methods are not called on an empty stack. Also assume that you know the maximum number of elements ever needed to be held in the stack. Include the runtime of each method.
public class Stack{
//declare your fields (private) here
private zebb zStack[];
private int top;
public Stack (int max){
public void push(zebb z){
public zebb pop(){
public zebb peek(){
public boolean isEmpty(){
public int size(){
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
