Skip to content

Commit 3566cd6

Browse files
authored
Add files via upload
1 parent 63d879c commit 3566cd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1977
-0
lines changed

ArrayList.class

1.01 KB
Binary file not shown.

ArrayList.java

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import java.util.Collection;
2+
3+
//ARRAYLIST
4+
//SIZE can be varry
5+
//we can add lots of elements
6+
//in ARRAYLIST we can store primitives; i.e int & floate
7+
//ARRAYLIST Heap ke andar banti hai;
8+
/*
9+
some oparations
10+
1. add
11+
2.get
12+
3.modified
13+
4. delete/ remove;
14+
5.iterate/ performing oparation
15+
*/
16+
// ARRAYLIST impliment krne se pehle ek package ko import krna padta hai jiska nam hai <java.util.ArrayList>
17+
18+
//BASICALLI SEARCH KE LIYE ARRAYLIST USE KRTE HAI
19+
import java.util.*;
20+
21+
public class ArrayList {
22+
public static void main(String[] args) {
23+
24+
java.util.ArrayList<Integer> list = new java.util.ArrayList<>();
25+
26+
// ADD ELEMENTS
27+
list.add(0); // elements ko hamne ADD kiya ;;
28+
list.add(1);
29+
list.add(4);
30+
31+
System.out.println(list);
32+
33+
// GET ELEMENTS
34+
35+
int element = list.get(2); // elements get kar diya ... badme use element me save kiya aur use . print kr
36+
// diya ;;;
37+
System.out.println(element);
38+
39+
// ADD ELEMENT IN BETWEEN
40+
list.add(2, 50); // in between add krne ke liye hamne () me pehle index li position add kr li aur
41+
// badme elements add kar diya;;
42+
System.out.println(list);
43+
44+
// SET ELEMENTS
45+
// set me ham pehle wale index ko change kr dete hai;;
46+
47+
list.set(1, 40); // index 1 pe hamne 40 add kr diya;;
48+
System.out.println(list);
49+
50+
// DELETE ELEMENTS
51+
list.remove(2); // index 2 matlab 3rd position wala element hamne remove kr diya ;;
52+
System.out.println(list);
53+
54+
// HOW MANY ELEMENTS ARE STORE IN ELEMENTS ;;
55+
// SIZE
56+
int size = list.size();
57+
System.out.println(size);
58+
59+
// ITERATE KARNA
60+
// loops
61+
for (int i = 0; i < list.size(); i++) {
62+
System.out.print(list.get(i));
63+
}
64+
System.out.println();
65+
66+
// SORTIG
67+
// ASSENDING OR DECENDING ORDER ME ARRENGE KRANA MATLAB SORTING KARNA ;;
68+
// ISME AUTOMATICALLY HAM ARRAY KO ASSENDING ORDER ME ARRENGE KR SAKTE HAI;;
69+
// SO THE FUNCTIONS IS
70+
71+
Collections.sort(list); // is function se arraylist assending order me print ho jati hai;;
72+
73+
System.out.println(list);
74+
75+
}
76+
77+
}

Integers.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
public class Integers {
3+
4+
}

LL_COLLECTION_FRAMEWORL.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
///collection frame work ko use krke classes hame pehle hi mil jati hai
2+
// classes scraches se nahi banani padti
3+
// code pura available hota hai ..sift un tool ko use karna hota hai;;;
4+
5+
import java.lang.invoke.VarHandle.VarHandleDesc;
6+
import java.util.*;
7+
8+
public class LL_COLLECTION_FRAMEWORL {
9+
10+
public static void main(String[] args) {
11+
LinkedList<String> list = new LinkedList<>();
12+
list.addFirst("is");
13+
list.addFirst("varad");
14+
list.addFirst("a");
15+
list.addLast("good");
16+
17+
System.out.println(list.size());
18+
19+
System.out.println(list);
20+
21+
for (int i = 0; i < list.size(); i++) {
22+
System.out.print(list.get(i) + "-->"); // .get ham likhate hai jab hame element chahiye hota hai;;
23+
}
24+
System.out.println(" ");
25+
26+
// list.removeFirst();
27+
// list.removeLast();
28+
// System.out.println(list);
29+
list.remove(3);
30+
31+
System.out.println(list);
32+
33+
}
34+
}

