Loading...

Messages

Proposals

Stuck in your homework and missing deadline? Get urgent help in $10/Page with 24 hours deadline

Get Urgent Writing Help In Your Essays, Assignments, Homeworks, Dissertation, Thesis Or Coursework & Achieve A+ Grades.

Privacy Guaranteed - 100% Plagiarism Free Writing - Free Turnitin Report - Professional And Experienced Writers - 24/7 Online Support

Cmps 101 pa1

19/12/2020 Client: saad24vbs Deadline: 3 days

1


CMPS 101


Algorithms and Abstract Data Types


Programming Assignment 1


Our goal in this project is to build an Integer List ADT and use it to alphabetize the lines in a file. This ADT


module will also be used (with some modifications) in future programming assignments, so you should test it


thoroughly, even though not all of its features will be used here. Begin by reading the handout ADT.pdf posted


on the class webpage for a thorough explanation of the programming practices and conventions required in this


class for implementing ADTs in Java and C.


Program Operation


The main program for this project will be called Lex.java. Your List ADT module will be contained in a file


called List.java, and will export its services to the client module Lex.java. Each file will define one top level


class, List and Lex respectively. The required List operations are specified in detail below. Lex.java will take


two command line arguments giving the names of an input file and an output file. The input can be any text file.


The output file will contain the same lines as the input arranged in lexicographic (i.e. alphabetical) order. For


example:


Input file: Output file: one five


two four


three one


four three


five two


Lex.java will follow the sketch given below.


1. Check that there are two command line arguments. Quit with a usage message to stderr if more than or less


than two strings are given on the command line.


2. Count the number of lines n in the file named by args[0]. Create a String array of length n and read in the


lines of the file as Strings, placing them into the array.


3. Create a List whose elements are the indices of the above String array. These indices should be arranged in an order that effectively sorts the array. Using the above input file as an example we would have.


Indices: 0 1 2 3 4


Array: one two three four five


List: 4 3 0 2 1


To build the integer List in the correct order, begin with an initially empty List, then insert the indices of the


array one by one into the appropriate positions of the List. Use the InsertionSort algorithm as a guide to your


thinking on how to accomplish this. (Please read the preceding two sentences several times so that you


understand what is required. You are not being asked to sort the input array using InsertionSort.) You may


use only the List ADT operations defined below to manipulate the List. Note that the String class provides a


method called compareTo() that determines the lexicographic ordering of two Strings. If s1 and s2 are


strings then:


s1.compareTo(s2)<0 is true if and only if s1 comes before s2


s1.compareTo(s2)>0 is true if and only if s1 comes after s2


2


s1.compareTo(s2)==0 is true if and only if s1 is identical to s2


4. Use the List constructed in (3) to print the array in alphabetical order to the file named by args[1]. Note


that at no time is the array ever sorted. Instead you are indirectly sorting the array by building a List of indices


in a certain order.


See the example FileIO.java to learn about file input-output operations in Java if you are not already familiar with


them. I will place a number of matched pairs of input-output files in the examples section, along with a python


script that creates random input files along with their matched output files. Use these tools to test your program


once it is up and running.


List ADT Specifications


Your list module for this project will be a bi-directional queue that includes a “cursor” to be used for iteration.


Think of the cursor as highlighting or underscoring a distinguished element in the list. Note that it is a valid state


for this ADT to have no distinguished element, i.e. the cursor may be undefined or “off the list”, which is in fact


its default state. Thus the set of “mathematical structures” for this ADT consists of all finite sequences of integers


in which at most one element is underscored. A list has two ends referred to as “front” and “back” respectively.


The cursor will be used by the client to traverse the list in either direction. Each list element is associated with


an index ranging from 0 (front) to n-1 (back), where n is the length of the list. Your list module will define the


following operations.


// Constructor


List() // Creates a new empty list.


// Access functions


int length() // Returns the number of elements in this List.


int index() // If cursor is defined, returns the index of the cursor element,


// otherwise returns -1.


int front() // Returns front element. Pre: length()>0


int back() // Returns back element. Pre: length()>0


int get() // Returns cursor element. Pre: length()>0, index()>=0


boolean equals(List L) // Returns true if and only if this List and L are the same


// integer sequence. The states of the cursors in the two Lists


// are not used in determining equality.


// Manipulation procedures


void clear() // Resets this List to its original empty state.


void moveFront() // If List is non-empty, places the cursor under the front element,


// otherwise does nothing.


void moveBack() // If List is non-empty, places the cursor under the back element,


// otherwise does nothing.


void movePrev() // If cursor is defined and not at front, moves cursor one step toward


// front of this List, if cursor is defined and at front, cursor becomes


// undefined, if cursor is undefined does nothing.


