代做Algorithms and Data Structures I Project 1: ReallyLongInt代写Java编程

Algorithms and Data Structures I

Project 1: ReallyLongInt

Background

Note: All starter files will be shared in a link at the end of this document.

In this project, we will use what we’ve reviewed about object-oriented programming in Java in combination with the Bag ADT from lecture to create and use a 2D array-based data structure.

Your Task: Design and implement a generic class (ArrayDS<T>) that will act as a data structure for accessing sequences of Java Objects. Your ArrayDS<T> class will primarily implement SequenceInterface<T>. The

details of this interface is explained in SequenceInterface.java  . Readthis over very carefully before implementing your ArrayDS<T> class.

ArrayDS

For the details on the functionality of your ArrayDS<T> class, carefully read over the files

SequenceInterface.java and Project1.java. You must use these files as specified and cannot remove/alter any of the code that is already written in them. There are different ways of implementing the

SequenceInterface<T> interface methods, some of which are more efficient than others. Try to think of the  best way of implementing these methods in this assignment, but the most important thing at this point is getting them to work correctly. A lot of pencil and paper work is recommended before actually starting to write     your code. Later we will discuss the relative merits of different implementations.

Important Note: The primary data within your ArrayDS<T> class must be a two-dimensional array. You may   not use any predefined Java collection class (e.g., ArrayList) for your ArrayDS<T> data fields. You may not declare and/or use any one-dimensional arrays except in the toArray() and hasSub sequence()

methods. Any methods besides these three will only be eligible for 50% credit if they are found to use one-dimensional arrays. This will be applied after the project is due!

You must use the following instance variables inside the ArrayDS<T> class:

private final BagInterface<Integer>[] [] array; //the underlying 2-D array

private int size ; //the number of items in the sequence

private T [] alphabet ; //the possible item values (e .g ., the decimal digits)

private T firstItem; //the first item in the sequence

private T lastItem; //the last item in the sequence

You should add other variables and named constants to follow the secure programming practices we mentioned in class.

To illustrate how to store a sequence of objects as a two-dimensional array, let's have an example.

Let's take the sequence 9875732732 as an example. This is a sequence of decimal digits. The sequence alphabet is the set of possible values from which the sequence items are drawn. So, in this example the alphabet is the set of decimal digits {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. This sequence can be visualized like this:

Each of the ten digits of the alphabet is represented by a circle. Every pair of consecutive digits in the sequence results in an arrow in the diagram, and the arrow's label includes the position of the second digit in the pair. For example, because 9 is followed by 8 in the sequence, there is an arrow from 9 to 8 in the diagram. Because the position of 8 in the sequence is 1, the arrow from 9 to 8 has 1 in its label. Because 3 is followed by 2 twice in the sequence, the arrow from 3 to 2 is labeled by 6 and 9, the positions of 2 in the sequence in both occurrences of 32 in the sequence.

To construct the sequence from the diagram, we follow the arrows starting from the firstItem (9), then 8   then 7. With each step, we keep track of our position in the sequence. At 7, we are at position 2 and we have  to decide whether to go to 3 or to 5. We go to 5 because of the label {3} of the arrow from 7 to 5, indicating   that 5 is at the next position (3). We keep following the arrows until we reach the last item. The circles that we will go through represent the sequence.

Here are some properties of the sequence in the example above. Please match these with the methods in SequenceInterface.java:

size() == 10

first() == 9

last() == 2

predecessor(8, 7) == true

predecessor(9, 2) == false

getFrequencyOf(3) == 2

itemAt(3) == 5

firstOccurenceOf(7) == 2

indexInAlphabet(3) == 3

nextIndex(7, 2) == 5

nextIndex(7, 7) == 3

prevIndex(2, 6) == 3

prevIndex(2, 9) == 3

hasSub sequence(732) == true

hasSub sequence( 983 ) == false

The diagram above (which, by the way, is called a graph) is represented as an NxN two-dimensional array, where N is the size of the alphabet, which is 10 in the example. The array representation of the diagram above is:

Each cell at row i and column j in the array contains the label of the arrow going from item i in the alphabet to item j in the alphabet. If there is no arrow between i and j, the cell is empty (null). Each cell is a BagInterface of Integers.

The sequence after append(7) will look like this:

 



Its array representation is:

After prefix(0): 



You will also need to override the following method. You might find it helpful to implement this first so you can use it while debugging your other methods:

public String toString() ;

This method will return a String that is the concatenation of all of the items in the Sequence implemented by the ArrayDS object appended together without spaces. For example, if an ArrayDS object contains the numbers 1, 2, 3, 4, 5, 6, toString() should output 123456.

To check your implementation of ArrayDS<T>, the Project1.java file should compile, run, and give output identical to P1Out.txt. Please note that this statement doesn't suggest that you delay testing until you are done with all the methods of ArrayDS. Instead, you should use stubs (comment out what you haven’t implemented  yet) and incrementally test your code using Project1.java as you complete each of the methods.

Starter Code

All starter code (including the shell of ArrayDS.java) and example output is available for download from this folder:

https://drive.google.com/drive/folders/1_Z85TGqy_noblGr3jhQBhR2gEnd12B7z?usp=sharing

Deliverables

You are responsible for submitting ONLY ArrayDS .java.  All other files will be automatically supplied to Gradescope. I would suggest avoiding making code changes to any of the other files (besides stubbing out Project1.java to test parts of your implementations at a time as you work).

If you use Eclipse or any other Java IDEs to work on this project, remember to test on a command line before submitting. Sometimes editors add package lines to the top of  .java files that will break the autograder.

Hints

-    See file P1Out.txt to see how your output for task A should look. As noted, your output when running

Project1.java should be identical to this.

-    In order for the Project1.java output to show correctly, you must override the toString() method in the ArrayDS class.

-    Think carefully about the order in which you implement ArrayDS methods as some methods can make others considerably easier to implement!





热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图