LinkList.java

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
//PROPERTIES OF LINKLIST
2+
//1. variable sixe
3+
//2. non-contiguous memory
4+
//3. insert in 0(1)
5+
//4. search in 0(n)
6+
7+
//NODE
8+
// NODE store 2 information
9+
//1. data...2. reference
10+
11+
//HEAD means ll ka pehta point amd tail means last elements
12+
13+
//type pf LL
14+
//1. SINGULAR....2.DOUBLE ENDED...3.CIRCULAR ...
15+
16+
//BASICALLI INSERTION KE LITE LINKLIST USE KRNA CHAHIYE
17+
18+
public class LinkList {
19+
node head;
20+
private int size; //private size ka int banaya
21+
22+
LinkList(){
23+
this.size =0; //size ko initialize 0 se kr diya ;;;
24+
}
25+
26+
class node { // node cclass bana li hamne
27+
String data;
28+
node next;
29+
30+
31+
node(String data) { // CONSTRUCTOR bana liya
32+
this.data = data;
33+
this.next = null;
34+
size++;
35+
36+
}
37+
38+
39+
}
40+
41+
// ADD--1.FIRST...2.LAST
42+
//add first
43+
public void addfirst(String data) {
44+
node newnode = new node(data); //ek newnode banaya
45+
if (head == null) {
46+
head = newnode;
47+
return;
48+
}
49+
50+
newnode.next = head; //head ko new node ke next me dal dila;;;matlab head ek kadam aage gaya
51+
head = newnode; //badme new node ko hi head bana diya;;
52+
53+
}
54+
55+
// ADD LAST
56+
public void addlast(String data) {
57+
node newnode = new node(data);
58+
if (head == null) {
59+
head = newnode;
60+
return;
61+
}
62+
node currnode = head; //pehle currnode ko head banaya;;
63+
while (currnode.next != null) { //jabtak currnode ka head null nahi hota
64+
currnode = currnode.next; // currnode ka jo next hai usko currnode me dalneka
65+
66+
}
67+
currnode.next = newnode; //currnpde ka next jo hai usko newnode bananeka;;
68+
69+
}
70+
71+
// print
72+
public void printlist() {
73+
if (head == null) {
74+
System.out.println(" LL is empty");
75+
return;
76+
}
77+
node currnode = head;
78+
while (currnode != null) {
79+
System.out.print(currnode.data + "-->");
80+
currnode = currnode.next;
81+
82+
}
83+
System.out.println("null");
84+
}
85+
86+
// DELETE
87+
// first ko delete karna hai to first ke next ko head banana hoga
88+
// last ko agr delete karna hai ..to next-next karna hai aur jaise hi second
89+
// last node tak pohochenge .
90+
// to second last node ko null bana lenge
91+
// delete first
92+
public void deletefirst() {
93+
if (head == null) {
94+
System.out.println("LL is empty");
95+
return;
96+
97+
98+
}
99+
size--; //delete hone ke bad size ko kam karna padega
100+
head = head.next; // head.next ko head banaya to head carbej ho gya
101+
}
102+
103+
public void deletelast() {
104+
if (head == null) {
105+
System.out.println("LL is empty");
106+
return;
107+
}
108+
size --; ////delete hone ke bad size ko kam karna padega
109+
node seclast = head; // head ko sechead banaya
110+
node lastnode = head.next; // head next ko last node banaaya
111+
112+
if (head.next == null) { // jisme LL me ek hi node hoga //next karte wakt null ka next null nahi ho sakta
113+
head = null;
114+
return;
115+
}
116+
117+
while (lastnode.next != null) { // jabtak last node null nahi ho jata
118+
lastnode = lastnode.next; // lastnode next ko last node me dalneka
119+
seclast = seclast.next; // aur seclast node ke next ko sec last me dalneka jo ki head banaya hai
120+
121+
}
122+
seclast.next = null;
123+
// lastnode = null;
124+
125+
}
126+
public int getsize(){
127+
return size;
128+
}
129+
130+
131+
132+
133+
134+
public static void main(String[] args) {
135+
LinkList list = new LinkList();
136+
137+
list.addfirst("is");
138+
list.addfirst("varad");
139+
list.addfirst("a");
140+
list.printlist();
141+
142+
list.addlast("good");
143+
list.printlist();
144+
list.addlast("but");
145+
list.addlast("not");
146+
list.addlast("not");
147+
148+
list.deletelast();
149+
list.deletefirst();
150+
list.deletelast();
151+
list.deletelast();
152+
list.printlist();
153+
list.addfirst("a");
154+
155+
list.addlast("so");
156+
list.printlist();
157+
System.out.println(list.size);
158+
159+
}
160+
161+
}

LinkList_reverse$node.class

448 Bytes
Binary file not shown.

LinkList_reverse.class

2.39 KB
Binary file not shown.

0 commit comments

Comments
 (0)