void moveNext() // If cursor is defined and not at back, moves cursor one step toward


// back of this List, if cursor is defined and at back, cursor becomes


// undefined, if cursor is undefined does nothing.


void prepend(int data) // Insert new element into this List. If List is non-empty,


// insertion takes place before front element.


void append(int data) // Insert new element into this List. If List is non-empty,


// insertion takes place after back element.


void insertBefore(int data) // Insert new element before cursor.


// Pre: length()>0, index()>=0


void insertAfter(int data) // Inserts new element after cursor.


// Pre: length()>0, index()>=0


void deleteFront() // Deletes the front element. Pre: length()>0


void deleteBack() // Deletes the back element. Pre: length()>0


3


void delete() // Deletes cursor element, making cursor undefined.


// Pre: length()>0, index()>=0


// Other methods


public String toString() // Overrides Object's toString method. Returns a String


// representation of this List consisting of a space


// separated sequence of integers, with front on left.


List copy() // Returns a new List representing the same integer sequence as this


// List. The cursor in the new list is undefined, regardless of the


// state of the cursor in this List. This List is unchanged.


The above operations are required for full credit, though it is not expected that all will be used by the client module


in this project. The following operation is optional, and may come in handy in some future assignment:


List concat(List L) // Returns a new List which is the concatenation of


// this list followed by L. The cursor in the new List


// is undefined, regardless of the states of the cursors


// in this List and L. The states of this List and L are


// unchanged.


Notice that the above operations offer a standard method for the client to iterate in either direction over the


elements in a List. A typical loop in the client might appear as follows.


L.moveFront();


while(L.index()>=0){


x = L.get();


// do something with x


L.moveNext();


}


To iterate back to front, simply replace moveFront() by moveBack() and moveNext() by movePrev().


One could just as well set this up as a for loop in either direction. Observe that in the special case where L is


empty, the cursor is necessarily undefined so that L.index() returns -1, making the loop repetition condition


initially false, and the loop executes zero times, as it should on an empty List. It is required that function index()


be implemented efficiently.


The underlying data structure for the List ADT will be a doubly linked list. The List class should therefore contain


a private inner Node class which itself contains fields for an int (the data), and two Node references (the previous


and next Nodes, respectively) which may be null. The Node class should also define an appropriate constructor


as well as a toString() method. The List class should contain three private fields of type Node referring to the


front, back, and cursor elements, respectively. The List class should also contain private int fields storing the


length of the List and the index of the cursor element. When the cursor is undefined, an appropriate value the


index field is -1, since that is what is returned by index() in such a case.


All of the above classes, fields and methods will be placed in List.java. Create a separate file called ListTest.java


to serve as a test client for your ADT. Do not submit this file, just use it for your own tests. I will place another


test client on the webpage called ListClient.java. Place this file in the directory containing your completed


List.java, then compile and run it. The correct output is included in ListClient.java as a comment. You will


submit this file unchanged with your project.


You are required to submit a Makefile that creates an executable jar file called Lex, which is the main program


for this project. Include a clean target in your Makefile that removes Lex and any associated .class files to aid


the grader in cleaning the submit directory. One possible Makefile will be included on the course webpage under


Examples/pa1. You may alter this Makefile as you see fit to perform other tasks such as submit. See my CMPS


4


