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

Target corporation distribution strategy - C & p haulage v middleton - Socw 6456 assignment - Book editing for dummies - The lonely good company of books - Single phase motor protection - Buffalo wild wings strengths and weaknesses - Group project - Brilliant answers - Stack using array in java program push and pop - How much is a mm lafleur bento box - Strategy and Performance Management at DSM - Annotated bibliography and outline leadership behavior - Converting a linear program to canonical form - IOM Report - The blind side analysis - Write an equation for a rational function with - HW 10.1 - Pico questions for emergency nursing - Thin and fat clients - Research journal of english language and literature rjelal - Nepal health professional council - Digital Marketing Strategy Project - Amp flexible super phone number - Creating phylogenetic trees from dna sequences student worksheet answer key - Was elvis a twin - In-service Baker’s Cyst - Texas governor informal powers - A scandal in bohemia comprehension questions - Toms shoes nonprofit - Epicardial pacing wires placement - 0.96 repeating as a fraction in simplest form - Bering land bridge theory - What does the name christian mean - Claudia (escribir) un mensaje por internet cuando la llamó miguel - Aps code of conduct - Nurs495prompt - Vrio analysis framework of amazon - Psyc 325 unit 2 discussion board - English Esaay - Cullen timber engineering connectors - Sex linked traits worksheet hemophilia - Earth Science - Guide to the nqs - Uti soap note - The vark questionnaire is designed to tell you - Socialization into professional nursing ati - Cross product how to remember - Ncle perm internet banking - Examples of diction in the devil in the white city - My viabenefits com coca cola - 6.3 Online Research Discussion - Reflection - Extra points - RESEARCH METHODOLOGIES AND INQUIRY - Week 2 IT - Accept the things you cannot change - Titration of vinegar lab report answers - Macbeth act 2 discussion questions answers - Matthew 5 43 48 relevance to other worldviews - Darwin's finch beak lab answer key - How are the roles of men and women portrayed in the short story “The Story of an Hour” by Kate Chopin?? Are they distinctly different? Do they have equal rights? What gender expectations do they follow or fight against? whats Chopin comment - Descriptive Statistics - The title page required by ashford university is a modified version of apa title pages. - Creating a budget assignment - Bj heating and cooling albury - First fieldwork the misadventures of an anthropologist pdf - Imagine you work for an independent grocery store with 20 employees. The business owner has tasked you with creating a relational database that will track employee names, IDs, positions (e.g., cashier, manager, clerk, or night crew), and salaries. - Cloudy with a chance of meatballs food storm - 12 days of christmas obfuscated c - Pneumatech air dryer troubleshooting - 6-3 Quiz: Armani - Lab 6 3 changes in phase of water answers - A vending machine automatically pours soft drinks into cups - Week-14 discussion cpm - Pearson correlation critical value - Research Paper - How to convert babylonian numerals to hindu arabic - Photograph - Homework for lab 4 batteries bulbs and current - Do you think that technology is helping over society more or harming it more? In what ways? - What is a1 size - Preesall gas storage project - Administrative closure in project management - Entrepreneurship theory process practice 4th edition - MACROECONOMIC POLICY - Topic: Discussion - Value - Discussion - Cloud computing assignment 1 - SCM Essay - Personal pedi by laurant directions - Critical Analysis - Apple inc corporate social responsibility - 132 divided by 11 - Businessballs com multiple intelligence test - Churchill avenue medical centre - TUTORS ONLY - Cosmeo make a quake - To cut into very small cubes of even size - Sinclair hand priming tool