Skip to content

Commit d2e9f05

Browse files
committed
Changed names according to suggestions
1 parent d1b4c1e commit d2e9f05

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/main/java/com/thealgorithms/datastructures/graphs/BipartiteGrapfDFS.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,23 @@ public static void main(String[] args) throws IOException {
5454
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
5555
int t = Integer.parseInt(read.readLine().trim());
5656
while (t-- > 0) {
57-
String[] str = read.readLine().trim().split(" ");
58-
int a = Integer.parseInt(str[0]);
59-
int b = Integer.parseInt(str[1]);
57+
String[] str1 = read.readLine().trim().split(" ");
58+
int numVertices = Integer.parseInt(str1[0]);
59+
int numEdges = Integer.parseInt(str1[1]);
6060

6161
ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
62-
for (int i = 0; i < a; i++) {
62+
for (int i = 0; i < numVertices; i++) {
6363
adj.add(new ArrayList<>());
6464
}
65-
for (int i = 0; i < b; i++) {
66-
String[] s = read.readLine().trim().split(" ");
67-
int u = Integer.parseInt(s[0]);
68-
int v = Integer.parseInt(s[1]);
69-
adj.get(u).add(v);
70-
adj.get(v).add(u);
65+
for (int i = 0; i < numEdges; i++) {
66+
String[] str2 = read.readLine().trim().split(" ");
67+
int vertexU = Integer.parseInt(str2[0]);
68+
int vertexV = Integer.parseInt(str2[1]);
69+
adj.get(vertexU).add(vertexV);
70+
adj.get(vertexV).add(vertexU);
7171
}
7272

73-
boolean ans = isBipartite(a, adj);
73+
boolean ans = isBipartite(numVertices, adj);
7474
if (ans) {
7575
System.out.println("YES");
7676
} else {

src/main/java/com/thealgorithms/datastructures/lists/ReverseKGroup.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ public Node reverse(Node head, int count, int k) {
2323
Node prev = null;
2424
int count1 = 0;
2525
Node curr = head;
26-
Node nxt = null;
26+
Node next = null;
2727
while (curr != null && count1 < k) {
28-
nxt = curr.next;
28+
next = curr.next;
2929
curr.next = prev;
3030
prev = curr;
31-
curr = nxt;
31+
curr = next;
3232
count1++;
3333
}
3434

35-
if (nxt != null) {
36-
head.next = reverse(nxt, count - k, k);
35+
if (next != null) {
36+
head.next = reverse(next, count - k, k);
3737
}
3838
return prev;
3939
}

src/main/java/com/thealgorithms/datastructures/trees/PrintTopViewofTree.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public void printTopView() {
6060
HashSet<Integer> set = new HashSet<>();
6161

6262
// Create a queue and add root to it
63-
Queue<QItem> qN = new LinkedList<QItem>();
64-
qN.add(new QItem(root, 0)); // Horizontal distance of root is 0
63+
Queue<QItem> queue = new LinkedList<QItem>();
64+
queue.add(new QItem(root, 0)); // Horizontal distance of root is 0
6565

6666
// Standard BFS or level order traversal loop
67-
while (!qN.isEmpty()) {
67+
while (!queue.isEmpty()) {
6868
// Remove the front item and get its details
69-
QItem qi = qN.remove();
69+
QItem qi = queue.remove();
7070
int hd = qi.hd;
7171
TreeNode n = qi.node;
7272

@@ -79,10 +79,10 @@ public void printTopView() {
7979

8080
// Enqueue left and right children of current node
8181
if (n.left != null) {
82-
qN.add(new QItem(n.left, hd - 1));
82+
queue.add(new QItem(n.left, hd - 1));
8383
}
8484
if (n.right != null) {
85-
qN.add(new QItem(n.right, hd + 1));
85+
queue.add(new QItem(n.right, hd + 1));
8686
}
8787
}
8888
}

0 commit comments

Comments
 (0)