Implement methods insert and extract

Assignment Help JAVA Programming
Reference no: EM131151037 , Length:

1: Balanced Parentheses

A stack is a data structure where data is accessed using the LIFO (last in first out) approach. In this problem, you will use a stack to check whether a string has balanced parentheses "()" (and possibly brackets "{}","[]"), or not.

For this problem, you can receive up to 80% by testing for balanced parentheses. The remaining 20% will be for a more general solution that checks for all parentheses and balanced brackets (curly and square).

A string that has balanced parentheses and brackets will be said to be balanced. Any character that is NOT one of ‘(',‘)',‘{',‘}',‘[', or ‘]' are not important when deciding if a string is balanced and can be ignored.

We will define balanced as follows. A string str is balanced

- if str does not contain a parenthesis or bracket symbol, or
- if str consists of a balanced string surrounded by opening and closing parentheses or matching brackets. That is, str is "(b)", or str is "[b]" or str is "{b}", where b is any balanced string, or
- if str is the concatenation of any two balanced strings. That is, str is "bc", where b and c are any balanced strings.

Write a Java class called Balanced that has two static methods isBalanced(String) and numberOfBalancedStrings(String[]). Use the provided template and write the body of the method according to the specifications provided.

Your isBalanced() method must use the java.util.Stack class (in a way that solves the problem) to receive any grades for this problem.
(https://docs.oracle.com/javase/8/docs/api/java/util/Stack.html)

Mark breakdown: 20 marks for balanced parentheses, 5 marks for general solution

Examples: The following strings have balanced parentheses
- "", "()", "()()"
- "cat", "c(at)", "(hello)(kitty)"
- "if( ((x-y) < 4) || (x > 12)){"

- "()(((s)))()()()()(x()((y))(x))......()(ccccc(w))ssss()"
The following strings do NOT have balances parentheses
- ")", ")(a)", ")a("
The following strings have balanced parentheses and brackets
- "", "()", "[]", "{}", "{[]}", "[()]", "({[]})", "()[](){}", "([])[{()}][]()"
- "for(int i=0; i<12; i+=1){x[i]+=1;}"
The following strings do NOT have balanced parentheses and brackets
- "(]", "{)", "[}", "[}", "(]"
- "for(int i=0; i<12; i+=1){"

2: Top 10

In this problem, you will complete a program that reads in a text file and outputs the top ten words that appear most frequently in the file. Reading data from the file is done for you in the provided skeleton file.

 Complete the WordStats program that is provided. Your program will take a single

command line argument that is the name of a text file (e.g., "file.txt") in the same directory as your program. The program will then read every "word" in the text file and output a graph of the relative frequency of the 10 most frequent words in the file. A word is a maximal sequence of characters without whitespace. The output of the program should look something like the following:

Total number of words is 1243
----------------------------------------------------------------- the |##################################################[851] cat |#########################[425]
an |########################[409] curious|########################[408]
android|#####[84] pizza |###[52] dog |##[33]
eel |##[32]
end |##[32]
what |#[17]
-----------------------------------------------------------------
finished in 1.343 seconds

A count of all words is given and then a plot that shows each of the words and their relative frequency. Each word is given along with a graphical representation of the relative frequency of that word. The most frequent word should have fifty # symbols and the others based on this scaling. Use simple rounding to determine number of # symbols. The actual count of each word should also be displayed as shown above (in square brackets). For example, the word "the" was most frequent appearing 851 times. The time message at the end is provided in the skeleton code.

Be sure to only modify main in the section indicated. You may add any helper methods you need.

Your plot may contain less than 10 words (if the text file has less then 10 unique words) and it may contain more than 10 words (if there is a tie and there are more than 10 words with the greatest frequencies).

You must use a Hashtable to keep track of the frequency of each word in the file.
(https://docs.oracle.com/javase/8/docs/api/java/util/Hashtable.html)

When considering "words" in the file, you should be ignoring punctuation (period, comma, question mark, exclamation mark, quotation marks) but keep apostrophes and hy- phens. For example, "that's" should be considered a single word.

In this problem you will initially need to use a hashtable but then move the data to another structure to complete the problem.

3: Linked List

In this problem you will implement a linked list class for Strings.

2161_Fig.jpg

Write a LinkedList class that extends the provided ALinkedList abstract class. The abstract class provides methods to add and remove a string from the front or back of the list. You will need to implement two additional methods: insert and extract. The specifications are found in the ALinkedList.java file.

4: Drawing

Think about your experience so far in COMP1006/1406. Think about what you have learned and what you have done. Your task in this problem is to draw a picture that expresses this reflection.

My hope in asking you to draw a picture is that you will critically reflect on the learning objectives you have achieved in this course so far. It should also make this assignment a bit lighter than the others. The intention is that this problem should not cause you stress. Do not worry about your "artistic ability". You will not be graded on that at all. Have fun.

Your submission should be in PDF format (if you prefer to hand in a physical copy then contact me and we will make arrangements for this). Ideally, the size of your drawing should be a standard letter size in horizontal orientation. If you submit your picture in a file called
Public.pdf then you are agreeing to have your picture shown to the class. If you prefer that your picture not be shown then submit it in a file called Private.pdf.

Offensive/rude/insensitive submissions will receive zero marks and may be forwarded to the Dean's office depending on the severity. (This has never happened before.)

Attachment:- Java.rar

Verified Expert

In this assignment, 3 programming problems were solved using Java. The 3 problems were based on the use of data structures like array, linked lists and hash tables.

Reference no: EM131151037

Questions Cloud

Who were the key actors involved in the decision-making : Who were the key actors involved in the decision-making to go to Iraq and how did their ideas evolve? Why were some actors involved and others excluded from the decision-making to go to Iraq and did the exclusion of some actors affect the decision th..
Prepare the journal entries to record the interest received : Prepare the journal entries to record the interest received and recognition of fair value for 2013. Prepare the journal entry to record the recognition of fair value for 2014.
Determine the state of stress at points c and d : determine the state of stress at points C and D on the strap at B . Assume the vertical reaction F at this end acts in the center and on the edge of the bracket as shown.
Identify ways that culture has influenced the structure : Research your chosen company (BP OIL). Find a minimum of three library sources, which will support your thesis in this assignment. Review your assigned weekly lecture and text reading. Select from this reading 8-10 key concepts, which will also..
Implement methods insert and extract : The abstract class provides methods to add and remove a string from the front or back of the list. You will need to implement two additional methods: insert and extract.
How did each development influence american culture : Write a 700- to 1,050-word paper in which you answer the following questions: What were the major developments in the evolution of mass media during the last century? How did each development influence American culture
Prepare journal entry to record sale of the colorado company : Prepare the journal entry to record the sale of the Colorado Company stock during 2014. Prepare the adjusting journal entry needed on December 31, 2014.
Determine the discharge per unit width of the aquifer : From two observation wells 200 m apart, theobserved water table elevations are 11 and 7 m measured form the bottom of the stratum. Determine the discharge per unit width of the aquifer.
Is the shareholder correct : A shareholder sues alleging that Jimmy violated his fiduciary duty of loyalty. Additionally, the shareholder claims that the directors violated their fiduciary duties of care. Is the shareholder correct

Reviews

Write a Review

JAVA Programming Questions & Answers

  Construct a fileinputstream with the file name

Write a program that will search a text file of strings representing numbers of type int and will write the largest and the smallest numbers to the screen. The file contains nothing but strings representing numbers of type int one per line. Your s..

  Create a student object based on the information given

You will then attempt to open the file, create a Student object based on the information given in the file and read the student's essay from the file.

  How this form may be protected from credit card frauds

Explain if replacing the fields, like social security number to credit card numbers will have any impact on the underlying codes? How this form may be protected from credit card frauds?

  Design constraintsyour program should confirm to the

design constraintsyour program should confirm to the following constraints.nbsp it shouldinclude at least one example

  Java application which creates bank records

Write down a java application which creates 10000 bank records and the allow user ti enter a balance and customer account info. using a an account number.

  Write a complete java class called diffcubes

Write a complete Java class called DiffCubes that uses a Scanner reads in two int values from the console. Using these values, the program should find the difference between the cubes of the two values and write the result to the screen

  Improve the word jumble game

Improve the Word Jumble game presented in this chapter so that each word is paired with a hint. If the player enters hint, then the program should show the corresponding hint.

  Exception handling for validating the input.

The program needs to have built in Exception handling for validating the input.

  Code the given java application

Using NetBeans, code the following Java application, and run it on Command prompt (Terminal If Linux) with the argument "notepad" (or "gedit" if Linux).

  Relationship between inheritance and subtyping

With this declaration of m in subclass B, any invocation of m on a B object will result in a special error indicating that the method should not be used. (a) What effect does this feature of Smalltalk have on the relationship between inherit..

  Write java class that contains 4 instance methods

Write an application class which only contains a main method. This class should create an instance of your CV class and should, through a sequence of method calls, cause your CV information to be displayed on the screen (see Figure 1).

  Write a java program that will read a sequence of names

Write a java program that will read a sequence of names (first name followed by last name, separated by at least one space) from a text file and will 1) remove all duplicate names and 2) write the names (last name followed by a comma, followed by one..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd