Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement MyLinkedStack (constructor, push, pop, peek and isEmpty) and MyLinkedQueue using head,tail variables(constructor, offer, poll, peek and isEmpty), and write the following two program to

Implement MyLinkedStack (constructor, push, pop, peek and isEmpty) and MyLinkedQueue using head,tail variables(constructor, offer, poll, peek and isEmpty), and write the following two program to test them. For stack testing, write a program to check if a string has matching parenthesis such as (()), but not )(. For stack testing, use it to Evaluating Expressions Phase 1: Scanning the expression The program scans the expression from left to right to extract operands, operators, and the parentheses. 1.1. If the extracted item is an operand, push it to operandStack. 1.2. If the extracted item is a + or - operator, process all the operators at the top of operatorStack and push the extracted operator to operatorStack. 1.3. If the extracted item is a * or / operator, process the * or / operators at the top of operatorStack and push the extracted operator to operatorStack. 1.4. If the extracted item is a ( symbol, push it to operatorStack. 1.5. If the extracted item is a ) symbol, repeatedly process the operators from the top of operatorStack until seeing the ( symbol on the stack. Phase 2: Clearing the stack Repeatedly process the operators from the top of operatorStack until operatorStack is empty.

Bonus:

support for exponent ^ and use HashMap for counting keyword occurrence in a

Java program.

=================================================================================

Heres some code already

import java.util.Queue;

public class MyLinkedQueue {

private class QueueNode

{

private QueueNode head;

private QueueNode tail;

}

QueueNode head,tail;

MyLinkedQueue()

{}

MyLinkedQueue(E [] objects)

{

for (E e:objects)

offer(e);

}

public E poll()

{

return null;

}

public E peek()

{

return ;

}

public void offer(E e)

{

}

public boolean isEmpty()

{

if(head == null)

return true;

else return false;

}

}

=====================================================================================

Just need help filling that in and then MyLinkedStack

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago