SLL - import java.util.Scanner; /* * @author Vujita * */...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Scanner; i /** * @author Vujita * */ public class SLL { public static DNode head; public static DNode token; public static long size; public static void Print(DNode a){ for(int c =0; c<size;c++){ System.out.print(a.getElement() + " "); a = a.getNext(); } System.out.println(); } public static DNode insert(int num,DNode j){ token = j; DNode prev = j; size++; boolean done = false; if(j == null){// if j is equal to null this is first val so send back the constructor that instantiated first DNode j = (new DNode(num,null)); return j; } while(!done){ if(token == null){ token = new DNode(num,null); prev.setNextNod(token); } else if(num > token.getElement()){ prev = token;//previous slot kept, to point to next spot for next insertion token = token.getNext();// increment next spot for check for insertio } else{ token = new DNode(num,token.getNext()); prev.setNextNod(token); done = true; } } return j; } public static DNode remove(int n1,DNode k){ p token = k; boolean exit = false;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

SLL - import java.util.Scanner; /* * @author Vujita * */...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online