Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.
(http://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.
(http://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

Java, Programming

  • Category:- Java
  • Reference No.:- M91906497
  • Price:- $75

Priced at Now at $75, Verified Solution

Have any Question?


Related Questions in Java

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As