Skip to content

Commit 2a44ee3

Browse files
committed
fix: Various CI fixes
1 parent bac4e70 commit 2a44ee3

11 files changed

+42
-36
lines changed

backtracking/graph_coloring.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ void printSolution(int color[]);
1313
/* A utility function to check if the current color assignment
1414
is safe for vertex v */
1515
bool isSafe(int v, bool graph[V][V], int color[], int c) {
16-
for (int i = 0; i < V; i++)
16+
for (int i = 0; i < V; i++) {
1717
if (graph[v][i] && c == color[i]) {
1818
return false;
1919
}
20+
}
2021
return true;
2122
}
2223

@@ -73,7 +74,9 @@ int main() {
7374

7475
int color[V];
7576

76-
for (int i = 0; i < V; i++) { color[i] = 0 };
77+
for (int i = 0; i < V; i++) {
78+
color[i] = 0;
79+
}
7780

7881
graphColoring(graph, m, color, 0);
7982
return 0;

backtracking/knight_tour.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ int main() {
5757
cout << "solution doesnot exist \n";
5858
} else {
5959
for (i = 0; i < n; i++) {
60-
for (j = 0; j < n; j++) { cout << sol[i][j] << " " };
60+
for (j = 0; j < n; j++) {
61+
cout << sol[i][j] << " ";
62+
}
6163
cout << "\n";
6264
}
6365
}

data_structures/doubly_linked_list.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ int main() {
156156
break;
157157

158158
default:
159-
if (choice == 0) { return }
159+
if (choice == 0) { break; }
160160
std::cout << "Wrong option; type an option : ";
161161
std::cin >> choice;
162162

data_structures/linked_list.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int main() {
151151
break;
152152

153153
default:
154-
if (choice == 0) { return }
154+
if (choice == 0) { break; }
155155
std::cout << "Wrong option; type an option : ";
156156
std::cin >> choice;
157157

data_structures/list_array.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ int main() {
156156
break;
157157

158158
default:
159-
if (choice == 0) { return }
159+
if (choice == 0) { break; }
160160
std::cout << "Wrong option; type an option : ";
161161
std::cin >> choice;
162162

data_structures/morrisinorder.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ void insert(Btree **root, int d) {
2020
*root = nn;
2121
return;
2222
} else {
23-
queue<Btree *> q;
23+
std::queue<Btree *> q;
24+
2425
// Adding root node to queue
2526
q.push(*root);
2627
while (!q.empty()) {
@@ -59,7 +60,7 @@ void morrisInorder(Btree *root) {
5960
// Left of current node is stored in temp
6061
temp = curr->left;
6162
// Moving to extreme right of temp
62-
while (temp->right && temp->right != curr) { temp = temp->right };
63+
while (temp->right && temp->right != curr) { temp = temp->right; }
6364
// If extreme right is null it is made to point to currrent node
6465
// (will be used for backtracking)
6566
if (temp->right == nullptr) {
@@ -85,7 +86,9 @@ int main() {
8586
// Testing morrisInorder funtion
8687
Btree *root = nullptr;
8788
int i;
88-
for (i = 1; i <= 7; i++) { insert(&root, i) };
89+
for (i = 1; i <= 7; i++) {
90+
insert(&root, i);
91+
}
8992
std::cout << "Morris Inorder: ";
9093
morrisInorder(root);
9194
return 0;

data_structures/queue_using_array2.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int rear = 0;
66

77
void Enque(int x) {
88
if (rear == 10) {
9-
cout << "\nOverflow";
9+
std::cout << "\nOverflow";
1010
} else {
1111
queue[rear++] = x;
1212
}
@@ -15,9 +15,8 @@ void Enque(int x) {
1515
void Deque() {
1616
if (front == rear) {
1717
std::cout << "\nUnderflow";
18-
}
1918

20-
else {
19+
} else {
2120
std::cout << "\n" << queue[front++] << " deleted";
2221
for (int i = front; i < rear; i++) {
2322
queue[i - front] = queue[i];
@@ -43,8 +42,8 @@ int main() {
4342
std::cout << "\nEnter Your Choice : ";
4443
std::cin >> ch;
4544
if (ch == 1) {
46-
cout << "\nInsert : ";
47-
cin >> x;
45+
std::cout << "\nInsert : ";
46+
std::cin >> x;
4847
Enque(x);
4948
} else if (ch == 2) {
5049
Deque();

data_structures/queue_using_linked_list.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ void Enque(int x) {
1414
n->next = nullptr;
1515
rear = n;
1616
front = n;
17-
}
1817

19-
else {
18+
} else {
2019
node *n = new node;
2120
n->val = x;
2221
n->next = nullptr;
@@ -58,7 +57,7 @@ int main() {
5857
std::cin >> ch;
5958
if (ch == 1) {
6059
std::cout << "\nInsert : ";
61-
std:::cin >> x;
60+
std::cin >> x;
6261
Enque(x);
6362
} else if (ch == 2) {
6463
Deque();

data_structures/stack_using_linked_list.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <iostream>
2-
using namespace std;
32

43
struct node {
54
int val;
@@ -16,35 +15,36 @@ void push(int x) {
1615
}
1716

1817
void pop() {
19-
if (top == NULL) {
20-
cout << "\nUnderflow";
18+
if (top == nullptr) {
19+
std::cout << "\nUnderflow";
2120
} else {
2221
node *t = top;
23-
cout << "\n" << t->val << " deleted";
22+
std::cout << "\n" << t->val << " deleted";
2423
top = top->next;
2524
delete t;
2625
}
2726
}
2827

2928
void show() {
3029
node *t = top;
31-
while (t != NULL) {
32-
cout << t->val << "\n";
30+
while (t != nullptr) {
31+
std::cout << t->val << "\n";
3332
t = t->next;
3433
}
3534
}
3635

3736
int main() {
3837
int ch, x;
3938
do {
40-
cout << "\n1. Push";
41-
cout << "\n2. Pop";
42-
cout << "\n3. Print";
43-
cout << "\nEnter Your Choice : ";
44-
cin >> ch;
39+
std::cout << "\n0. Exit";
40+
std::cout << "\n1. Push";
41+
std::cout << "\n2. Pop";
42+
std::cout << "\n3. Print";
43+
std::cout << "\nEnter Your Choice : ";
44+
std::cin >> ch;
4545
if (ch == 1) {
46-
cout << "\nInsert : ";
47-
cin >> x;
46+
std::cout << "\nInsert : ";
47+
std::cin >> x;
4848
push(x);
4949
} else if (ch == 2) {
5050
pop();

data_structures/tree.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void CreateTree(node *curr, node *n, int x, char pos) {
3737
}
3838

3939
void BFT(node *n) {
40-
list<node *> queue;
40+
std::list<node *> queue;
4141

4242
queue.push_back(n);
4343

@@ -123,12 +123,14 @@ int main() {
123123
break;
124124

125125
default:
126-
if (ch == 0) { return }
126+
if (ch == 0) { break; }
127127
std::cout << "Wrong option; type an option : ";
128128
std::cin >> ch;
129129

130130
break;
131131
}
132132
} while (ch != 0);
133+
134+
delete root;
133135
return 0;
134136
}

data_structures/trie_tree.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ typedef struct trie {
1717
*/
1818
trie* createNode() {
1919
trie* nn = new trie();
20-
for (int i = 0; i < 26; i++) { nn->arr[i] = nullptr };
20+
for (int i = 0; i < 26; i++) { nn->arr[i] = nullptr; }
2121
nn->isEndofWord = false;
2222
return nn;
2323
}
@@ -66,7 +66,7 @@ bool deleteString(trie* root, std::string str, int index) {
6666
return false;
6767
}
6868
root->isEndofWord = false;
69-
for (int i = 0; i < 26; i++) { return false };
69+
for (int i = 0; i < 26; i++) { return false; }
7070
return true;
7171
}
7272
int j = str[index] - 'a';
@@ -106,7 +106,5 @@ int main() {
106106
int b = search(root, "word", 0);
107107

108108
std::cout << a << b;
109-
delete trie;
110-
111109
return 0;
112110
}

0 commit comments

Comments
 (0)