Commit 2e318113 authored by michael lundquist's avatar michael lundquist
Browse files

Adding these files to the package

parent 151ab5c7
Pipeline #3978 failed with stage
in 1 minute and 23 seconds
package com.ds.fourthassignment;
public class CircularLinkedList {
private LNode head;
private LNode tail;
private int size;
public CircularLinkedList(){
head= null;
tail = null;
size =0;
}
public void addToHead(LNode newNode){
//adding to head:
if(head==null){
head = newNode;
tail = head;
}
else{
//update head
newNode.setNext(head);
tail.setNext(newNode);
head = newNode;
}
size++;
}
public void addToTail(LNode newNode){
if(tail==null){
tail = newNode;
head= tail;
}
else{
//update tail
tail.setNext(newNode);
newNode.setNext(head);
tail = newNode;
}
size++;
}
public String display(){
String out="";
if (head==null) return null;
LNode current = head;
do{
out+=current.getData() +",";
if (current==tail) break;
current = current.getNext();
}while(current!=null);
return out;
}
public boolean isEmpty(){ return (head==null ? true : false); }
public int getSize() { return size; }
}
\ No newline at end of file
package com.ds.fourthassignment;
public class DoublyLNode {
private String data;
......
package com.ds.fourthassignment;
public class DoublyLinkedList {
private DoublyLNode head;
......
package com.ds.fourthassignment;
public class LNode {
Integer data;
......
package com.ds.fourthassignment;
public class TNode {
private Scientist data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment