1. Homepage
  2. Coding
  3. PITT CS445 Algorithms and Data Structures I Project 2: LinkedDS

PITT CS445 Algorithms and Data Structures I Project 2: LinkedDS

Order Now
PITTCS445CS0445Algorithms and Data Structures ILinkedDSJava

Algorithms and Data Structures I Assignment Writing Service

Project 2: LinkedDS[1] Assignment Writing Service

Background

This project is designed to increase your experience with linked data structures. Similar to Project 1, you will work with control structures, class-building, interfaces, and generics to create a new linked data structure called a LinkedDS<T>. The LinkedDS<T> will implement the SequenceInterface<T>, so before doing anything else, take a look at the method comments in SequenceInterface.java. Assignment Writing Service

  Assignment Writing Service

After you finish reviewing SequenceInterface.java, take a look at the client code in Project2.java. Just like Project 1, you cannot modify any of the code in SequenceInterface.java or Project2.java. Assignment Writing Service

  Assignment Writing Service

As with most complicated programming assignments, there are multiple ways to implement the SequenceInterface<T> methods, some more efficient than others. The comments in SequenceInterface.java outline the running time (efficiency) requirements for your implementations. I 100% recommend pencil & paper work and drawing pictures to familiarize yourself with the algorithm you’d like to implement before you write any code. Assignment Writing Service

  Assignment Writing Service

Note: The primary data structure in your LinkedDS<T> must be a one-dimensional array of linked lists. You may not use any predefined Java collection class (e.g. ArrayList) for your LinkedDS<T> data fields. You may not declare any one-dimensional arrays except for the alphabet and for the return value of any methods that return an array (declaring a one-dimensional array and then resizing it before returning is OK). Assignment Writing Service

LinkedDS

Your LinkedDS<T> class header must be: Assignment Writing Service

  Assignment Writing Service

public class LinkedDS<T> implements SequenceInterface<T> {  Assignment Writing Service

  Assignment Writing Service

You must use the following instance variables inside the LinkedDS<T> class: Assignment Writing Service

  Assignment Writing Service

private Node[] array; // 1-D array of linked lists Assignment Writing Service

private int size; // the number of items in the sequence Assignment Writing Service

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

private T firstItem; //the first item Assignment Writing Service

private T lastItem; //the last item Assignment Writing Service

  Assignment Writing Service

The Node private inner class is already defined in LinkedDS.java:: Assignment Writing Service

  Assignment Writing Service

private static class Node { Assignment Writing Service

    private int item; //index in alphabet of item Assignment Writing Service

    private Node next; Assignment Writing Service

  Assignment Writing Service

    private Node(int item){ Assignment Writing Service

        this.item = item; Assignment Writing Service

        next = null; Assignment Writing Service

    } Assignment Writing Service

} Assignment Writing Service

  Assignment Writing Service

Besides the methods in SequenceInterface<T>, the following constructor is required: Assignment Writing Service

  Assignment Writing Service

public LinkedDS(T[] alphabet) Assignment Writing Service

  Assignment Writing Service

Here’s an example of how the LinkedDS should work using a 1D array of linked lists. Assignment Writing Service

