-
Notifications
You must be signed in to change notification settings - Fork 28
/
LinkedListDemo.java
50 lines (37 loc) · 1.09 KB
/
LinkedListDemo.java
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
package ds_002_linkedlists;
public class LinkedListDemo {
public static void main(String[] args) {
LinkedList list = new LinkedList();
System.out.println("Is Empty: " + list.isEmpty());
System.out.println("Size : " + list.size());
System.out.println("Index of 5: " + list.find(5));
System.out.println("Index of 7: " + list.find(7));
// Insert At End
list.insertAtEnd(8);
list.printList2();
// Insert At Top
list.insertAtTop(7);
list.insertAtTop(5);
list.insertAtTop(3);
list.printList2();
// Insert At Middle
list.insertAtIndex(2, 6);
list.printList2();
// Insert At End
list.insertAtEnd(9);
list.printList2();
// Remove From Beginning
list.removeFromBeginning();
list.printList2();
// Remove From End
list.removeFromEnd();
list.printList2();
// Remove From Middle
list.removeFromMiddle(6);
list.printList2();
System.out.println("Is Empty: " + list.isEmpty());
System.out.println("Size : " + list.size());
System.out.println("Index of 5: " + list.find(5));
System.out.println("Index of 7: " + list.find(7));
}
}