SWE 510: Object-Oriented Programming in Java

FAll 2010
Muhammad Abdulla
General Information | Textbooks | Schedule & Notes | Projects | Policies
Homework 4
Due: 11:59 PM, Dec. 2, 2010 
Reminders: Follow the submission instructions. Remember to comment your code!

Total Points: 100

0) Permutation (40 points)

   In this assignment, you will write a program that generates all the permutations
   of an input string using recursion. A couple of examples are shown below:

   $ java Permute abc
   abc
   acb
   bac
   bca
   cab
   cba

   $ java Permute Zx#x 
   Zx#x
   Zxx#
   Z#xx
   Z#xx
   Zxx#
   Zx#x
   xZ#x
   xZx#
   x#Zx
   x#xZ
   xxZ#
   xx#Z
   #Zxx
   #Zxx
   #xZx
   #xxZ
   #xZx
   #xxZ
   xZx#
   xZ#x
   xxZ#
   xx#Z
   x#Zx
   x#xZ

   As show in the example above, duplicate letters are treated as separate.
   In other words, the permutation program treats characters in the input
   string based on their positions only and two duplicate characters are
   treated as if they are different. No specific assumptions are to be made
   regarding the case and types of the input characters.


1) Word Frequency Counter (60 points)

   Write a program that calculates the frequency of words in the input. The
   program should calculate how many times each unique word appears in the
   input, and should print the words in the order of decreasing frequency.
   If two words have the same frequency, then alphabetical order is used.
   Assuming that a file, "input.txt", contains the following text:

   this is a line. 
   this is another line.
   line after line.

   $ java Frequency input.txt
   line 4
   is 2
   this 2
   a 1
   after 1
   another 1

   If no input file is given, standard input is used. If multile file names
   are given, all files should be processed together as if they are one big,
   single input. Words are case insensitive. 

   
Date & Time
bullet
bullet (EST)
What is New?
Valid W3C XHTML
© 2008-2010 Muhammad Abdulla
Last Modified: January 15, 2010