12B website (https://classes.soe.ucsc.edu/cmps012b/Winter19/lab1.pdf) to learn basic information about


Makefiles.


You must also submit a README file for this (and every) assignment. README should list each file submitted,


together with a brief description of its role in the project, and any special notes to myself and the grader.


README is essentially a table of contents for the project, and nothing more. You will therefore submit five files


in all:


List.java written by you


ListClient.java provided on webpage, do not alter


Lex.java written by you


Makefile provided on webpage, you may alter


README written by you


Points will be deducted if you misspell these file names, or if you submit jar files, .class files, input-output files,


or any other extra files not specified above. Each source file you submit must begin with a comment block


containing your name, CruzID, and the assignment name.


Advice


The examples Queue.java and Stack.java on the website are good starting points for the List module in this project.


You are welcome to simply start with one of those files, rename things, then add functionality until the


specifications for the List ADT are met. You should first design and build your List ADT, test it thoroughly, and


only then start coding Lex.java. Start early and ask questions if anything is unclear. Information on how to turn


in your project is posted on the class webpage.


https://classes.soe.ucsc.edu/cmps012b/Winter19/lab1.pdf

https://classes.soe.ucsc.edu/cmps012b/Winter19/lab1.pdf

Applied Sciences

Architecture and Design

Biology

Business & Finance

Chemistry

Computer Science

Geography

Geology

Education

Engineering

English

Environmental science

Spanish

Government

History

Human Resource Management

Information Systems

Law

Literature

Mathematics

Nursing

Physics

Political Science

Psychology

Reading

Science

Social Science

Home

Blog

Archive

Contact

google+twitterfacebook

Copyright © 2019 HomeworkMarket.com

Homework is Completed By:

Writer Writer Name Amount Client Comments & Rating
Instant Homework Helper

ONLINE

Instant Homework Helper

$36

She helped me in last minute in a very reasonable price. She is a lifesaver, I got A+ grade in my homework, I will surely hire her again for my next assignments, Thumbs Up!

Order & Get This Solution Within 3 Hours in $25/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 3 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 6 Hours in $20/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 6 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

Order & Get This Solution Within 12 Hours in $15/Page

Custom Original Solution And Get A+ Grades

  • 100% Plagiarism Free
  • Proper APA/MLA/Harvard Referencing
  • Delivery in 12 Hours After Placing Order
  • Free Turnitin Report
  • Unlimited Revisions
  • Privacy Guaranteed

6 writers have sent their proposals to do this homework:

Writer Writer Name Offer Chat

Writers are writing their proposals. Just wait here to get the offers for your project...

Let our expert academic writers to help you in achieving a+ grades in your homework, assignment, quiz or exam.

Similar Homework Questions

Week8 discussion - Surface area of oblique pyramid - 22 allen street pyrmont nsw 2009 - Hypertrophy coach training split - Insurance institute of ireland - Moral distress in nursing contributing factors outcomes and interventions - Pirate bay safe to use - Aperture slot worlds biggest crossword - Psychotherapy With Individuals - Tesco overseas expansion - Mean median range standard deviation - Foreign direct investment by cemex - Eme moonbounce for a beginner - Northern arizona university competency based - 737 800 stall speed - Main causes of fire in nhs - The Suffragettes Accomplishment - Last christmas dice and k9 - Examples of fallacies in social media - Does domestic partnership affect fafsa - Andrew braaksma author - Kung fu panda meaning - Questions - Beloved wife is not well behaved baka - Evie artificial intelligence - Strayer outline - Gcu integration of faith and work - Tweeters rehearsal studio leatherhead - Centre assistant job description - Paul durcan father's day - C12 15 alkyl benzoate dangers - Commemorative speech about my father - Sara smilansky types of play - Criminal justice - Cirque du soleil financial problems - Is forum shopping ethical busi - Chingford metal finishers slough - Which consumer market segments best match with benihana - What does wheelbarrow mean in a dream - Jo koy mexican falling off cliff - E - Www sutherlandcu com au - Discussion Essay Guru ONLY - Bolman and deal reframing organizations powerpoint - Examples of cultural bias - Science write up template - Module 4 Discussion - How to register a business in saskatchewan - IS HEALTH A HUMAN RIGHT OR NOT IN THE USA - Failure mode and effects analysis nursing - Discussion Forum 2 - Discussion: Pre-Assessment - A simple pendulum 1.00 m in length - A description of what you believe to be the consequences of a healthcare organization not involving nurses in each stage of the SDLC when purchasing and implementing a new health information technology system. - Ellie harrison outrageous acts of science - Dhl fuel surcharge uk - Is apache plume an annual or a perennial - List of economic consulting firms - How to get the percent yield - Brivis ng1 lo heating module manual - Cisco nexus netflow support - Delinquent road hazards da unbeatables - Topic proposal memo example - FASB Codification - Perry mason the case of the golfers gambit - A railroad car of mass - Cpt code for omni glaucoma procedure - Successfactors vail resorts - Roberta kathleen parks lafayette ca - The highwayman alfred noyes analysis - Assignment - Malcolm x coming to an awareness of language essay - Accounting cycle project - Boring, tedious jobs generally reduce people's perceptions of their - Ielts verification candidate identity - Medical -surgical nursing - Nur601 Reply to this discussion- Ruth - Seven group holdings annual report - Don't have employment separation certificate - 6 strip h method - Discussion Topic - D2 act 3 waypoints - 1.5 mm brass tube - Which entry mode gives a multinational the tightest control over foreign operations? - Ftttt urban dictionary - Read The Case of Plant Relocation and complete the questions at the end of the case study. - Multi step flow theory of mass communication - Computer graphics assignment questions and answers - Principles of distributed database systems 3rd edition - Iso 9001 sales procedure - Melnyk and fineout overholt 4th edition - Three stage model of interviewing - Studentweb box hill tafe - Iupac name of c ccl3 4 - Nippon express usa headquarters - Anzca primary exam reports - Feast watson mastertouch wipe on poly - Breaking night quotes with page numbers - +91-8306951337 kala jadu specialist astrologer IN Bhatpara - Leadership role