Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 20d50c2

Browse filesBrowse files
committed
Pattern updates
1 parent 108aef7 commit 20d50c2
Copy full SHA for 20d50c2

39 files changed

+142
-151
lines changed

‎.idea/workspace.xml

Copy file name to clipboardExpand all lines: .idea/workspace.xml
+54-26Lines changed: 54 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

‎src/com/company/Lecture13/Queue.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture13/Queue.java
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.company.Lecture13;
22

3-
import com.company.Lecture5.ArrayIntro;
43

54
public class Queue {
65
private int[] data;

‎src/com/company/Lecture14/CircularQueue.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture14/CircularQueue.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void enqueue(int item){
4141
size++;
4242
return;
4343
}
44+
System.out.println("Queue overflow!!");
4445
}
4546

4647
public Integer dequeue(){

‎src/com/company/Lecture14/DynamicCircularQueue.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture14/DynamicCircularQueue.java
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public void enqueue(int item) {
88
for (int i = 0; i < data.length; i++) {
99
temp[i] = data[(i + this.front) % data.length];
1010
}
11+
this.data = temp;
1112
}
1213

1314
super.enqueue(item);

‎src/com/company/Lecture16/LinkedList.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture16/LinkedList.java
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,12 @@ public String delete(int index){
9595
public String findMid(){
9696
Node node = head;
9797
Node temp = head;
98-
while(temp.next != null && temp.next.next != null){
98+
while(temp.next != null &&
99+
temp.next.next != null){
99100
node = node.next;
100101
temp = temp.next.next;
101102
}
102-
103-
String mid = node.value;
104-
return mid;
103+
return node.value;
105104
}
106105

107106
public void reverseList(){
@@ -133,24 +132,18 @@ public static LinkedList merge(LinkedList first,LinkedList second){
133132
LinkedList list = new LinkedList();
134133
while (h1 != null && h2 != null){
135134
if(h1.value.compareTo(h2.value) < 0){
136-
// shift from h1
137135
list.insertLast(h1.value);
138136
h1 = h1.next;
139137
}else{
140-
// shift from h2
141138
list.insertLast(h2.value);
142139
h2 = h2.next;
143140
}
144141
}
145-
146142
while (h1 != null){
147-
// shift from h1
148143
list.insertLast(h1.value);
149144
h1 = h1.next;
150145
}
151-
152146
while (h2 != null){
153-
// shift from h2
154147
list.insertLast(h2.value);
155148
h2 = h2.next;
156149
}

‎src/com/company/Lecture17/LinkedListGeneric.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture17/LinkedListGeneric.java
+29-30Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public Node(T value, Node next){
2121
}
2222

2323
public void insertFirst(T value){
24-
Node node = new Node(value, head);
25-
head = node;
24+
head = new Node(value, head);
2625

2726
if(size == 0){
2827
tail = head;
@@ -106,34 +105,34 @@ public T delete(int index){
106105
return value;
107106
}
108107

109-
// public static LinkedListGeneric merge(LinkedListGeneric first, LinkedListGeneric second){
110-
// Node h1 = first.head;
111-
// Node h2 = second.head;
112-
//
113-
// LinkedListGeneric list = new LinkedListGeneric();
114-
//
115-
// while(h1 != null && h2 != null){
116-
// if(h1.value.compareTo(h2.value) < 0){
117-
// list.insertLast(h1.value);
118-
// h1 = h1.next;
119-
// }else{
120-
// list.insertLast(h2.value);
121-
// h2 = h2.next;
122-
// }
123-
// }
124-
//
125-
// while (h1 != null){
126-
// list.insertLast(h1.value);
127-
// h1 = h1.next;
128-
// }
129-
//
130-
// while (h2 != null){
131-
// list.insertLast(h2.value);
132-
// h2 = h2.next;
133-
// }
134-
//
135-
// return list;
136-
// }
108+
public LinkedListGeneric<T> merge(LinkedListGeneric<T> first, LinkedListGeneric<T> second){
109+
Node h1 = first.head;
110+
Node h2 = second.head;
111+
112+
LinkedListGeneric<T> list = new LinkedListGeneric<>();
113+
114+
while(h1 != null && h2 != null){
115+
if(h1.value.compareTo(h2.value) < 0){
116+
list.insertLast(h1.value);
117+
h1 = h1.next;
118+
}else{
119+
list.insertLast(h2.value);
120+
h2 = h2.next;
121+
}
122+
}
123+
124+
while (h1 != null){
125+
list.insertLast(h1.value);
126+
h1 = h1.next;
127+
}
128+
129+
while (h2 != null){
130+
list.insertLast(h2.value);
131+
h2 = h2.next;
132+
}
133+
134+
return list;
135+
}
137136

138137
public Node get(int index){
139138
Node node = head;

‎src/com/company/Lecture20/CustomHashSet.java

Copy file name to clipboardExpand all lines: src/com/company/Lecture20/CustomHashSet.java
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ public CustomHashSet(){
2020

2121
public void add(K key){
2222
int index = Math.abs(key.hashCode() % array.size());
23-
2423
LinkedList<Node> list = array.get(index);
2524
for (Node node : list){
2625
if(node.key.equals(key)){
2726
return;
2827
}
2928
}
30-
3129
size++;
3230
list.add(new Node(key));
33-
3431
if((((float)size)/array.size()) > .5){
3532
rehash();
3633
}
@@ -67,21 +64,17 @@ public boolean contains(K key){
6764

6865
public boolean remove(K key){
6966
int index = Math.abs(key.hashCode() % array.size());
70-
7167
LinkedList<Node> list = array.get(index);
72-
7368
Node target = null;
7469
for (Node node : list){
7570
if(node.key.equals(key)){
7671
target = node;
7772
break;
7873
}
7974
}
80-
8175
if(target == null){
8276
return false;
8377
}
84-
8578
list.remove(target);
8679
size--;
8780
return true;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.