Skip to content

Commit 4c94735

Browse files
committed
Added Circular queue, dequeue and queue using stack code
1 parent cbdac0e commit 4c94735

Some content is hidden

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

52 files changed

+5661
-5287
lines changed

Balanced Paranthesis.txt

+70-70
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
1-
#include <iostream>
2-
#include<stack>
3-
using namespace std;
4-
5-
int length(char *exp){
6-
int length=0;
7-
for(int i=0;exp[i]!='\0';i++)
8-
length++;
9-
return length;
10-
}
11-
12-
13-
14-
bool checkBalanced(char *exp){
15-
stack<int> st;
16-
int l =length(exp);
17-
for(int i = 0 ; i < l ; i++){
18-
19-
if(exp[i]=='('||exp[i]=='{'||exp[i]=='['){
20-
st.push(exp[i]);
21-
continue;
22-
}
23-
24-
else if(exp[i]==')'){
25-
if(st.empty() == false){
26-
if(st.top()=='(')
27-
st.pop();
28-
}
29-
else
30-
return false;
31-
}
32-
33-
34-
else if(exp[i]=='}'){
35-
if(st.empty() == false){
36-
if(st.top()=='{')
37-
st.pop();
38-
}
39-
else
40-
return false;
41-
}
42-
else if(exp[i]==']'){
43-
if(st.empty() == false){
44-
if(st.top()=='[')
45-
st.pop();
46-
}
47-
else
48-
return false;
49-
}
50-
51-
}
52-
53-
54-
if(st.empty()==true){
55-
return true;
56-
}
57-
else
58-
return false;
59-
}
60-
61-
int main() {
62-
char input[100000];
63-
cin.getline(input, 100000);
64-
if(checkBalanced(input)) {
65-
cout << "true" << endl;
66-
}
67-
else {
68-
cout << "false" << endl;
69-
}
70-
}
1+
#include <iostream>
2+
#include<stack>
3+
using namespace std;
4+
5+
int length(char *exp){
6+
int length=0;
7+
for(int i=0;exp[i]!='\0';i++)
8+
length++;
9+
return length;
10+
}
11+
12+
13+
14+
bool checkBalanced(char *exp){
15+
stack<int> st;
16+
int l =length(exp);
17+
for(int i = 0 ; i < l ; i++){
18+
19+
if(exp[i]=='('||exp[i]=='{'||exp[i]=='['){
20+
st.push(exp[i]);
21+
continue;
22+
}
23+
24+
else if(exp[i]==')'){
25+
if(st.empty() == false){
26+
if(st.top()=='(')
27+
st.pop();
28+
}
29+
else
30+
return false;
31+
}
32+
33+
34+
else if(exp[i]=='}'){
35+
if(st.empty() == false){
36+
if(st.top()=='{')
37+
st.pop();
38+
}
39+
else
40+
return false;
41+
}
42+
else if(exp[i]==']'){
43+
if(st.empty() == false){
44+
if(st.top()=='[')
45+
st.pop();
46+
}
47+
else
48+
return false;
49+
}
50+
51+
}
52+
53+
54+
if(st.empty()==true){
55+
return true;
56+
}
57+
else
58+
return false;
59+
}
60+
61+
int main() {
62+
char input[100000];
63+
cin.getline(input, 100000);
64+
if(checkBalanced(input)) {
65+
cout << "true" << endl;
66+
}
67+
else {
68+
cout << "false" << endl;
69+
}
70+
}

C++/SieveOfEratosthenes.cpp

+36-36
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
#include <iostream>
2-
#include <stdbool.h>
3-
#include <cstring>
4-
#include <conio.h>
5-
6-
using namespace std;
7-
8-
void SieveOfEratosthenes(int n)
9-
{
10-
long int i,p;
11-
bool arr[n+1];
12-
memset(arr,true,sizeof(arr));
13-
for(i=2;i*i<=n;i++)
14-
{
15-
if(arr[i]==true)
16-
{
17-
for(p=i*i;p<=n;p=p+i)
18-
{
19-
arr[p]=false;
20-
}
21-
}
22-
}
23-
for(i=2;i<=n;i++)
24-
{
25-
if(arr[i]==true)
26-
cout<<i<<endl;
27-
}
28-
}
29-
int main()
30-
{
31-
long int x;
32-
cin>>x;
33-
SieveOfEratosthenes(x);
34-
getch();
35-
return (0);
36-
}
1+
#include <iostream>
2+
#include <stdbool.h>
3+
#include <cstring>
4+
#include <conio.h>
5+
6+
using namespace std;
7+
8+
void SieveOfEratosthenes(int n)
9+
{
10+
long int i,p;
11+
bool arr[n+1];
12+
memset(arr,true,sizeof(arr));
13+
for(i=2;i*i<=n;i++)
14+
{
15+
if(arr[i]==true)
16+
{
17+
for(p=i*i;p<=n;p=p+i)
18+
{
19+
arr[p]=false;
20+
}
21+
}
22+
}
23+
for(i=2;i<=n;i++)
24+
{
25+
if(arr[i]==true)
26+
cout<<i<<endl;
27+
}
28+
}
29+
int main()
30+
{
31+
long int x;
32+
cin>>x;
33+
SieveOfEratosthenes(x);
34+
getch();
35+
return (0);
36+
}

C++/insertionsort.cpp

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
#include<iostream>
2-
using namespace std;
3-
int main()
4-
{
5-
int n;
6-
cout<<"Enter the length of the array : ";
7-
cin>>n;
8-
int a[n];
9-
cout<<"Insert the elements to perform sorting... "<<endl;
10-
for (int u = 0; u <n ; u++)
11-
{
12-
cout<<"Enter the "<<u+1<<" element : ";
13-
cin>>a[u];
14-
}
15-
16-
17-
int j,key,i;
18-
for (i = 1; i < n; i++)
19-
{
20-
key = a[i];
21-
j = i - 1;
22-
while (j>=0&& a[j]>key)
23-
{
24-
a[j + 1] = a[j];
25-
j=j-1;
26-
}
27-
a[j+1]=key;
28-
}
29-
for (i = 0; i < n; i++)
30-
cout<<a[i]<< " ";
31-
return 0;
32-
}
1+
#include<iostream>
2+
using namespace std;
3+
int main()
4+
{
5+
int n;
6+
cout<<"Enter the length of the array : ";
7+
cin>>n;
8+
int a[n];
9+
cout<<"Insert the elements to perform sorting... "<<endl;
10+
for (int u = 0; u <n ; u++)
11+
{
12+
cout<<"Enter the "<<u+1<<" element : ";
13+
cin>>a[u];
14+
}
15+
16+
17+
int j,key,i;
18+
for (i = 1; i < n; i++)
19+
{
20+
key = a[i];
21+
j = i - 1;
22+
while (j>=0&& a[j]>key)
23+
{
24+
a[j + 1] = a[j];
25+
j=j-1;
26+
}
27+
a[j+1]=key;
28+
}
29+
for (i = 0; i < n; i++)
30+
cout<<a[i]<< " ";
31+
return 0;
32+
}

CaesarCipher/Python/CaesarCipher.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
letters = input()
2-
rot = int(input())
3-
for i in range(len(letters)):
4-
print(letters[(i + rot) % len(letters)], end='')
5-
print('\n', letters, sep='')
6-
for i in range(len(letters)):
1+
letters = input()
2+
rot = int(input())
3+
for i in range(len(letters)):
4+
print(letters[(i + rot) % len(letters)], end='')
5+
print('\n', letters, sep='')
6+
for i in range(len(letters)):
77
print(letters[(i - rot) % len(letters)], end='')

Calculator/Calculator.depend

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# depslib dependency file v1.0
2-
1570949579 source:c:\users\yakov\desktop\codeblocks\calculator\main.cpp
3-
<bits/stdc++.h>
4-
1+
# depslib dependency file v1.0
2+
1570949579 source:c:\users\yakov\desktop\codeblocks\calculator\main.cpp
3+
<bits/stdc++.h>
4+

0 commit comments

Comments
 (0)