Skip to content

Commit f710f3a

Browse files
authored
Update ListAddnFun
1 parent 1ef46db commit f710f3a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

DataStructures/Lists/ListAddnFun

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
package DataStructures.Lists;
2+
3+
/*
4+
* This class implements a SinglyLinked List.
5+
* A linked list is similar to an array, it hold values.
6+
* However, links in a linked list do not have indexes. With
7+
* a linked list you do not need to predetermine it's size as
8+
* it grows and shrinks as it is edited.
9+
*it has functions called mid that gives node at mid
10+
* in addn to linked list there is algo that
11+
* construct a linked list with alternate sums of linked list
12+
* and added to new one and add mid value
13+
* i.e sum of first and last value of inital list
14+
15+
Test Case:
16+
17+
18+
LinkedList LL1 = new LinkedList();
19+
Scanner scn=new Scanner(System.in);
20+
int numNodes=scn.nextInt();
21+
for(int i=0;i<2*numNodes;i++) {
22+
LL1.addLast(scn.nextInt());
23+
}
24+
LL1.display();
25+
LinkedList LL2=new LinkedList();
26+
LL2.formLL2(LL1);
27+
LL2.display();
28+
LinkedList LL3=new LinkedList();
29+
LL3.formLL3(LL1);
30+
LL3.display();
31+
Node MID=LL1.midValue();
32+
System.out.println(MID.data);
33+
LinkedList updLL1=new LinkedList();
34+
updLL1.formRes(LL1,LL2,LL3,MID);
35+
updLL1.display();
36+
updLL1.Size();
37+
38+
*/
39+
40+
41+
142
import java.util.*;
243
import java.lang.*;
344
import java.io.*;

0 commit comments

Comments
 (0)