# Project #39091 - Data Structures Java

This is a 2 Part Homework Assignment. Please approach both parts as separate programs that need to be build.

Write the below program is Java.

Also - solution can be easily found online but you need to use different algorithm. Teacher will catch that.

PART 1 PART 1 PART 1 PART 1 PART 1

PART 2 PART 2 PART 2 PART 2 PART 2

Question 1

Consider a polynomial with integer coefficients and positive integer exponents P(x) = a0 * x0  + a1 * x1 + ... + an-1 * xn-1. Consider the problem of calculating the polynomial value for an integer value of its variable x. For example, if the polynomial is P(x) = 2 * x3 - 5 * x2 + 6 * x1 + 8 * x0 and the integer value is x = 2 than the value of P(2) is 16.

a)
Design and write the methods calculateBruteForce and calculateHorner for calculating the polynomial value by using the brute force approach and respectively Horner's technique. ForcalculateBruteForce method, define and invoke your own defined method for raising x to a given power, instead of calling a predefined method such as the Math.pow().
By analyzing the code, determine and indicate the complexity of the two methods in terms of Big-O notation. Which of the two methods would perform better in terms of execution time?

b)
Write a driver program TestPolyVal.java to validate the conclusions drawn from question a). Consider a polynomial with 20 terms whose coefficients are stored in an integer array and are randomly generated in the interval 1 .. 99. In the array of coefficients, the array cell of index i corresponds to the polynomial coefficient ai, while i represents the exponent of the variable x. Implement the following actions:
(b1) Invoke the two methods and display the polynomial value returned by the methods for a random generated integer value in the interval 1 .. 9.
(b2) Measure and display the execution time of the two methods as the arithmetic mean value of 100 executions. Use the method System.nanoTime() for determining the execution time. Discuss the obtained results. Are the results in line with your answer to question a?
Note. Due to the behavior of the JIT compiler, the execution time of the repeated programs is much slower the first times they are run and therefore make sure to discard the measured values for the initial 5 runs.

Question 2

Consider the text file Question2.txt

Design, write and test a java program TextProcessing.java doing the following tasks.

a)
Store all input file words (including the duplicated words) larger than 3 characters in an appropriate JCF data structure ds1. Give reason for your option. Display ds1 content.

b)
Remove all duplicated words from ds1 and store the remaining non-duplicated words in an appropriate, unsorted JCF data structure ds2. Word order in ds2 should be the same as in ds1. Give reason for your option. Display ds2 content. For example, if ds1 contains: alpha, theta, epsilon, theta, beta, gamma, theta, gamma then ds2 should contain:  alpha, theta, epsilon, beta, gamma.

c)
Sort ds2 words in lexicographical order and store the sorted words in an appropriate JCF data structure ds3. Give reason for your option. Display ds3 content.

Submission requirements

Submit the following before the due date listed in the Calendar:

1.TestPolyVal.java and TextProcessing.java source files.
2. A document file containing: (2.1) a short question(s) analysis, (2.2) design decisions and assumptions, (2.3) test cases and two relevant screenshots, (2.4) error handling, (2.5) lessons learned and (2.6) possible improvements. The size of the document file (including the screenshots) should be of two pages, single spaced, font size 12.

Submit the following before the due date listed in the Calendar:

1.TestPolyVal.java and TextProcessing.java source files.
2. A document file containing: (2.1) a short question(s) analysis, (2.2) design decisions and assumptions, (2.3) test cases and two relevant screenshots, (2.4) error handling, (2.5) lessons learned and (2.6) possible improvements. The size of the document file (including the screenshots) should be of two pages, single spaced, font size 12.

## Rubric Name: Assessment Rubric for Projects and Assignments

Attribute Does not Meet Meets 14 points (0-14 points) Rarely employs Modularity (including proper use of parameters, use of local variables etc.) Rarely employs correct & appropriate use of programming structures (loops, conditionals, classes etc.) Poorly structured and inefficient algorithms Rarely uses good object-oriented design 17 points (15-17 points) Employs Modularity (including proper use of parameters, use of local variables etc.) some of the time Employs correct & appropriate use of programming structures (loops, conditionals, classes etc.) some of the time Efficient algorithms used some of the time Good use of object-oriented design 20 points (18-20 points) Employs Modularity (including proper use of parameters, use of local variables etc.) most of the time Employs correct & appropriate use of programming structures (loops, conditionals, classes etc.) most of the time Efficient algorithms used most of the time Excellent use of object-oriented design 28 points (0-28 points) Program does not fulfill functionality Few requirements were fulfilled 35 points (29-35 points) Program fulfills most functionality Most requirements were fulfilled 40 points (36-40 points) Program fulfills all functionality All requirements were fulfilled Extra effort was apparent 14 points (0-14 points) No test plan included 17 points (15-17 points) Good test plan included 20 points (18-20 points) Comprehensive test plan 14 points (0-14 points) No comments No lessons learned No possible improvements No approach discussion 17 points (15-17 points) Good comments Some lessons learned Some possible improvements included Some approach discussion 20 points (18-20 points) Excellent comments Comprehensive lessons learned Excellent possible improvements included Excellent approach discussion and references

 Subject Computer Due By (Pacific Time) 09/05/2014 12:00 am
TutorRating
pallavi

Chat Now!

out of 1971 reviews
amosmm

Chat Now!

out of 766 reviews
PhyzKyd

Chat Now!

out of 1164 reviews
rajdeep77

Chat Now!

out of 721 reviews
sctys

Chat Now!

out of 1600 reviews

Chat Now!

out of 770 reviews
topnotcher

Chat Now!

out of 766 reviews
XXXIAO

Chat Now!

out of 680 reviews