Description
Lab 2
1) Stacks. Array and linked list implementation of stacks.
Download the archive Lab2.zipand extract subdirectory stack with the stack implementation
contained in the following files
Stack.java
Node.java
NodeStack.java
ArrayStack.java
StackEmptyException.java
FullStackException.java
The archive also contains the files tryStack1.javaand tryStack2.java
Compile tryStack1and run it
Compile tryStack2and run it
2) Doubly Linked Lists in Java
Extract the subdirectory dLinkListfrom the archive Lab2.zipwith the implementation of the
doubly-linked list contained in the following files.
ListNode.java
DLinkedList.java
In DLinkedList.javaimplement the following methods:
InsertNode(ListNode nNode, ListNode pAfter)
inserts the node nNodeafter node pAfterin the current list
RemoveNode(ListNode nNode)
removes node nNodefrom current list
Compile TestDLinkedList.javaand run it
3) Checking Balanced Brackets in Expressions with Stacks
Extract the subdirectory balancefrom the archive Lab2.zipwith the implementation of the stack
ADT with an array list contained in the following files:
Stack.java
ArrayStack.java
StackEmptyException.java
StackFullException.java
The archive also contains the file bracketsBalance.javain which you should implement the
following method:
boolean bBalance (String exp)
that evaluates expfor balanced brackets and returns true(if balanced) and false
otherwise
use the stack implementation in ArrayStack.java.
Compile bracketsBalance.javaand run it with different expressions