Code:
public class BinaryTree
{
//Definition of the node
protected class BinaryTreeNode
{
DataElement info;
BinaryTreeNode llink;
public class BinaryTree
{
//Definition of the node
protected class BinaryTreeNode
{
DataElement info;
BinaryTreeNode llink;
public abstract class ArrayListClass
{
protected int length; //to store the length of the list
protected int maxSize; //to store the maximum size of the list
protected DataElement[] list; //array to hold the list elements
//Default constructor
//Creates an array of size 100
//Postcondition: list points
public class OrderedArrayList extends ArrayListClass
{
//default constructor
public OrderedArrayList()
{
super();
}
//constructor with a parameter
public OrderedArrayList(int size)
{
super(size);
}
public class OrderedArrayList extends ArrayListClass
{
//default constructor
public OrderedArrayList()
{
super();
}
//constructor with a parameter
public OrderedArrayList(int size)
{
super(size);
}
//copy constructor
public OrderedArrayList(OrderedArrayList
public abstract class ArrayListClass
{
protected int length; //to store the length of the list
protected int maxSize; //to store the maximum size of the list
protected DataElement[] list; //array to hold the list elements
//Default constructor
/Method to make a copy of otherQueue.
//Postcondition: A copy of otherQueue is created and
// assigned to this queue.
public void copyQueue(LinkedQueueClass otherQueue)
//copy constructor
public LinkedQueueClass(LinkedQueueClass otherQueue)
{
queueFront = otherQueue.queueFront;
queueRear = otherQueue.queueRear;
}//end copy constructor
Method to make a copy of otherQueue.
//Postcondition: A copy of otherQueue is created and
public abstract class DataElement
{
public abstract boolean equals(DataElement otherElement);
//Method to determine whether two objects contain the
//same data.
//Postcondition: Returns true if this object
public class LinkedQueueClass1
{
//Definition of the node
protected class QueueNode
{
DataElement info;
QueueNode link;
}
private QueueNode queueFront; //reference variable to the
//first element of the queue
private QueueNode queueRear; //reference variable
This is my default constructor method
//default constructor
public LinkedQueueClass()
{
queueFront = null;
queueRear = null;
}
//How about making use of the size of the stack
public boolean equalStack(StackClass otherStack) {
if (getSize() != otherStack.getSize()) { //if stack lengths are not equal return false
return false;
}
else {
while(!isEmpty()) {
if(top().compareTo(otherStack.top()) != 0) {
return false;
}
else {
try {
pop();
public class StackClass
{
private int maxStackSize; //variable to store the maximum
//stack size
private int stackTop; //variable to point to the top
//of the stack
private DataElement[] list; //array of reference variables
public abstract class DataElement
{
public abstract boolean equals(DataElement otherElement);
//Method to determine whether two objects contain the
//same data.
//Postcondition: Returns true if this object contains the
// same data as the object otherElement;
// otherwise, it returns false.
public abstract int
Leave a comment: