Categories: Homework Aiders

Priority Queues Interface Implementation Lab 11 Assignment Include word file containing all the required files with the code. Also include test files and t

Priority Queues Interface Implementation Lab 11 Assignment Include word file containing all the required files with the code. Also include test files and their results. Follow the file attached to complete. //————————————————————————// RefSortedList.java
by Dale/Joyce/Weems
Chapter 6
//
// Implements the ListInterface using a linked list. It is kept in increasing
// order as defined by the compareTo method of the added elements. Only
// Comparable elements may be added to a list.
//
// Null elements are not permitted on a list.
//
// One constructor is provided, one that creates an empty list.
//—————————————————————————package ch06.lists;
import support.LLNode;
public class RefSortedList
extends RefUnsortedList
implements ListInterface
{
public RefSortedList()
{
super();
}
public void add(T element)
// Adds element to this list.
{
LLNode prevLoc;
// trailing reference
LLNode location;
// traveling reference
T listElement;
// current list element being compared
// Set up search for insertion point.
location = list;
prevLoc = null;
// Find insertion point.
while (location != null)
{
listElement = location.getInfo();
if (listElement.compareTo(element) < 0) // list element < add element { prevLoc = location; location = location.getLink(); } else break; } // Prepare node for insertion. LLNode newNode = new LLNode(element); // Insert node into list. if (prevLoc == null) { // Insert as first node. newNode.setLink(list); list = newNode; } else { // Insert elsewhere. newNode.setLink(location); prevLoc.setLink(newNode); } numElements++; } } //---------------------------------------------------------------------------// BinarySearchTree.java by Dale/Joyce/Weems Chapter 8 // // Defines all constructs for a reference-based BST //---------------------------------------------------------------------------package ch08.trees; import ch05.queues.*; import ch03.stacks.*; import support.BSTNode; public class BinarySearchTree implements BSTInterface { protected BSTNode root; // reference to the root of this BST boolean found; // used by remove // for traversals protected LinkedUnbndQueue inOrderQueue; // queue of info protected LinkedUnbndQueue preOrderQueue; // queue of info protected LinkedUnbndQueue postOrderQueue; // queue of info public BinarySearchTree() // Creates an empty BST object. { root = null; } public boolean isEmpty() // Returns true if this BST is empty; otherwise, returns false. { return (root == null); } private int recSize(BSTNode tree) // Returns the number of elements in tree. { if (tree == null) return 0; else return recSize(tree.getLeft()) + recSize(tree.getRight()) + 1; } public int size() // Returns the number of elements in this BST. { return recSize(root); } public int size2() // Returns the number of elements in this BST. { int count = 0; if (root != null) { LinkedStack hold = new LinkedStack(); BSTNode currNode; hold.push(root); while (!hold.isEmpty()) { currNode = hold.top(); hold.pop(); count++; if (currNode.getLeft() != null) hold.push(currNode.getLeft()); if (currNode.getRight() != null) hold.push(currNode.getRight()); } } return count; } private boolean recContains(T element, BSTNode tree) // Returns true if tree contains an element e such that // e.compareTo(element) == 0; otherwise, returns false. { if (tree == null) return false; // element is not found else if (element.compareTo(tree.getInfo()) < 0) return recContains(element, tree.getLeft()); // Search left subtree else if (element.compareTo(tree.getInfo()) > 0)
return recContains(element, tree.getRight()); // Search right subtree
else
return true;
// element is found
}
public boolean contains (T element)
// Returns true if this BST contains an element e such that
// e.compareTo(element) == 0; otherwise, returns false.
{
return recContains(element, root);
}
private T recGet(T element, BSTNode tree)
// Returns an element e from tree such that e.compareTo(element) == 0;
// if no such element exists, returns null.
{
if (tree == null)
return null;
// element is not found
else if (element.compareTo(tree.getInfo()) < 0) return recGet(element, tree.getLeft()); // get from left subtree else if (element.compareTo(tree.getInfo()) > 0)
return recGet(element, tree.getRight());
// get from right subtree
else
return tree.getInfo(); // element is found
}
public T get(T element)
// Returns an element e from this BST such that e.compareTo(element) == 0;
// if no such element exists, returns null.
{
return recGet(element, root);
}
private BSTNode recAdd(T element, BSTNode tree)
// Adds element to tree; tree retains its BST property.
{
if (tree == null)
// Addition place found
tree = new BSTNode(element);
else if (element.compareTo(tree.getInfo())
Purchase answer to see full
attachment

Don't use plagiarized sources. Get Your Custom Essay on
Priority Queues Interface Implementation Lab 11 Assignment Include word file containing all the required files with the code. Also include test files and t
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT! Just from $10/Page
Order Essay
superadmin

Share
Published by
superadmin

Recent Posts

communication MA | Solution Aider

part one For this assignment you are to to watch: Shattered Glass Write a two…

3 years ago

Standard Project – WebServers | Solution Aider

Standard Project - WebServers. Instruction attached. Need all requirements, you do not have to make…

3 years ago

Discussion post 2 | Solution Aider

Read classmates post and respond with 100 words:The International Categorization of Diseases, Tenth Revision, Clinical…

3 years ago

case sttudy | Solution Aider

Most Americans have at least 1 issue that is most important to them. Economic issues…

3 years ago

Methodologies Report | Solution Aider

For this assignment, you are the court intake processor at a federal court where you…

3 years ago

outline about gender equality | Solution Aider

Use a standard outline format to lay out how you are going to write your…

3 years ago