Question
Simple 3 part java program: Part 1: Implement a generic one-way linked list. That is, each node only knows about the next node. Name it
Simple 3 part java program:
Part 1:
Implement a generic one-way linked list. That is, each node only knows about the next node. Name it SinglyLinkedList. Your linked list can have head and tail to keep track of the two ends of the list. Typically, you may want to have a private member variable to keep track of the lists size. Your SinglyLinkedList must implement the Iterable interface, and you will need to write an inner class named SinglyLinkedListIterator that must implement the Iterator interface. It is recommended that you also have a generic inner class named Node that represents an element in the linked-list.
linked list must provide the following methods, in addition to any other methods you want: public void add(AnyType element), public void insertAt(AnyType element, int index), public void remove(AnyType element), public void clear(), public boolean isEmpty(), public int size(), public AnyType getNthFromFirst(int n), public AnyType getNthFromLast(int n), public SinglyLinkedListIterator iterator(), public String toString(), public boolean hasNext() ,public AnyType next() , public void remove()
Part 2:
Implement your own Stack class using linked list. Class description as follows i) Define generic class MyStack ii) Define Constructor iii) Define the following methods a. T pop ( ) b. push (T value) c. boolean isEmpty()
Part 3:
Using the above implemented MyStack class implement the infix to postfix conversion. This will simply take an infix notation string and output the postfix expression. Sample Input: a+b*(c-d) Sample Output: a b c d - * +
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started