Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// getty.txt Four score and seven years ago our fathers brought forth, upon this continent, a new nation, conceived in liberty, and dedicated to the

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

// getty.txt

Four score and seven years ago our fathers brought forth, upon this continent, a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation, so conceived, and so dedicated, can long endure. We are met here on a great battlefield of that war. We have come to dedicate a portion of it as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But in a larger sense we can not dedicate - we can not consecrate - we can not hallow this ground. The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note, nor long remember, what we say here, but can never forget what they did here. It is for us, the living, rather to be dedicated here to the unfinished work which they have, thus far, so nobly carried on. It is rather for us to be here dedicated to the great task remaining before us that from these honored dead we take increased devotion to that cause for which they here gave the last full measure of devotion - that we here highly resolve that these dead shall not have died in vain; that this nation shall have a new birth of freedom; and that this government of the people, by the people, for the people, shall not perish from the earth.

// This is what was given

// ObjectTreeNode.java

public class ObjectTreeNode { private Object info; private ObjectTreeNode left; private ObjectTreeNode right; public ObjectTreeNode() { info = null; left = null; right = null; } public ObjectTreeNode (Object o) { info = o; left = null; right = null; } public void setInfo(Object o) { info = o; } public Object getInfo() { return info; } public void setLeft(ObjectTreeNode p) { left = p; } public ObjectTreeNode getLeft() { return left; } public void setRight(ObjectTreeNode p) { right = p; } public ObjectTreeNode getRight() { return right; } }

// ObjectBinaryTree class

public class ObjectBinaryTree { private ObjectTreeNode root; public ObjectBinaryTree() { root = null; } public ObjectTreeNode getRoot() { return root; } public void setLeftChild(ObjectTreeNode parent, ObjectTreeNode r) { if (parent == null || parent.getLeft() != null) { System.out.println("Runtime Error: setLeftChild()"); System.exit(1); } parent.setLeft(r); } public void setRightChild(ObjectTreeNode parent, ObjectTreeNode r){ if (parent == null || parent.getRight() != null) { System.out.println("Runtime Error: setRightChild()"); System.exit(1); } parent.setRight(r); }

public void insertBST(Object o) { ObjectTreeNode p, q; ObjectTreeNode r = new ObjectTreeNode(o); if (root == null) root = r; else { p = root; q = root; while (q != null) { p = q; if (((TreeComparable)(r.getInfo())).compareTo((TreeComparable)(p.getInfo()))

public void insertBSTDup(Object o) { ObjectTreeNode p, q; ObjectTreeNode r = new ObjectTreeNode(o); if (root == null) root = r; else { p = root; q = root; while (q != null && ((TreeComparable)(r.getInfo())).compareTo((TreeComparable)(p.getInfo())) != 0) { p = q; if (((TreeComparable)(r.getInfo())).compareTo((TreeComparable)(p.getInfo())) 0) setRightChild(p, r); else ((TreeComparable)(p.getInfo())).operate((TreeComparable)(r.getInfo())); } }

public ObjectTreeNode searchBST(Object o) { ObjectTreeNode p; ObjectTreeNode r = new ObjectTreeNode(o); if(root != null) { p = root; while (p != null) { if (((TreeComparable)(r.getInfo())).compareTo((TreeComparable)(p.getInfo())) 0) p = p.getRight(); else return p; } } return null; }

public void preTrav(ObjectTreeNode tree) { if (tree != null) { ((TreeComparable)tree.getInfo()).visit(); preTrav(tree.getLeft()); preTrav(tree.getRight()); } } public void inTrav(ObjectTreeNode tree) { if (tree != null) { inTrav(tree.getLeft()); ((TreeComparable)tree.getInfo()).visit(); inTrav(tree.getRight()); } } public void postTrav(ObjectTreeNode tree) { if (tree != null) { postTrav(tree.getLeft()); postTrav(tree.getRight()); ((TreeComparable)tree.getInfo()).visit(); } }

public void delete(Object o) { ObjectTreeNode s, t, v; boolean found = false; ObjectTreeNode r = new ObjectTreeNode(o); ObjectTreeNode p = root; ObjectTreeNode q = null; // Search for the node with info key, set p to point to that node and set q to point to its parent, if any. while (p != null && !found) { if (((TreeComparable)(r.getInfo())).compareTo((TreeComparable)(p.getInfo())) == 0) found = true; else { q = p; if (((TreeComparable)(r.getInfo())).compareTo((TreeComparable)(p.getInfo()))

// Driver class - can modify if needed

public class Driver {

public static void main(String[] args) throws IOException {

PrintWriter pw = new PrintWriter(new FileWriter("csis.txt"));

Xref foo = new Xref(pw);

Hash hash = new Hash(pw);

hash.getHashTable();

hash.printHashTable();

foo.getInfo();

foo.traverse();

foo.query();

pw.flush();

pw.close();

}

}

r Lab: Binary Tree and Hashing s are programs that search webpages for specified keyword Web search engines relevant webpages where the keywords were found picking the Ose The Col for a search engine works the same way as a book's index. The nd returns a list of for search engines are mat which webpages match a and returns a li tching and ranking. The matching phase query and the ranking phase determines main tasks . The two matches. Note that search queries can prod usamost relevant results (ranking) or millions of hits (matches) and a search engine must be capable of uce nt of an index is the most fundamental idea behind any search engine concept of a page number index by first The inde f the book are now webpages and search engines assign a different pages er to every single page on the web. The search engine builds up an tmaking a list of all the words that appear in any page, making a ge number in which each word appears, and then sorts that list in l order. So if a query is made on the word "computer", the search alo ecan quickly jump to the entry for "computer in the word list and extract the pages for that entry ther than build an index for webpages, this lab will build an index, or a cross- nce listing, for text-based documents. The lab will display the number of each word appears in the document, the line numbers in which each word and the position of each word in the line. The lab will also allow us to the document for specific words and will display the number of times the ears in the document, the line numbers in which the word appears and word app the position of the word in the line At the outset we do not know how many different words are in the text, nor do we know in how many different lines a word may appear. Our approach will be to use an object binary search tree whose nodes provide for the following fields: a Word object two references to the left and right children of the current node Note that while the ObjectTreeMode class is built to hold a generic object, yourll be creating a Word class whose objects will be placed in the bjectTreeNodes of the object binary search tree. r Lab: Binary Tree and Hashing s are programs that search webpages for specified keyword Web search engines relevant webpages where the keywords were found picking the Ose The Col for a search engine works the same way as a book's index. The nd returns a list of for search engines are mat which webpages match a and returns a li tching and ranking. The matching phase query and the ranking phase determines main tasks . The two matches. Note that search queries can prod usamost relevant results (ranking) or millions of hits (matches) and a search engine must be capable of uce nt of an index is the most fundamental idea behind any search engine concept of a page number index by first The inde f the book are now webpages and search engines assign a different pages er to every single page on the web. The search engine builds up an tmaking a list of all the words that appear in any page, making a ge number in which each word appears, and then sorts that list in l order. So if a query is made on the word "computer", the search alo ecan quickly jump to the entry for "computer in the word list and extract the pages for that entry ther than build an index for webpages, this lab will build an index, or a cross- nce listing, for text-based documents. The lab will display the number of each word appears in the document, the line numbers in which each word and the position of each word in the line. The lab will also allow us to the document for specific words and will display the number of times the ears in the document, the line numbers in which the word appears and word app the position of the word in the line At the outset we do not know how many different words are in the text, nor do we know in how many different lines a word may appear. Our approach will be to use an object binary search tree whose nodes provide for the following fields: a Word object two references to the left and right children of the current node Note that while the ObjectTreeMode class is built to hold a generic object, yourll be creating a Word class whose objects will be placed in the bjectTreeNodes of the object binary search tree

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_2

Step: 3

blur-text-image_3

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

l Describe the development process.

Answered: 1 week ago

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago