Skip to content

Commit f9091b0

Browse files
committed
Commiting Linked List
1 parent 4d75254 commit f9091b0

File tree

80 files changed

+2006
-0
lines changed

Some content is hidden

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

80 files changed

+2006
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1.26 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
2.03 KB
Binary file not shown.
1.01 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
417 Bytes
Binary file not shown.
275 Bytes
Binary file not shown.
1.17 KB
Binary file not shown.

CodePractice/bin/queues/MyQueue.class

1.33 KB
Binary file not shown.
594 Bytes
Binary file not shown.
414 Bytes
Binary file not shown.
397 Bytes
Binary file not shown.
1.13 KB
Binary file not shown.
389 Bytes
Binary file not shown.
395 Bytes
Binary file not shown.
383 Bytes
Binary file not shown.
1.12 KB
Binary file not shown.
1.4 KB
Binary file not shown.
1.42 KB
Binary file not shown.
988 Bytes
Binary file not shown.
722 Bytes
Binary file not shown.
1.2 KB
Binary file not shown.
1.01 KB
Binary file not shown.
3.1 KB
Binary file not shown.
408 Bytes
Binary file not shown.

CodePractice/bin/stacks/MyStack.class

1.53 KB
Binary file not shown.
414 Bytes
Binary file not shown.
Binary file not shown.
414 Bytes
Binary file not shown.
1010 Bytes
Binary file not shown.
725 Bytes
Binary file not shown.
302 Bytes
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package generealRecursion;
2+
3+
public class CombinationsOfAString {
4+
5+
/**
6+
* @param args
7+
*/
8+
public static void main(String[] args) {
9+
// TODO Auto-generated method stub
10+
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package generealRecursion;
2+
3+
public class IsArrayInSortedRec {
4+
5+
public static boolean isSorted(int[] arr, int n){
6+
if(n == 0){
7+
return true;
8+
}else{
9+
return arr[n] > arr[n-1] ? isSorted(arr, n-1): false;
10+
}
11+
}
12+
public static void main(String[] args) {
13+
int [] a = {3,5,4,1,2};
14+
int []b = {1,2,3,4,5};
15+
System.out.println(isSorted(b, b.length -1));
16+
}
17+
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package generealRecursion;
2+
3+
public class PermutaionOfAString {
4+
5+
/**
6+
* @param args
7+
*/
8+
public static void main(String[] args) {
9+
// TODO Auto-generated method stub
10+
11+
}
12+
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package generealRecursion;
2+
3+
public class TowerOfHanoi {
4+
5+
public static void solve(int n, String source, String auxillary, String destination){
6+
if(n == 1){
7+
System.out.println(source +" to "+ destination);
8+
}else{
9+
solve(n-1, source, destination, auxillary);
10+
System.out.println(Integer.toString(n)+" "+source +" to "+ destination);
11+
solve(n-1, auxillary, source, destination);
12+
}
13+
14+
}
15+
16+
public static void main(String[] args) {
17+
// TODO Auto-generated method stub
18+
solve(4, "S","B","C");
19+
}
20+
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package myLinkedList;
2+
3+
public class CircularLinkedList {
4+
Node head = null;
5+
int length = 0;
6+
7+
public CircularLinkedList(){
8+
head = null;
9+
}
10+
public CircularLinkedList(Object data){
11+
head.data = data;
12+
head.next = head;
13+
length++;
14+
}
15+
16+
public int countNodes(){
17+
Node curNode = head;
18+
if (head == null) return 0;
19+
int count = 1;
20+
while(curNode.next != head){
21+
count++;
22+
curNode = curNode.next;
23+
}
24+
return count;
25+
}
26+
27+
public String toString(){
28+
StringBuffer strBuf = new StringBuffer("");
29+
Node curNode = head;
30+
strBuf.append(head.data.toString());
31+
while(curNode.next != head){
32+
curNode = curNode.next;
33+
strBuf.append(curNode.data.toString()+" ");
34+
}
35+
strBuf.append(curNode.data.toString());
36+
return strBuf.toString();
37+
}
38+
39+
public void insertAtTheStart(Object data){
40+
Node newNode = new Node(data);
41+
newNode.next = head;
42+
Node curNode = head;
43+
while(curNode.next != head){
44+
curNode = curNode.next;
45+
}
46+
curNode.next = newNode;
47+
head = newNode;
48+
}
49+
50+
public void insertAtTheEnd(Object data){
51+
Node newNode = new Node(data);
52+
newNode.next = head;
53+
Node curNode = head;
54+
while(curNode.next != head){
55+
curNode = curNode.next;
56+
}
57+
curNode.next = newNode;
58+
}
59+
60+
public void deleteFront(){
61+
if(head == null) return;
62+
if(head.next == head){
63+
head = null;
64+
return;
65+
}
66+
Node curNode = head.next;
67+
while(curNode.next != head){
68+
curNode = curNode.next;
69+
}
70+
curNode.next = head.next;
71+
head = head.next;
72+
}
73+
74+
public void deleteLast(){
75+
if(head == null) return;
76+
if(head.next == head){
77+
head = null;
78+
return;
79+
}
80+
Node curNode = head;
81+
while(curNode.next.next != head){
82+
curNode = curNode.next;
83+
}
84+
curNode.next = head;
85+
}
86+
}
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package myLinkedList;
2+
3+
public class DDLNode {
4+
Object data;
5+
DDLNode prev;
6+
DDLNode next;
7+
public DDLNode(Object data){
8+
this.data = data;
9+
next = null;
10+
prev = null;
11+
}
12+
public DDLNode(Object data, DDLNode prev, DDLNode next){
13+
this.data = data;
14+
this.prev = prev;
15+
this.next = next;
16+
}
17+
public Object getData(){
18+
return this.data;
19+
}
20+
public void setData(Object data){
21+
this.data = data;
22+
}
23+
public DDLNode getPrev(){
24+
return this.prev;
25+
}
26+
public void setPrev(DDLNode node){
27+
this.prev = node;
28+
}
29+
public DDLNode getNext(){
30+
return this.next;
31+
}
32+
public void setNext(DDLNode node){
33+
this.next = node;
34+
}
35+
public String toString(){
36+
return this.data.toString();
37+
}
38+
}

0 commit comments

Comments
 (0)