Ask an Expert Help-24/7

ASK QUESTION & GET ANSWERED ONTIME!

High Quality, Fast Delivery, Plagiarism Free - Just in 3 Steps

Submit Your Question Here

Email Address
Word Limit
No. of Pages
(yy-mm-dd)
Multiple Attach File
Professional Assignment Help Services

Java Assignment Help

Book Your Assignments Today!
&
Securing Higher Grades at Least Amount Of Effort?

Get Assignment Answers from Top-notch Tutors – specialize in your subject areas

Hire Your Assignment Writing Expert for  Collage/University

CMP 561 Algorithm Analysis

Objective:  Find the data structure which yields a better CPU efficiency than java.util.ArrayList in a search-oriented operation/application. Listed below are data structures that you can select from.
Name
Synchronization
Order
Duplicated Records
Vector
Synchronized
Queue
Yes
Hashtable
Synchronized
Random
Yes
HashMap
Unsynchronized
Random
Yes
LinkedHashMap
Unsynchronized
Least recently used
Yes
TreeMap
Unsynchronized
Natural
Yes
HashSet
Unsynchronized
Random
No
LinkedHashSet
Unsynchronized
Least recently used
No
TreeSet
Unsynchronized
Natural
No
The attached program, ByArrayList.java, calculates and displays the time needed to perform some search operations. This program searches for records by the 2-character state code. The data records are stored in qz4Data.csv file. Each data record/line consists of 5 attributes/fields, separated by commas:
 ID (Unique, no duplicates)
 Age
 State (2-character abbreviation)
 Gender (M or F)
 Status (0: not processed; 1: processed; 2: approved)
Shown below are some sample runs of ByArrayList:
C:\ Java ByArrayList
CPU time used: 10401 ms
C:\ Java ByArrayList
CPU time used: 12047 ms
C:\ Java ByArrayList
CPU time used: 10937 ms
You are tasked to:
A. Develop a program to perform the identical operation as ByArrayList.java program, using a data structure which gives a better CPU efficiency.
B. Provide a comment file in MS Word or pdf format to summarize your conclusion.
C. Give a 2-minute presentation. You need to  Show the difference between the outputs generated from ByArrayList and your program.  Show the key statements that generate your program output.
 Be prepared to answer questions.
Please name your .java file as: YourLastNameQz4.java and YourLastNameQz4
CMP561 Quiz #4 Page 2
Quiz #4 Grading Policy
Deducted
Why
5%
Submitted a solution that is identical or similar to the one submitted by others.
5%
Submitted a solution that has nothing or little to do with the requirements.
3%
Submitted an incomplete solution.
3%
Submitted a file that cannot be compiled.
2%
Submitted a program that generates a run-time error/exception.
2%
Submitted a program generates an incorrect output.
2%
Did not submit a comment file.
2%
Did not give a presentation.
2%
The presentation showed that you did not complete the program by yourself.
1%
Failed to answer at least one question during the presentation.
1%
Submitted one or more binary files.
1%
Submitted one or more files without your name.
1%
Did not follow the file naming instruction.
1%
Comment file does not provide a conclusion.
1%
The conclusion has little or nothing to do with the requirements.
1%
The conclusion is inconsistent with the program output.
/**
This program uses java.util.ArrayList to store data records for search operations. It shows the time needed to search records by the 2-character state code.
**/
import java.util.*;
import java.io.*; public class ByArrayList {
public static void main(String []args) throws IOException
{
String line;
String []pattern = { “VA”, “MD”, “CT”, “DC”, “CA”, “FL”, “OH”, “AZ”, “NY”, “NJ” };
ArrayList <Qz4Data> records = new ArrayList<Qz4Data> ();
BufferedReader inFile = new BufferedReader(new FileReader(“qz4Data.csv”));
while ((line = inFile.readLine()) != null)
records.add(new Qz4Data(line));
inFile.close();
long startTime = System.currentTimeMillis(); // start time
for (int k=0; k < 200; ++k)
for (int i=0; i < pattern.length; ++i)
for (Qz4Data s : records)
s.getState().equals(pattern[i]);
long endTime = System.currentTimeMillis(); // end time
System.out.print(“CPU time used: ” + (endTime – startTime) + ” ms”);
} // main
} // ByArrayList
class Qz4Data
{
String ID, state, gender;
int age, status;
Qz4Data() {}
Qz4Data(String l)
{
StringTokenizer st = new StringTokenizer(l, “,”);
ID = st.nextToken(“,”).trim();
age = Integer.valueOf(st.nextToken(“,”));
state = st.nextToken(“,”).trim();
gender = st.nextToken(“,”).trim();
status = Integer.valueOf(st.nextToken(“,”));
}
public String getID() { return ID; }
public String getState() { return state; }
public String getGender() { return gender; }
public int getAge() { return age; }
public int getStatus() { return status; }
public void setAge(int a) { age = a; }
public void setState(String s) { state = s; }
public void setStatus(int s) { status = s; }
} //

 

To get answer chat with online assignment adviser

Hire Your Assignment Writing Expert for Collage/University

Ask Your Java Assignment Help Online?
Check out our Java Programming Assignment Help Service
Find Your computer science assignment topics

Get This Answer with 24/7 Subject-Matter Experts

Get help instantly with No1 Assignment Help and Earn better grades
with 24/7 homework help

Chat Now

Top