Java computer science linked list

timer Asked: Jan 31st, 2016

Question description

1.For the following question - make sure you document it with comments in the code.
2.You must use classes Time1 and BusArrival - You can get those classes in the zip file attached OR here -
3.Also make sure that for each method you have a documentation in the header.
4.Make sure that the name of the methods would be exactly as written.
5.The result is 1 file - zipped inside a file.
6.Write as a comment on the API what is the time complexity and the place complexity of every method you wrote.

Question 1:

Class BusArrivalNode represents a single item in the linked list.

Class will include the two attributes:

1. BusArrival  _busArr

2. BusArrivalNode  _next

U must write the constructors and the methods that are necessary in class.

For this class you have to define three constructors:

1. public BusArrivalNode (BusArrival b)

Receive the bus arrival (an object from class BusArrival) next_ field will be set to null.

2. public BusArrivalNode (BusArrival b, BusArrivalNode n)

Gets the bus arrival (object from class BusArrival) and another item n from type BusArrivalNode. The constructor would init the attributes by the given parameters. _next field will point to n.

3. public BusArrivalNode (BusArrivalNode b)

Copy constructor. Notice you have to copy the information (next) itself and not a copy of the pointer. Which means  in this case aliasing is the right thing.

The methods in class BusArrivalNode are:

* public BusArrival getBusArr() – returns a copy of the bus arrival.

* public BusArrivalNode  getNext()- returns pointer to the next item. Notice that aliasing is not a mistake here either. You need to return the pointer next and not a copy of the pointer.

* public void aetBusArr (BusArrival b) - receives the bus arrival and update the arrival attribute in the vertex.

* public void setNext(BusArrivalNode  next) - receives a pointer and update the pointer attribute to the next item. Notice that aliasing is not a mistake here either. You need to update the information (next) itself and not a copy.

Tutor Answer

(Top Tutor) Studypool Tutor
School: University of Maryland
Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors