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

Doc 8168 vol 3 - Urgent please accept the bid who can deliver in 3hours - Difference between protista and fungi - Cua esaver reward account - Atkins or fadkins answers part 1 - IT Related Questions - Wk 3, IOP 470: Power, Decision-Making, and Leadership Paper - Article Analysis and Evaluation of Research Ethics - Www betheluniversityonline net ccj - Delivering health care in america a systems approach - Population per square mile china - Internet of things chapter 1 quiz - Hellenistic cosmopolitanism expressed itself in all of the following ways except - Parts of a nuptial mass - Data Mining Best Practices Assignment - Discussion - Math management quiz - The four phases of mentoring are initiation, cultivation, socialization, and definition. - Research article critique apa format - The project scope document is valuable for establishing - Animal farm chapter 7 quiz - Sample scope statement for software project - ¿cómo estás? yo (1) porque mañana vuelvo a puerto rico y te voy a ver. sé (i know) que tú - What organelle in the cell creates co2 - 7 eugenia street rivett - Www usingenglish com comprehension - For purposes of external reporting private colleges and universities - Sustainability management - Web services ppt slideshare - Which sentence best summarizes the central conflict in amaterasu - Surge function in modelling medicinal doses - Lawrence erlbaum associates inc - Core concepts 5.4 word wise - Symphony new mobile 2018 - Bus timetable 320 watford - Microbiology case study examples with answers - Bt line rental plus - Admission essay writing service - Investment management chapter 1 - Final Narrative paper - Business Policies and Strategies - Fishy in the water fishy in the sea lyrics - Mi familia project spanish 1 - St george christian college - +91-8306951337 get your love back by vashikaran IN Jamnagar - ?? same-day +27833173182 CHITUNGWIZA ABORTION CLINIC // PILLS,,,, - Monster high 13 wishes ds game - Olivier blanchard macroeconomics 7th edition solutions - SOCS185N: Culture and Society - Designer baby scalisi vs ny univ medical center p 429 - Describe the importance of effective communication in the correctional setting - Oprah winfrey harvard commencement speech transcript - Fraser foods case study answers - Tivo temporary service connection issue c133 - Describe the different types of logistics service providers - The swot analysis pdf - How to share games on scratch - How to prepare an adjusted trial balance - Stefan ceramics is in the business of selling - Concept map of literature - Discussion - 1 - Operations Security - Group therapy - Windshield survey example - Discuss at least two backup strategies - SCM Essay - Grand tour question in qualitative research - Accounting Assignment - Loughborough town hall panto - Health Assessment 5 - Applications Security 3questions. - A to z mysteries detective camp - Musee des beaux arts analysis essay - Fetal medicine fellowship uk - What are some key performance indicators that are used by organizations in which you have been employed? How did managers explain the importance of these KPIs, and were any rewards tied to them? - Netflix quixtar - Sdtm version 3.2 pdf - Genetics quiz questions and answers pdf - Why is it difficult to establish effective health it governance? - Laser cutter risk assessment example - Yamile marrero fiu - Common core math learning progressions - Pienso comprar aquellas camisas verdes - Under armour opportunities and threats - Ni usb 6212 driver - Assessing Client Progress - Bf skinner theory in the classroom - Define transaction demand for money - Give the systematic iupac name for the following - Statistics - Zoot suit act 2 summary - Mm lafleur bento box reviews - Bramble finches for sale - Bsbmgt516 - Matlab Program - Analysis of hydrogen peroxide pre lab answers - Words with letters lovei - Range of a vector valued function - Web jetadmin 64 bit - 25l liquid nitrogen dewar - Reflections - Creativity and innovation table mgt411