-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBalancedChecker.java
More file actions
59 lines (46 loc) · 1.03 KB
/
Copy pathBalancedChecker.java
File metadata and controls
59 lines (46 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package stacks;
import java.util.ArrayList;
public class IDLList<E> {
public class Node<E> {
//Data Fields
E data;
Node<E> next;
Node<E> prev;
//Constructors
//Creates a new node holding elem as it's data, with next and previous null
Node(E elem){
data = elem;
next = null;
prev = null;
}
//Creates a new node holding elem as it's data, and next and prev are assigned accordingly
Node(E elem, Node<E> prev, Node<E> next){
data = elem;
this.prev = prev;
this.next = next;
}
}
//Data Fields
Node<E> head;
Node<E> tail;
int size;
ArrayList<Node<E>> indices;
//Constructors
//Creates an empty Double Linked List
IDLList(){
head = null;
tail = null;
size = 0;
indices = null;
}
//Methods
public boolean add(E elem){
head = new Node<E>(elem, null, head);
size++;
return true;
}
public static void main(String[] args){
IDLList<Integer> i = new IDLList<Integer>();
System.out.println(i.add(1));
}
}