  Assignment Writing Service

The alphabet for decimal digits is the same as it was in the example for Project 1: {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. Remember, your LinkedDS<T> must work on any generic type, not just decimal integers. Just like Project 1, let’s use the sequence 9875732732 as an example. This diagram shows how it would look in a LinkedDS: Assignment Writing Service

  Assignment Writing Service

  Assignment Writing Service

Each of the ten digits of the alphabet is represented by an array of Node objects. Each entry in the array is a Node that serves as the head of a linked list that contains the successors of an item in the sequence, stored by their position in the sequence in ascending order. In the example, the first two lists are empty because 0 and 1 are not in the example sequence (9875732732). Assignment Writing Service

  Assignment Writing Service

The Node at index 2 (which represents the decimal digit 2) has only one other node in its chain: a 7, meaning that the item at index 7 is what follows 2 in the sequence. There’s only one item in 2’s linked list because 2 is only succeeded by another number once in the sequence. The Node at index 7 (which represents the decimal digit 7) has three nodes because 7, in its three occurrences in 9875732732, is followed by 5, 3, and 3, in that order. Every pair of consecutive items in the sequence results in a node in the diagram. Assignment Writing Service

  Assignment Writing Service

The sequence 9875732732 has the following properties: Assignment Writing Service

  Assignment Writing Service

first() == 9 Assignment Writing Service

last() == 2 Assignment Writing Service

size() == 10 Assignment Writing Service

isEmpty() == false Assignment Writing Service

getFrequencyOf(3) == 2 Assignment Writing Service

getFrequencyOf(2) == 2 Assignment Writing Service

getFrequencyOf(7, 3) == 2 //73 appeared twice in the sequence Assignment Writing Service

successors(7) == {5, 3} //5 and 3 are the unique items that immediately follow 7 in the sequence Assignment Writing Service

  Assignment Writing Service

If we start with the example sequence 9875732732 and then call push(7), 7 will be inserted to the beginning of the sequence, it will become 79875732732, and this diagram shows the whole model: Assignment Writing Service

  Assignment Writing Service

Assignment Writing Service

Note that a Node containing 9 was inserted into the beginning of 7’s linked list. This is because 9 is now the first item that comes after a 7 in the sequence. Assignment Writing Service

  Assignment Writing Service

The sequence 79875732732 has the following properties: Assignment Writing Service

  Assignment Writing Service

first() == 7 Assignment Writing Service

last() == 2 Assignment Writing Service

size() == 11 Assignment Writing Service

isEmpty() == false Assignment Writing Service

getFrequencyOf(3) == 2 Assignment Writing Service

getFrequencyOf(2) == 2 Assignment Writing Service

getFrequencyOf(7, 3) == 2 //73 appeared twice in the sequence Assignment Writing Service

successors(7) == {9, 5, 3} //9, 5, and 3 are the unique items that immediately follow 7 in the sequence Assignment Writing Service

  Assignment Writing Service

After you have finished implementing LinkedDS<T>, the Project2.java test file should compile and run correctly and give the same output as shown in P2Out.txt. Just like Project 1, I strongly recommend that you stub out the code in Project2.java and test your methods incrementally, instead of all at once at the end. Assignment Writing Service

Starter Code

All starter code and example output is available for download from this folder: Assignment Writing Service

  Assignment Writing Service

Project 2 Starter Code Assignment Writing Service

  Assignment Writing Service

Deliverables

You are responsible for submitting: Assignment Writing Service

-       LinkedDS.java Assignment Writing Service

  Assignment Writing Service

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 Project2.java to test parts of your implementations at a time as you work). Assignment Writing Service

  Assignment Writing Service

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. Assignment Writing Service

Hints

-       To create an array of generic types (T) of size length, use this: T[] result = (T[])new Object[length]; Assignment Writing Service

-       Adding @SuppressWarnings("unchecked") above that line will prevent your compiler from warning you about the unchecked cast. Assignment Writing Service

-       Unlike our linked implementations in class, the Nodes here always contain ints as data. This is because the ints represent the index of the actual T item in the alphabet array. Assignment Writing Service

-       See file P2Out.txt to see how your output should look. As noted, your output when running Project2.java should be identical to this. Assignment Writing Service

-       Draw pictures! Drawing a picture of a linked chain will be much more helpful when debugging and deciding on an efficient way to implement the different methods. If you have access to a whiteboard, use it! If not, pencil & paper or a tablet will also work fine. Assignment Writing Service



[1] Adapted from Dr. Sherif Khattab and Dr. John Ramirez’s coursework Assignment Writing Service

联系辅导老师!
私密保护
WeChat 微信
PITT代写,CS445代写,CS0445代写,Algorithms and Data Structures I代写,LinkedDS代写,Java代写,PITT代编,CS445代编,CS0445代编,Algorithms and Data Structures I代编,LinkedDS代编,Java代编,PITT代考,CS445代考,CS0445代考,Algorithms and Data Structures I代考,LinkedDS代考,Java代考,PITT代做,CS445代做,CS0445代做,Algorithms and Data Structures I代做,LinkedDS代做,Java代做,PITThelp,CS445help,CS0445help,Algorithms and Data Structures Ihelp,LinkedDShelp,Javahelp,PITT作业代写,CS445作业代写,CS0445作业代写,Algorithms and Data Structures I作业代写,LinkedDS作业代写,Java作业代写,PITT编程代写,CS445编程代写,CS0445编程代写,Algorithms and Data Structures I编程代写,LinkedDS编程代写,Java编程代写,PITT作业答案,CS445作业答案,CS0445作业答案,Algorithms and Data Structures I作业答案,LinkedDS作业答案,Java作业答案,