Assignment 1 ASSIGNMENT 1 Assignment 1 tests your knowledge of Recursion (Chapter 18), List, Stacks, Queues, and Priority Queues (Chapter 20) and Sets and Maps (chapter 21). Design a...

1 answer below »
eveything will be on the fileplease after doing it , can you explain me the process so that i can do it in my turn


Assignment 1 ASSIGNMENT 1 Assignment 1 tests your knowledge of Recursion (Chapter 18), List, Stacks, Queues, and Priority Queues (Chapter 20) and Sets and Maps (chapter 21). Design a program/project/driver class (the program/project/driver class file should be called YourNameAssignment1; replace YourName with your actual name) with the following exact methods (with exact1 names and functionality; replace YourName with your actual name or the name you go by, no spaces): Method Exact Name Description YourNameRecursion A recursive method (using recursion studied in Chapter 18) that receives a string as a parameter and recursively capitalizes each character in the string (change a small cap to a large cap, e.g. a to A, b to B, etc) as following: capitalize the first letter from the string, then calls the function recursively for the remainder of the string and in the end, build the capitalized string. For example, for “java”, will capitalize the first letter to “J”(base case), calls the method recursively for the reminder of the string “ava” (reduction), and after recursion/reduction is over it and returns “AVA” will build a new string from “J” and “AVA” and return “JAVA” to the calling method. YourNameCreateList A method that reads words from the Assingment1Data.txt file and store them into a List, Stack, or Queue data structure called YourNameList (any type of lists, queues, or stacks introduced in Chapter 20 - use your knowledge of the chapter and problem at hand to decide which one is better). Words are delimited by whitespaces, punctuation marks (comma, period, colon, semi-colon, exclamation mark, question mark, etc.), quotation marks, and parentheses, and other symbols. Print the message “LIST” and all the elements from YourNameList one element per line. YourNameProcessList A method that processes each element from the YourNameList, to capitalized them using the YourNameRecursion method and replace the word with the capitalized word. Print the message “CAPITALIZED LIST” and all the elements from YourNameList one element per line. YourNameCreateSet A method that processes each element from the capitalized YourNameList and add the unique capitalized words to a Set data structure called YourNameSet (any type of sets introduced in Chapter 21 - use your knowledge of the chapter and problem at hand to decide which one is better). Print the message “SET” and all the elements from YourNameSet one element per line. YourNameCreateMap A method that processes each element from the YourNameSet, and for each element from YourNameSet counts how many times that element occur in the capitalized YourNameList (e.g. for “JAVA” it will count how may times the word “JAVA” is in the capitalized YourNameList and store the WORD-OCCURRENCE pairs into an ordered map data structure called YourNameMap (any type of map introduced in Chapter 21 like Map, LinkedListMap, or TreeMap - use your knowledge of the chapter and problem at hand to decide which type is better for this particular problem) Print the message “MAP” and all the elements from YourNameMap one element per line. YourNameAssignment1 The driver class main should call the methods above in this order: ▪ Use the YourNameCreateList method to create the YourNameList list. ▪ Use the YourNameProcessList method to process the YourNameList to capitalize all the words in the list using the YourNameList lis YourNameRecursion method. ▪ Use the YourNameCreateSet method to create to capitalize YourNameList list and create YourNameSet set. ▪ Use the YourNameCreateMap method to create the YourNameMap map and print it. Your code should just call the method and not reimplement the code from the methods above. Use parameters and returned values to pass structures between different method calls. Create a Microsoft Word document called YourNameAssignment1-Screenshot. (replace YourName with your actual name) that contains screenshots of the editor window showing the entire JAVA source code and the entire output. If the entire class JAVA source code or the output does not fit in one screenshot or the screenshots cannot be easily read, create multiple screenshots and add them to the same document. Submit YourNameAssignment1.java JAVA source code file and YourName-Assignment1-Screenshots.docx Microsoft Word screenshots document on eCampus under the Assignment 1. Do not archive the files (no ZIP, no RAR, etc) or submit other file formats. 1 Use the exact names (spelling, caps). You are not going to earn any credit if the classes and methods do not contain your actual name and have the exact/precise names and functionality. JAVA Code Convention Dr. Adriana Badulescu Programming Fundamentals II Course Code Convention Your code should be well-documented. Every line of code should be preceded by a comment or a Javadoc comment explaining exactly what that line of code is doing. Every class should have a Javadoc comment with the following format: /** * * DESCRIPTION * USAGE * * @author [author name] * @version [version] * */ Every method, should have a Javadoc comment with the following format: /** * * DESCRIPTION * * @param [argument name] [argument description] * @return [description of return] * */ Every other line of code (declaration, initialization, assignment, function call, etc), should be preceded by a regular comment explaining what that line of code is doing. One of the 2 formats: /* DESCRIPTION – multiple lines */ or // DESCRIPTION – one line Class Javadoc comment Method Javadoc comment Line of code regular comment Chapter 1 Chapter 18: Recursion Dr. Adriana Badulescu Topics ▪ Introduction ▪ Why Program? ▪ Computer Systems: Hardware and Software ▪ Programming Languages ▪ What Is a Program Made Of? ▪ The Programming Process ▪ Object-Oriented Programming 2 Objectives ▪ To describe what a recursive method is and the benefits of using recursion (§18.1). ▪ To develop recursive methods for recursive mathematical functions (§§18.2– 18.3). ▪ To explain how recursive method calls are handled in a call stack (§§18.2–18.3). ▪ To solve problems using recursion (§18.4). ▪ To use an overloaded helper method to derive a recursive method (§18.5). ▪ To implement a selection sort using recursion (§18.5.1). ▪ To implement a binary search using recursion (§18.5.2). ▪ To get the directory size using recursion (§18.6). ▪ To solve the Tower of Hanoi problem using recursion (§18.7). ▪ To draw fractals using recursion (§18.8). ▪ To discover the relationship and difference between recursion and iteration (§18.9). ▪ To know tail-recursive methods and why they are desirable (§18.10). Computing Factorial factorial(0) = 1; factorial(n) = n*factorial(n-1); n! = n * (n-1)! 0! = 1 Computing Factorial 5 Computing Factorial factorial(4) = 4 * factorial(3) = 4 * (3 * factorial(2)) = 4 * (3 * (2 * factorial(1))) = 4 * (3 * ( 2 * (1 * factorial(0)))) = 4 * (3 * ( 2 * ( 1 * 1)))) = 4 * (3 * ( 2 * 1)) = 4 * (3 * 2) = 4 * (6) = 24 factorial(0) = 1; factorial(n) = n*factorial(n-1); Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial Trace Recursive factorial factorial(4) Stack Trace Space Required for factorial(4) 1 Space Required for factorial(4) 2 Space Required for factorial(3) Space Required for factorial(4) 3 Space Required for factorial(3) Space Required for factorial(2) Space Required for factorial(4) 4 Space Required for factorial(3) Space Required for factorial(2) Space Required for factorial(1) Space Required for factorial(4) 5 Space Required for factorial(3) Space Required for factorial(2) Space Required for factorial(1) Space Required for factorial(0) Space Required for factorial(4) 6 Space Required for factorial(3) Space Required for factorial(2) Space Required for factorial(1) Space Required for factorial(4) 7 Space Required for factorial(3) Space Required for factorial(2) Space Required for factorial(4) 8 Space Required for factorial(3) Space Required for factorial(4) 9 Fibonacci Numbers Fibonacci series: 0 1 1 2 3 5 8 13 21 34 55 89… indices: 0 1 2 3 4 5 6 7 8 9 10 11 fib(0) = 0; fib(1) = 1; fib(index) = fib(index -1) + fib(index -2); index >=2 fib(3) = fib(2) + fib(1) = (fib(1) + fib(0)) + fib(1) = (1 + 0) +fib(1) = 1 + fib(1) = 1 + 1 = 2 Fibonacci Numbers 20 Fibonnaci Numbers return fib(3) + fib(2) return fib(2) + fib(1) return fib(1) + fib(0) return 1 return fib(1) + fib(0) return 0 return 1 return 1 return 0 1: call fib(3) 2: call fib(2) 3: call fib(1) 4: return fib(1) 7: return fib(2) 5: call fib(0) 6: return fib(0) 8: call fib(1) 9: return fib(1) 10: return fib(3) 11: call fib(2) 16: return fib(2) 12: call fib(1) 13: return fib(1) 14: return fib(0) 15: return fib(0) fib(4) 0: call fib(4) 17: return fib(4) Characteristics of Recursion ▪ All recursive methods have the following characteristics: ▪ One or more base cases (the simplest case) are used to stop recursion. ▪ Every recursive call reduces the original problem (reduction), bringing it increasingly closer to a base case until it becomes that case. ▪ In general, to solve a problem using recursion, you break it into subproblems. ▪ If a subproblem resembles the original problem, you can apply the same approach to solve the subproblem recursively. ▪ This subproblem is almost the same as the original problem in nature with a smaller size. Problem Solving Using Recursion ▪ Let us consider a simple problem of printing a message for n times. ▪ You can break the problem into two subproblems: one is to print the message one time and the other is to print the message for n-1 times. The second problem is the same as the original problem with a smaller size. ▪ The base case for the problem is n==0. Think Recursively ▪ Many of the problems can be solved using recursion if you think recursively. ▪ A string is a palindrome if it reads the same forward and backward. E.g. mom
Answered 3 days AfterJul 10, 2021

Answer To: Assignment 1 ASSIGNMENT 1 Assignment 1 tests your knowledge of Recursion (Chapter 18), List, Stacks,...

Pranav answered on Jul 14 2021
138 Votes
package MainApp;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.
Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* A Project Class that takes input from a file and performs various functions on it.
* This class gets creates a list of words from a text file, and counts the occurrences
* of each word
* @author Valencia Tshamanye
* @version 1.0 13/07/2021
*/
public class ValenciaTshamanyeAssignment1 {
    
    //a list of strings which will be initialized using a text file
    private static List valenciaTshamanyeList;
    
    //a set of Strings
    private static Set valenciaTshamanyeSet;
    
    //a map that stores the number of occurrences of each String in the list
    private static Map valenciaTshamanyeMap;
    
    /**
     * A recursive method to capitalize every character of a string passed as parameter
     * @param original The original String to be capitalized
     * @param charPosition The position of the character to be capitalized in this
     * recursive call
     * @return A string with all the characters capitalized
     */
    public static String ValenciaTshamanyeRecursion(String original, int charPosition) {
        
        //the terminating point of recursion
        if( charPosition >= original.length() ) {
            return "";
        }
        
        //fetching the character at the given position and capitalizing it by a method
        char capitalizedChar = Character.toUpperCase(original.charAt(charPosition));
        
        /*embedding the recursive call for the next character into the return statement,
         * converting the capitalized character into a string, and ultimately attaching
         * all the capitalized characters with this string to return the final string
         */
        return Character.toString(capitalizedChar) +
                ValenciaTshamanyeRecursion(original, charPosition+1);
    }
    
    /**
     * A method to initialize our list with the help of...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here