-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
55 lines (42 loc) · 1.13 KB
/
Main.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
51
52
53
54
55
/**
* File Name: Main.java
*
* Software Quality Assurance Corporation
* Code Review Project
*
* (c) Copyright 2023 SQAC
* ALL RIGHTS RESERVED
*
* Functional description: This class demonstrates the working of the
* singly-linked list SSL implementation.
*
* Input: None.
* Output: None except error messages.
* Supported Requirements: TBD
* Classes in this file: this class
* Related Documents: None; this file provides in-code documentation.
* Update History:
* Error Messages:
* Constraints: None.
* Assumptions: None.
**/
package sll;
public class Main {
public static void main(String[] args) {
SinglyLinkedList sll=new SinglyLinkedList();
// inserting 10 elements
for(int i=9; i>=0; i--) {
Node node=new Node(""+i);
sll.insert(node, sll.head());
}
System.out.println(sll);
// insert 20 before 5
Node n5=sll.find("5");
sll.insert(new Node("20"), n5);
System.out.println(sll);
// delete 6
Node n6=sll.find("6");
sll.remove(n6);
System.out.println(sll);
}
}