Language is in java.
package com.cse.ds;
public class Song<E> {
E data;
Song next;
Song prev;
/** Constructor to create singleton Song */
public Song(E element)
{
}
/** Constructor to create singleton link it between previous and next
* @param element Element to add, can be null
* @param prevSong predecessor Song, can be null
* @param nextSong successor Song, can be null
*/
public Song(E element, Song prevSong, Song nextSong)
{
//To be implemented
}
/** Remove this Song from the list. Update previous and next Songs */
public void remove()
{
//To be implemented
}
/** Set the previous Song in the list
* @param p new previous Song
*/
public void setPrev(Song p)
{
//To be implemented
}
/** Set the next Song in the list
* @param n new next Song
*/
public void setNext(Song n)
{
//To be implemented
}
/** Set the element
* @param e new element
*/
public void setElement(E e)
{
//To be implemented
}
/** Accessor to get the next Song in the list */
public Song getNext()
{
return null; // XXX-CHANGE-XXX
}
/** Accessor to get the prev Song in the list */
public Song getPrev()
{
return null; // XXX-CHANGE-XXX
}
/** Accessor to get the Songs Element */
public E getElement()
{
return null;// XXX-CHANGE-XXX
}
}
public class Song<E> {
E data;
Song next;
Song prev;
/** Constructor to create singleton Song */
public Song(E element)
{
data = element;
next = null;
prev = null;
}
/**
* Constructor to create singleton link it between
previous and next
*
* @param element
* Element to add, can be null
*
* @param prevSong
* predecessor Song, can be null
*
* @param nextSong
* successor Song, can be null
*
*/
public Song(E element, Song prevSong, Song nextSong)
{
//assigning the values
data=element;
next=nextSong;
prev=prevSong;
// To be implemented
}
/** Remove this Song from the list. Update previous and next Songs */
public void remove()
{
// storing prev in temp
Song temp=prev;
//making prev node next =current node next
temp.next=next;
//setting next node prev=prev node
next.prev=temp;
//making null for both
next=null;
prev=null;
// To be implemented
}
/**
* Set the previous Song in the list
*
* @param p
* new previous Song
*
*/
public void setPrev(Song p)
{
prev=p;
// To be implemented
}
/**
* Set the next Song in the list
*
* @param n
* new next Song
*
*/
public void setNext(Song n)
{
next=n;
// To be implemented
}
/**
* Set the element
*
* @param e
* new element
*
*/
public void setElement(E e)
{
// To be implemented
data=e;
}
/** Accessor to get the next Song in the list */
public Song getNext()
{
return next; // XXX-CHANGE-XXX
}
/** Accessor to get the prev Song in the list */
public Song getPrev()
{
return prev; // XXX-CHANGE-XXX
}
/** Accessor to get the Songs Element */
public E getElement()
{
return data;// XXX-CHANGE-XXX
}
}
Language is in java. package com.cse.ds; public class Song<E> { E data; Song next; Song prev;...
In Java Language. Modify the LinkedPostionalList class to support a method swap(p,q) that causes the underlying nodes referenced by positions p and q to be exchanged for each other. Relink the existing nodes, do not create any new nodes. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- package lists; import java.util.Iterator; import java.util.NoSuchElementException; public class LinkedPositionalList implements PositionalList { //---------------- nested Node class ---------------- /** * Node of a doubly linked list, which stores a reference to its * element and to both the previous and next...
public class myLinkedList<E extends Comparable<E>>{ private Node<E> head = null; private Node<E> tail = null; public myLinkedList() { head = null; } public void concatenateList (myLinkedList<E> M) {//attach another linkedList refered by M to the end of this linkedList } public int searchElement (E targetElement){//test if a target element can be found on the list, return the occurrences of the target element ...
JAVA - Circular Doubly Linked List Does anybody could help me with this method below(previous)? public E previous() { // Returns the previous Element return null; } Explanation: We have this class with these two implemented inferfaces: The interfaces are: package edu.ics211.h04; /** * Interface for a List211. * * @author Cam Moore * @param the generic type of the Lists. */ public interface IList211 { /** * Gets the item at the given index. * @param index the index....
Java Programming: The following is my code: public class KWSingleLinkedList<E> { public void setSize(int size) { this.size = size; } /** Reference to list head. */ private Node<E> head = null; /** The number of items in the list */ private int size = 0; /** Add an item to the front of the list. @param item The item to be added */ public void addFirst(E...
solve this Q in java languege Write a method that return DoublyLinkedList as reversed string For example: If the elements of a list is 1, 2, 3, 4, 5, 6 the reverse string should be 6, 5, 4, 3, 2, 1 implement reverse method you have two steps: 1- you should start traversing from the last element of DoublyLinkedList (the previous of the trailer) 2- you should add the element inside each node to string don't forget the space in...
Please answer in Java. The code that needs to be modified is below. Thank you. Question: Implement Doubly Linked List add method which add an element to a specific position. - It’s an instance method that takes a position and an element, then adds the element to this specific position and shifts the element currently at this position and any subsequent elements to the right. It throws an exception if the position is out of bound. It traverses the list...
Using a doubly linked list as the underlying data structure, implement a list ADT that implements the ListInterface.java found in the ProgProjTwo Eclipse project starting point for this assignment. In addition to the forward iterator defined by resetIterator( ) and getNextItem( ) in ListInterface.java, implement a backwards iterator by providing resetBackIterator( ) and getPreviousItem( ) methods. As noted in the syllabus addendum, you are encouraged to develop a find( ) helper method that can support various list ADT operations. A...
Here is the IntegerLinkedList_incomplete class: public class IntegerLinkedList { static class Node { /** The element stored at this node */ private int element; // reference to the element stored at this node /** A reference to the subsequent node in the list */ private Node next; // reference to the subsequent node in the list /** * Creates a node with the given element and next node. * * @param e the element to be stored * @param n...
Complete P16.1 and P16.4 (Class Name: NewMethodDemo) Once complete, upload all .java files. For primary test class: Remember your header with name, date, and assignment. Also include class names that will be tested. Psuedocode (level 0 or mixture of level 0 and algorithm [do not number steps]) is required if main() contains more than simple statements (for example, your program includes constructs for decisions (if/else), loops, and methods. For Secondary class(es): Include a JavaDoc comment that describes the purpose of...
Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements DoubleEndedList { private Node front; // first node in list private Node rear; // last node in list private int size; // number of elements in list ////////////////////////////////////////////////// // YOU MUST IMPLEMENT THE LOCATE METHOD BELOW // ////////////////////////////////////////////////// /** * Returns the position of the node containing the given value, where * the front node is at position zero and the rear node is...