Lab 8 Solution

$30.00

Category: Tag:

Description

Problem 1. (Tree Traversal) Implement the methods preOrder(), inOrder(), postOrder(), and levelOrder() in TreeTraversal that return the an iterable object containing nodes of a binary tree traversed in pre-, in-, post-, and level-order, respectively.

$ java T r e e T r a v e r s a l

FBGADICEH

< ctrl -d >

Pre – order : F B A D C E G I H

In – order : A B C D E F G H I

Post – order : A C E D B H I G F

Level – order : F B G A D I C E H

Problem 2. (Spell Checker) Write a program Spell that takes a command-line argument specifying the name of the le containing common misspellings (a line-oriented le with each comma-separated line containing a misspelled word and the correct spelling), then reads text from standard input and prints out the misspelled words in the text along with the line numbers where they occurred and their correct spellings. Use the given SeparateChainingHashST implementation to store the misspellings and their corrections. Just for fun, compare the performance of Spell using other implementations of the symbol table API, such as RedBlackBST and LinearProbingHashST.

  • java Spell m i s s p e l l i n g s . txt < w a r _ a n d _ p e a c e . txt u n c o n c i o u s n e s s :16122 -> u n c o n s c i o u s n e s s

leaded :21907 -> led wont :39087 -> won ’ t wont :50591 -> won ’ t Ukranian :58064 -> U kr ai ni an wont :59650 -> won ’ t

c o n c i o u s n e s s :59835 -> c o n s c i o u s n e s s occuring :59928 -> o cc ur ri ng

Files to Submit:

  1. TreeTraversal.java

  1. Spell.java

Spring 2015 1 of 1


error: Content is protected !!