Skip to content

Commit 694da59

Browse files
axravmintbomb27
andauthored
feat: added basic code structure for some languages (#4)
* feat: added basic code structure for python * feat : added some more languages with base structure * feat: better naming conventions, fixing bugs * feat: generic messages * fix: naming Co-authored-by: Alok Naushad <[email protected]>
1 parent c7e4efc commit 694da59

Some content is hidden

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

78 files changed

+1424
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

C++/binarysearch.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Binary Search Algorithm in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
int BinarySearch(int *arr, int size, int x)
8+
{
9+
// your code goes here
10+
// return the index of x in arr if found otherwise return -1
11+
}
12+
13+
int main()
14+
{
15+
int arr[5] = {2, 3, 4, 10, 40};
16+
int x = 10;
17+
int z = BinarySearch(arr, 5, x);
18+
cout << z;
19+
return 0;
20+
}

C++/binarytree.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Binary Tree Algorithm in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
struct Node
8+
{
9+
int data;
10+
Node *left;
11+
Node *right;
12+
};
13+
14+
Node *NewNode(int data)
15+
{
16+
// your code goes here
17+
}
18+
19+
Node *Insert(Node *node, int data)
20+
{
21+
// your code goes here
22+
}
23+
24+
Node *PrintTree(Node *node)
25+
{
26+
// your code goes here
27+
}
28+
29+
int main()
30+
{
31+
Node *root = NewNode(100);
32+
Insert(root, 50);
33+
Insert(root, 150);
34+
Insert(root, 25);
35+
PrintTree(root);
36+
}

C++/bubblesort.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Bubble Sort Algorithm in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
void BubbleSort(int *arr, int size)
8+
{
9+
// your code goes here
10+
// print the sorted array
11+
}
12+
13+
int main()
14+
{
15+
int arr[6] = {76, 22, 21, 96, 70, 20};
16+
BubbleSort(arr, 6);
17+
return 0;
18+
}
19+
20+
// Output
21+
22+
// 21 22 20 70 76 96

C++/checkPrime.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Check Prime Number in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
bool IsPrime(int n)
7+
{
8+
// your code goes here
9+
// check if the number is prime or not and return true or false accordingly
10+
}
11+
12+
int main()
13+
{
14+
int n = 73;
15+
bool result = IsPrime(n);
16+
cout << result;
17+
return 0;
18+
}
19+
20+
// Output
21+
// 73 is a prime number

C++/eval.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Eval Function for C++
2+
#include <iostream>
3+
#include <string>
4+
using namespace std;
5+
6+
int main()
7+
{
8+
string expression = "10 + 20 * 30";
9+
cout << eval(expression) << endl;
10+
}
11+
12+
int eval(string expression)
13+
{
14+
// your code goes here
15+
}
16+
17+
// Output
18+
// 610

C++/fibonacci.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Fibonacci Series in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
int fib(int n)
7+
{
8+
// your code goes here
9+
// print the fibonacci series
10+
}
11+
12+
int main()
13+
{
14+
fib(10);
15+
}
16+
17+
// Output
18+
19+
// 0 1 1 2 3 5 8 13 21 34

C++/heapsort.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Heap Sort Algorithm in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
void Heapify(int *arr, int size, int i)
8+
{
9+
// your code goes here
10+
}
11+
12+
void HeapSort(int *arr, int size)
13+
{
14+
// your code goes here
15+
// print the sorted array
16+
}
17+
18+
int main()
19+
{
20+
int arr[6] = {76, 22, 21, 96, 70, 20};
21+
HeapSort(arr, 6);
22+
return 0;
23+
}
24+
25+
// Output
26+
27+
// 20 21 22 70 76 96

C++/helloworld.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Hello world in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
int main()
7+
{
8+
cout << "Hello World";
9+
return 0;
10+
}

C++/infixtopostfix.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Infix to Postfix Conversion using Stack in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
string InfixToPostfix(string expression)
8+
{
9+
// your code goes here
10+
// return the postfix expression
11+
}
12+
13+
int main()
14+
{
15+
string expression = "a+b*(c^d-e)^(f+g*h)-i";
16+
cout << InfixToPostfix(expression) << endl;
17+
}
18+
19+
// Output
20+
// abcd^e-fgh*+^*+i-

C++/linearsearch.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Linear Search Algorithm in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
int LinearSearch(int *arr, int size, int x)
7+
{
8+
for (int i = 0; i < size; i++)
9+
{
10+
if (arr[i] == x)
11+
{
12+
return i;
13+
}
14+
}
15+
return -1;
16+
}
17+
18+
int main()
19+
{
20+
int arr[5] = {2, 3, 4, 10, 40};
21+
int x = 10;
22+
int z = LinearSearch(arr, 5, x);
23+
cout << z;
24+
}

C++/selectionsort.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Selection Sort Algorithm in C++
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
void SelectionSort(int *arr, int size)
8+
{
9+
// your code goes here
10+
// print the sorted array
11+
}
12+
13+
int main()
14+
{
15+
int arr[6] = {76, 22, 21, 96, 70, 20};
16+
SelectionSort(arr, 6);
17+
return 0;
18+
}
19+
20+
// Output
21+
22+
// 20 21 22 70 76 96

C/binarysearch.c

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Binary Search Algorithm in C++
2+
3+
#include <stdio.h>
4+
5+
int BinarySearch(int *arr, int size, int x)
6+
{
7+
// your code goes here
8+
// return the index of the element if found else return -1
9+
}
10+
11+
int main()
12+
{
13+
int arr[5] = {2, 3, 4, 10, 40};
14+
int x = 10;
15+
int index = BinarySearch(arr, 5, x);
16+
printf("%d", index);
17+
return 0;
18+
}
19+
20+
// Output
21+
22+
// 3

C/binarytree.c

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Binary Tree Implementation in C
2+
3+
#include <stdio.h>
4+
5+
struct node
6+
{
7+
int data;
8+
struct node *left;
9+
struct node *right;
10+
};
11+
12+
struct node *NewNode(int data)
13+
{
14+
// your code goes here
15+
}
16+
17+
void PrintTree(struct node *root)
18+
{
19+
// your code goes here
20+
}
21+
22+
void Insert(struct node *root, int data)
23+
{
24+
// your code goes here
25+
}
26+
27+
int main()
28+
{
29+
struct node *root = NewNode(100);
30+
Insert(root, 50);
31+
Insert(root, 200);
32+
Insert(root, 25);
33+
34+
PrintTree(root);
35+
return 0;
36+
}

C/bubblesort.c

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Bubble sort algorithm in C
2+
3+
#include <stdio.h>
4+
5+
void bubbleSort(int arr[], int n)
6+
{
7+
// your code goes here
8+
// print the sorted array
9+
}
10+
11+
int main()
12+
{
13+
int arr[6] = {76, 22, 21, 96, 70, 20};
14+
bubbleSort(arr, 6);
15+
return 0;
16+
}
17+
18+
// Output
19+
// 20 21 22 70 76 96

C/checkprime.c

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Check if a number is prime or not in C.
2+
3+
#include <stdio.h>
4+
5+
int IsPrime(int n)
6+
{
7+
// your code goes here
8+
// return 1 if n is prime else return 0
9+
}
10+
int main()
11+
{
12+
int n = 73;
13+
int result = IsPrime(n);
14+
printf("%d", result);
15+
}
16+
17+
// Output
18+
// 73

C/eval.c

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Eval function for C
2+
3+
#include <stdio.h>
4+
5+
int evaluate(char *expression)
6+
{
7+
// your code goes here
8+
}
9+
10+
int main()
11+
{
12+
char expr[100] = "10 + 20 * 30";
13+
int result = 0;
14+
result = evaluate(expr);
15+
printf("Result: %d", result);
16+
}
17+
18+
// Output
19+
// 610

0 commit comments

Comments
 (0)