From 867866e68d506495850a08648192c30f1d30f0b6 Mon Sep 17 00:00:00 2001
From: Muhammed Nihad
Date: Wed, 7 Oct 2020 12:02:10 +0530
Subject: [PATCH 001/129] Add generate-multiplication-table
C program to generate multiplication table
---
generate-multiplication-table | 10 ++++++++++
1 file changed, 10 insertions(+)
create mode 100644 generate-multiplication-table
diff --git a/generate-multiplication-table b/generate-multiplication-table
new file mode 100644
index 00000000..7250ae24
--- /dev/null
+++ b/generate-multiplication-table
@@ -0,0 +1,10 @@
+#include
+int main() {
+ int n, i;
+ printf("Enter an integer: ");
+ scanf("%d", &n);
+ for (i = 1; i <= 10; ++i) {
+ printf("%d * %d = %d \n", n, i, n * i);
+ }
+ return 0;
+}
From 0c36ad0654b4b2e070b23957c154ec2d6861c6c0 Mon Sep 17 00:00:00 2001
From: Muhammed Nihad
Date: Wed, 7 Oct 2020 12:03:06 +0530
Subject: [PATCH 002/129] Rename generate-multiplication-table to Generate
multiplication table using C
---
...-multiplication-table => Generate multiplication table using C | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename generate-multiplication-table => Generate multiplication table using C (100%)
diff --git a/generate-multiplication-table b/Generate multiplication table using C
similarity index 100%
rename from generate-multiplication-table
rename to Generate multiplication table using C
From 0c7574d7315cc7e3acac2bbe7217afd964951c3c Mon Sep 17 00:00:00 2001
From: Deepak Sahu <54443431+Deepaksahu-bot@users.noreply.github.com>
Date: Wed, 7 Oct 2020 12:26:31 +0530
Subject: [PATCH 003/129] Update Sum & Avg. of elements of a matrix.c
---
Sum & Avg. of elements of a matrix.c | 52 ++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/Sum & Avg. of elements of a matrix.c b/Sum & Avg. of elements of a matrix.c
index f2c54eec..dea629c6 100644
--- a/Sum & Avg. of elements of a matrix.c
+++ b/Sum & Avg. of elements of a matrix.c
@@ -19,3 +19,55 @@ int main()
printf("\nAverage Of Matrix = %d",avg);
return 0;
}
+//code for matrix multiplication
+#include
+
+int main()
+{
+ int m, n, p, q, c, d, k, sum = 0;
+ int first[10][10], second[10][10], multiply[10][10];
+
+ printf("Enter number of rows and columns of first matrix\n");
+ scanf("%d%d", &m, &n);
+ printf("Enter elements of first matrix\n");
+
+ for (c = 0; c < m; c++)
+ for (d = 0; d < n; d++)
+ scanf("%d", &first[c][d]);
+
+ printf("Enter number of rows and columns of second matrix\n");
+ scanf("%d%d", &p, &q);
+
+ if (n != p)
+ printf("The multiplication isn't possible.\n");
+ else
+ {
+ printf("Enter elements of second matrix\n");
+
+ for (c = 0; c < p; c++)
+ for (d = 0; d < q; d++)
+ scanf("%d", &second[c][d]);
+
+ for (c = 0; c < m; c++) {
+ for (d = 0; d < q; d++) {
+ for (k = 0; k < p; k++) {
+ sum = sum + first[c][k]*second[k][d];
+ }
+
+ multiply[c][d] = sum;
+ sum = 0;
+ }
+ }
+
+ printf("Product of the matrices:\n");
+
+ for (c = 0; c < m; c++) {
+ for (d = 0; d < q; d++)
+ printf("%d\t", multiply[c][d]);
+
+ printf("\n");
+ }
+ }
+
+ return 0;
+}
From a157186d901dc442667585e15ff5e6d6fe2c5bef Mon Sep 17 00:00:00 2001
From: Akash Banchhor
Date: Wed, 7 Oct 2020 12:31:36 +0530
Subject: [PATCH 004/129] basica data structure added
---
binarytree.c | 114 ++++++++++++++++++++++++++++++++++++++++
doublylinkedlist.c | 83 +++++++++++++++++++++++++++++
linkedlist.c | 126 +++++++++++++++++++++++++++++++++++++++++++++
queue.c | 62 ++++++++++++++++++++++
stack.c | 55 ++++++++++++++++++++
structure.c | 22 ++++++++
union.c | 18 +++++++
7 files changed, 480 insertions(+)
create mode 100644 binarytree.c
create mode 100644 doublylinkedlist.c
create mode 100644 linkedlist.c
create mode 100644 queue.c
create mode 100644 stack.c
create mode 100644 structure.c
create mode 100644 union.c
diff --git a/binarytree.c b/binarytree.c
new file mode 100644
index 00000000..0fbbe8e3
--- /dev/null
+++ b/binarytree.c
@@ -0,0 +1,114 @@
+#include
+#include
+
+struct btree{
+ int data;
+ struct btree *left;
+ struct btree *right;
+};
+
+struct btree *minValueNode(struct btree* node){
+ struct btree* current = node;
+
+ /* loop down to find the leftmost leaf */
+ while (current && current->left != NULL)
+ current = current->left;
+
+ return current;
+}
+
+void insert(struct btree **root, int newData){
+ struct btree *node = (*root);
+ if(node == NULL){
+ struct btree *newNode = (struct btree *)malloc(sizeof(struct btree));
+ newNode->left = NULL;
+ newNode->data = newData;
+ newNode->right = NULL;
+ *root = newNode;
+ }
+ else{
+ if(newData > node->data)
+ insert(&(node->right), newData);
+ else
+ insert(&(node->left), newData);
+ }
+}
+
+struct btree *delete(struct btree *root, int item){
+ if(root == NULL)
+ return root;
+
+ if(item > root->data)
+ root->right = delete(root->right, item);
+
+ else if(item < root->data)
+ root->left = delete(root->left, item);
+
+ else{
+ if(root->left == NULL){
+ struct btree *temp = root->right;
+ free(root);
+ return temp;
+ }
+ if(root->right == NULL){
+ struct btree *temp = root->left;
+ free(root);
+ return temp;
+ }
+ struct btree *temp = minValueNode(root->right);
+ root->data = temp->data;
+ root->right = delete(root->right, temp->data);
+ }
+ return root;
+}
+
+void inorder(struct btree *root){
+ if(root != NULL){
+ inorder(root->left);
+ printf("%d ", root->data);
+ inorder(root->right);
+ }
+ else{
+ return;
+ }
+}
+
+void preorder(struct btree *root){
+ if(root != NULL){
+ printf("%d ", root->data);
+ preorder(root->left);
+ preorder(root->right);
+ }
+ else{
+ return;
+ }
+}
+
+void postorder(struct btree *root){
+ if(root != NULL){
+ postorder(root->left);
+ postorder(root->right);
+ printf("%d ", root->data);
+ }
+ else{
+ return;
+ }
+}
+
+int main(){
+ struct btree *root = NULL;
+ insert(&root, 20);
+ insert(&root, 40);
+ insert(&root, 17);
+ insert(&root, 6);
+ insert(&root, 8);
+ insert(&root, 10);
+ insert(&root, 7);
+ inorder(root);
+ printf("\n");
+ delete(root, 20);
+ inorder(root);
+ printf("\n");
+ postorder(root);
+ return 0;
+}
\ No newline at end of file
diff --git a/doublylinkedlist.c b/doublylinkedlist.c
new file mode 100644
index 00000000..59463dfc
--- /dev/null
+++ b/doublylinkedlist.c
@@ -0,0 +1,83 @@
+#include
+#include
+
+struct node{
+ int data;
+ struct node *prev;
+ struct node *next;
+};
+
+void addAtBeg(struct node **head, int newData){
+ struct node *newNode = (struct node *)malloc(sizeof(struct node));
+
+ newNode->data = newData;
+
+ if(*head == NULL){
+ *head = newNode;
+ newNode->next = NULL;
+ newNode->prev = NULL;
+ }
+ else{
+ newNode->prev = NULL;
+ newNode->next = *head;
+ (*head)->prev = newNode;
+ *head = newNode;
+ }
+}
+
+void addAfter(struct node **head, int look, int newData){
+ struct node *newNode = (struct node *)malloc(sizeof(struct node));
+
+ newNode->data = newData;
+
+ struct node *link = *head;
+ while(link->data != look){
+ link = link->next;
+ }
+ newNode->prev = link;
+ newNode->next = link->next;
+ link->next = newNode;
+}
+
+void removeNode(struct node **head, int key){
+ struct node *link = *head;
+
+ while(link->next->data != key){
+ link = link->next;
+ }
+ link->next->next->prev = link;
+ link->next = link->next->next;
+}
+
+void reverse(struct node **head){
+ struct node *current = *head;
+ struct node *temp = NULL;
+ while(current != NULL){
+ temp = current->prev;
+ current->prev = current->next;
+ current->next = temp;
+ current = current->prev;
+ }
+ if(temp != NULL )
+ *head = temp->prev;
+}
+
+void print(struct node *head){
+ while(head != NULL){
+ printf("%d ", head->data);
+ head = head->next;
+ }
+}
+
+int main(){
+ struct node *head = NULL;
+ struct node *tail = NULL;
+ addAtBeg(&head, 5);
+ addAtBeg(&head, 4);
+ addAfter(&head, 5, 6);
+ addAfter(&head, 6, 7);
+ removeNode(&head, 6);
+ reverse(&head);
+ print(head);
+ return 0;
+}
\ No newline at end of file
diff --git a/linkedlist.c b/linkedlist.c
new file mode 100644
index 00000000..d4110abb
--- /dev/null
+++ b/linkedlist.c
@@ -0,0 +1,126 @@
+#include
+#include
+
+struct node{
+ int data;
+ struct node *link;
+};
+
+void addNodeAtBeg(struct node **head, int newData){
+ //Create a new node
+ struct node *newNode = (struct node *)malloc(sizeof(struct node));
+ //insert data in new node
+ newNode->data = newData;
+ //it's a new node i.e. it is going to be last node, add NULL to it's link
+ newNode->link = NULL;
+ //if linked list is empty
+ if(*head == NULL){
+ *head = newNode;
+ return;
+ }
+ else{
+ newNode->link = *head;
+ *head = newNode;
+ return;
+ }
+}
+
+void addNodeAtEnd(struct node **head, int newData){
+ struct node *newNode = (struct node *)malloc(sizeof(struct node));
+
+ newNode->data = newData;
+ newNode->link = NULL;
+
+ struct node *last = *head;
+
+ if(*head == NULL)
+ *head = newNode;
+ else{
+ while(last->link != NULL)
+ last = last->link;
+ last->link = newNode;
+ }
+}
+
+void insertNodeAfter(struct node **head, int item, int newData){
+ struct node *newNode = (struct node *)malloc(sizeof(struct node));
+
+ newNode->data = newData;
+
+ struct node *find = *head;
+
+ while(find->data != item)
+ find = find->link;
+ newNode->link = find->link;
+ find->link = newNode;
+}
+
+void deleteParticularNode(struct node **head, int item){
+ struct node *find = *head;
+ if(find->data == item){
+ *head = find->link;
+ free(find);
+ }
+ else{
+ while(find->link->data != item)
+ find = find->link;
+ find->link = find->link->link;
+ free(find->link->link);
+ }
+}
+
+void reverse(struct node **head){
+ struct node *prev = *head;
+ struct node *next = *head;
+ struct node *current = *head;
+
+ next = next->link->link;
+ current = current->link;
+ prev->link = NULL;
+
+ while(1){
+ current->link = prev;
+ prev = current;
+ current = next;
+ if(current == NULL)
+ break;
+ next = next->link;
+ }
+ *head = prev;
+}
+
+void printList(struct node *head){
+ while(head != NULL){
+ printf("%d ", head->data);
+ head = head->link;
+ }
+}
+
+int main(){
+
+ struct node *head = NULL;
+
+ addNodeAtBeg(&head, 6);
+
+ addNodeAtBeg(&head, 5);
+
+ addNodeAtEnd(&head, 7);
+
+ insertNodeAfter(&head, 7, 79);
+
+ deleteParticularNode(&head, 7);
+
+ addNodeAtBeg(&head, 2);
+
+ addNodeAtBeg(&head, 3);
+
+ addNodeAtBeg(&head, 4);
+
+ printList(head);
+
+ reverse(&head);
+ printf("\n");
+ printList(head);
+
+ return 0;
+}
\ No newline at end of file
diff --git a/queue.c b/queue.c
new file mode 100644
index 00000000..d16220c6
--- /dev/null
+++ b/queue.c
@@ -0,0 +1,62 @@
+#include
+#include
+
+struct node{
+ int data;
+ struct node *link;
+};
+
+void enqueue(struct node **head, int newData){
+ struct node *newNode = (struct node *)malloc(sizeof(struct node));
+ newNode->data = newData;
+ newNode->link = NULL;
+ if(*head == NULL){
+ *head = newNode;
+ }
+ else{
+ struct node *tail = *head;
+ while(tail->link != NULL)
+ tail = tail->link;
+ tail->link = newNode;
+ }
+}
+
+void dequeue(struct node **head){
+ if(*head == NULL)
+ printf("\nQueue is already empty");
+ else if((*head)->link == NULL){
+ *head = NULL;
+ printf("\nQueue is now empty");
+ }
+ else{
+ *head = (*head)->link;
+ }
+}
+
+void print(struct node *head){
+ while(head != NULL){
+ printf("%d ", head->data);
+ head = head->link;
+ }
+}
+
+int main(){
+ struct node *head = NULL;
+ enqueue(&head, 1);
+ enqueue(&head, 2);
+ enqueue(&head, 3);
+ print(head);
+ dequeue(&head);
+ printf("\n");
+ print(head);
+ dequeue(&head);
+ printf("\n");
+ print(head);
+ dequeue(&head);
+ printf("\n");
+ print(head);
+ dequeue(&head);
+ printf("\n");
+ print(head);
+ return 0;
+}
\ No newline at end of file
diff --git a/stack.c b/stack.c
new file mode 100644
index 00000000..b3b7eaea
--- /dev/null
+++ b/stack.c
@@ -0,0 +1,55 @@
+#include
+#include
+
+struct node{
+ int data;
+ struct node *link;
+};
+
+void push(struct node **top, int newData){
+ struct node *newNode = (struct node *)malloc(sizeof(struct node));
+ newNode->data = newData;
+
+ if(*top == NULL){
+ *top = newNode;
+ newNode->link = NULL;
+ }
+ else{
+ newNode->link = *top;
+ *top = newNode;
+ }
+}
+
+void pop(struct node **top){
+ if(*top == NULL)
+ printf("\nstack underflow");
+ else if((*top)->link == NULL){
+ *top = NULL;
+ printf("\nstack is now empty");
+ }
+ else
+ *top = (*top)->link;
+}
+
+void print(struct node *top){
+ while(top != NULL){
+ printf("%d ", top->data);
+ top = top->link;
+ }
+}
+
+int main(){
+ struct node *top = NULL;
+ push(&top, 5);
+ push(&top, 4);
+ push(&top, 3);
+ print(top);
+ pop(&top);
+ pop(&top);
+ pop(&top);
+ pop(&top);
+ pop(&top);
+ printf("\n");
+ print(top);
+ return 0;
+}
\ No newline at end of file
diff --git a/structure.c b/structure.c
new file mode 100644
index 00000000..90b91c16
--- /dev/null
+++ b/structure.c
@@ -0,0 +1,22 @@
+#include
+
+struct Distance{
+ int inch, feet;
+};
+
+void add(struct Distance l1, struct Distance l2){
+ l1.feet = l1.feet + l2.feet + (l1.inch + l2.inch) / 12;
+ l2.inch = (l1.inch + l2.inch) % 12;
+ printf("\nFeet = %d, inch = %d",l1.feet, l1.inch);
+}
+
+int mian(){
+ struct Distance d1 = {100, 30};
+ struct Distance d2 = {20, 20};
+ printf("Distance 1");
+ printf("\nFeet = %d, inch = %d",d1.feet, d1.inch);
+ printf("\nDistance 2");
+ printf("\nFeet = %d, inch = %d",d2.feet, d2.inch);
+ add(d1, d2);
+ return 0;
+}
\ No newline at end of file
diff --git a/union.c b/union.c
new file mode 100644
index 00000000..1b145ffe
--- /dev/null
+++ b/union.c
@@ -0,0 +1,18 @@
+#include
+
+union mix{
+ int a;
+ char c[4];
+};
+
+int main(){
+ union mix k;
+ k.c[0] = 'A';
+ k.c[1] = 'B';
+ k.c[2] = 'C';
+ k.c[3] = 'D';
+ k.a = 1024;
+ //k.c[4] = 'E';
+ printf("%d %d %d %d %d", k.c[0], k.c[1], k.c[2], k.c[3], k.a);
+ return 0;
+}
\ No newline at end of file
From 9143892d169a373903fc53b646d8d0b363a0e40a Mon Sep 17 00:00:00 2001
From: Rahul Sinha <72486800+rahulSinha-01@users.noreply.github.com>
Date: Wed, 7 Oct 2020 13:08:04 +0530
Subject: [PATCH 005/129] add binary search
---
searching.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
create mode 100644 searching.cpp
diff --git a/searching.cpp b/searching.cpp
new file mode 100644
index 00000000..6baf3e60
--- /dev/null
+++ b/searching.cpp
@@ -0,0 +1,87 @@
+#include
+
+using namespace std;
+
+int main()
+{
+
+ int choice, index, search, size, flag = 0;
+
+ cout << "Enter the size array" << endl;
+ cin >> size;
+ int A[size];
+ cout << "Enter the array in sorted order" << endl;
+ for (int i = 0; i < size; i++)
+ {
+ cin >> A[i];
+ }
+ cout << "Enter the Element to be searched" << endl;
+ cin >> search;
+
+ while (true)
+ {
+
+ cout << "MENU" << endl;
+ cout << "Enter 1 for Linear Search" << endl;
+ cout << "Enter 2 for Binary Search" << endl;
+ cout << "Enter 3 to exit" << endl;
+ cin >> choice;
+
+ switch (choice)
+ {
+
+ case 1:
+ {
+ cout << "Linear Search" << endl;
+ for (int j = 0; j < size; j++)
+ {
+ if (A[j] == search)
+ {
+ index = j;
+ flag = 1;
+ }
+ }
+
+ if (flag == 1)
+ {
+ cout << search << " is found at the index " << index << endl;
+ }
+ else
+ {
+ cout << search << " is not found in the array" << endl;
+ }
+ break;
+ }
+
+ case 2:
+ {
+ cout << "Binary Search" << endl;
+ int low = 0;
+ int high = size - 1;
+ while (low <= high)
+ {
+ int mid = low + (high - low) / 2;
+
+ if (A[mid] == search)
+ cout << search << " Element found at index " << mid << endl;
+
+ if (A[mid] <= search)
+ low = mid + 1;
+
+ else
+ high = mid - 1;
+ }
+ break;
+ }
+
+ case 3:
+ {
+ exit(0);
+ }
+ default:
+ {
+ cout << "No correct option chosen" << endl;
+ }
+ }
+ }
+}
From 28c361680d6bdced4e6252cdcb8a6667750cedff Mon Sep 17 00:00:00 2001
From: ISHJOT <60621772+ISHJOT15@users.noreply.github.com>
Date: Wed, 7 Oct 2020 14:07:16 +0530
Subject: [PATCH 006/129] Added a file to reverse a doubly linked list
This is a C code to reverse a doubly linked list.
---
Revdoubly. C | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
create mode 100644 Revdoubly. C
diff --git a/Revdoubly. C b/Revdoubly. C
new file mode 100644
index 00000000..6486b064
--- /dev/null
+++ b/Revdoubly. C
@@ -0,0 +1,64 @@
+#include
+#include
+#include
+struct node{
+int data;
+struct node *next;
+struct node *prev;
+};
+struct node *head,*tail;
+
+void create(){
+struct node *newnode;
+int choice;
+head=NULL;
+while(choice){
+newnode=(struct node*)malloc(sizeof(struct node));
+printf("enter data");
+scanf("%d",&newnode->data);
+newnode->prev=NULL;
+newnode->next=NULL;
+if(head == NULL){
+head=newnode;
+tail=newnode;
+}
+else{
+tail->next=newnode;
+newnode->prev=tail;
+tail=newnode;
+}
+printf("do you want to continue(1,0)?");
+scanf("%d",&choice);
+}
+}
+
+void print(){
+struct node * temp;
+temp=head;
+while(temp!=NULL){
+printf("%d",temp->data);
+temp=temp->next;
+}
+}
+void rever(){
+struct node * pnode,* nnode;
+pnode=head;
+while(pnode!=NULL){
+nnode=pnode->next;
+pnode->next=pnode->prev;
+pnode->prev=nnode;
+pnode=nnode;
+}
+pnode=head;
+head=tail;
+tail=pnode;
+}
+void main(){
+clrscr();
+create();
+print();
+rever();
+printf("\n");
+print();
+getch();
+}
From 7894ab7ae5423649fbad253da3c8ac9aff80ad55 Mon Sep 17 00:00:00 2001
From: ISHJOT <60621772+ISHJOT15@users.noreply.github.com>
Date: Wed, 7 Oct 2020 14:11:15 +0530
Subject: [PATCH 007/129] Added revLL.C file
This is a C code which reverse single linked list.
---
RevLL.C | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 RevLL.C
diff --git a/RevLL.C b/RevLL.C
new file mode 100644
index 00000000..f3ea47c1
--- /dev/null
+++ b/RevLL.C
@@ -0,0 +1,56 @@
+#include
+#include
+#include
+
+struct node{
+int data;
+struct node * next;
+};
+struct node * head;
+void reverse(){
+struct node *temp,*prevnode,*currnode,*nextnode;
+prevnode=NULL;
+currnode=head;
+nextnode=head;
+while(currnode!=NULL){
+nextnode=nextnode->next;
+currnode->next=prevnode;
+prevnode=currnode;
+currnode=nextnode;
+}
+head=prevnode;
+}
+void main(){
+struct node *temp,*newnode;
+int choice;
+clrscr();
+head=NULL;
+while(choice){
+newnode = (struct node*)malloc(sizeof(struct node));
+printf("enter data");
+scanf("%d",&newnode->data);
+newnode->next=NULL;
+if(head==NULL){
+head=newnode;
+temp=newnode;
+}
+else{
+temp->next=newnode;
+temp=newnode;
+}
+printf("Do you want to continue(0,1)?");
+scanf("%d",&choice);
+}
+temp=head;
+while(temp!=NULL){
+printf("%d",temp->data);
+temp=temp->next;
+}
+reverse();
+temp=head;
+while(temp!=NULL){
+printf("%d",temp->data);
+temp=temp->next;
+}
+getch();
+}
From aa87054931e1fec68e9a0931e2a5e21672d7a0ab Mon Sep 17 00:00:00 2001
From: sakshimaslekr <43902901+sakshimaslekr@users.noreply.github.com>
Date: Wed, 7 Oct 2020 14:35:35 +0530
Subject: [PATCH 008/129] Create swayamvar.c
---
swayamvar.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 swayamvar.c
diff --git a/swayamvar.c b/swayamvar.c
new file mode 100644
index 00000000..1e0159fd
--- /dev/null
+++ b/swayamvar.c
@@ -0,0 +1,43 @@
+#include
+#include
+
+int main(){
+
+int n, i, count = 0, gr = 0, gm = 0;
+char bride[10000];
+char groom[10000];
+scanf("%d",&n);
+scanf("%s",bride);
+scanf("%s",groom);
+
+for(i=0;i0){
+ gr--;
+ count++;
+ }
+ else
+ break;}
+
+else{if(gm>0){
+
+ gm--;
+ count++;
+ }
+ else
+ break;}
+
+}
+
+printf("%d",n-count);
+
+}
From 57f76ad9714ad7669f848f95e6544a3ceb6f121d Mon Sep 17 00:00:00 2001
From: Shihaf Ahil M <54226314+shihaf@users.noreply.github.com>
Date: Wed, 7 Oct 2020 21:53:30 +0530
Subject: [PATCH 009/129] Create quick_sort.c
In this program quick sort algorithm is implemented using C.
---
quick_sort.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 quick_sort.c
diff --git a/quick_sort.c b/quick_sort.c
new file mode 100644
index 00000000..87cb44dd
--- /dev/null
+++ b/quick_sort.c
@@ -0,0 +1,55 @@
+#include
+void swap(int* a, int* b)
+{
+ int t = *a;
+ *a = *b;
+ *b = t;
+}
+int partition (int arr[], int low, int high)
+{
+ int pivot = arr[high];
+ int i = (low - 1);
+
+ for (int j = low; j <= high- 1; j++)
+ {
+ if (arr[j] < pivot)
+ {
+ i++;
+ swap(&arr[i], &arr[j]);
+ }
+ }
+ swap(&arr[i + 1], &arr[high]);
+ return (i + 1);
+}
+void quickSort(int arr[], int low, int high)
+{
+ if (low < high)
+ {
+ int pi = partition(arr, low, high);
+ quickSort(arr, low, pi - 1);
+ quickSort(arr, pi + 1, high);
+ }
+}
+void printArray(int arr[], int size)
+{
+ int i;
+ for (i=0; i < size; i++)
+ printf("%d ", arr[i]);
+ printf("\n");
+}
+int main()
+{
+ int n;
+ printf("enter the size of the array : ");
+ scanf("%d",&n);
+ int arr[n];
+ printf("\nenter array elements: ");
+ for(int i=0;i
Date: Thu, 8 Oct 2020 00:29:02 +0530
Subject: [PATCH 010/129] Create insertionsort.c
insertion sort
---
insertionsort.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
create mode 100644 insertionsort.c
diff --git a/insertionsort.c b/insertionsort.c
new file mode 100644
index 00000000..319e7b48
--- /dev/null
+++ b/insertionsort.c
@@ -0,0 +1,36 @@
+#include
+
+int main()
+{
+ int i,j,n,temp,a[30];
+ printf("Enter the number of elements:");
+ scanf("%d",&n);
+ printf("\nEnter the elements\n");
+
+ for(i=0;i=0))
+ {
+ a[j+1]=a[j]; //moves element forward
+ j=j-1;
+ }
+
+ a[j+1]=temp; //insert element in proper place
+ }
+
+ printf("\nSorted list is as follows\n");
+ for(i=0;i
Date: Thu, 8 Oct 2020 07:50:54 +0530
Subject: [PATCH 011/129] Update README.md
---
README.md | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index cd6de503..5b258ae2 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,13 @@ To earn your Hacktoberfest tee or tree reward, you must register and make four v
## Steps For Contribution
1. Fork this repo
- 2. Add a file
- 3. commit the code
- 4. Make pull request
+ 2. Star this repo
+ 3. Add a file
+ 4. commit the code
+ 5. Make pull request
+***
+
+
+ Thank You
+
+
From e44510b0687637b8a5cb046f3a79ebb4ebab2055 Mon Sep 17 00:00:00 2001
From: AshuKulu <71241200+AshuKulu@users.noreply.github.com>
Date: Thu, 8 Oct 2020 09:36:59 +0530
Subject: [PATCH 012/129] Update README.md
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 5b258ae2..f505e5ac 100644
--- a/README.md
+++ b/README.md
@@ -10,14 +10,14 @@
- Pull requests can be made in any GitHub-hosted repositories/projects.
- You can sign up anytime between October 1 and October 31.
-## HactoberFest Rules :
+## HacktoberFest Rules :
To earn your Hacktoberfest tee or tree reward, you must register and make four valid pull requests (PRs) between October 1-31 (in any time zone). PRs can be made to any public repo on GitHub, not only the ones with issues labeled Hacktoberfest. If a maintainer reports your pull request as spam or behavior not in line with the project’s code of conduct, you will be ineligible to participate. This year, the first 70,000 participants who successfully complete the challenge will be eligible to receive a prize.
***
From ffa7c20412a7a1b3a15448f6b4a415d38cbda7c5 Mon Sep 17 00:00:00 2001
From: mohakmaheshwari1205
<68627419+mohakmaheshwari1205@users.noreply.github.com>
Date: Thu, 8 Oct 2020 09:40:54 +0530
Subject: [PATCH 013/129] Add files via upload
please upload it.
---
Bubble_sort.cpp | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
create mode 100644 Bubble_sort.cpp
diff --git a/Bubble_sort.cpp b/Bubble_sort.cpp
new file mode 100644
index 00000000..fabb6159
--- /dev/null
+++ b/Bubble_sort.cpp
@@ -0,0 +1,41 @@
+#include
+using namespace std;
+void swapping(int &a, int &b) { //swap the content of a and b
+ int temp;
+ temp = a;
+ a = b;
+ b = temp;
+}
+void display(int *array, int size) {
+ for(int i = 0; i array[j+1]) { //when the current item is bigger than next
+ swapping(array[j], array[j+1]);
+ swaps = 1; //set swap flag
+ }
+ }
+ if(!swaps)
+ break; // No swap in this pass, so array is sorted
+ }
+}
+int main() {
+ int n;
+ cout << "Enter the number of elements: ";
+ cin >> n;
+ int arr[n]; //create an array with given number of elements
+ cout << "Enter elements:" << endl;
+ for(int i = 0; i> arr[i];
+ }
+ cout << "Array before Sorting: ";
+ display(arr, n);
+ bubbleSort(arr, n);
+ cout << "Array after Sorting: ";
+ display(arr, n);
+}
From 777b415adfa0c4bcb78fdbdac182183adbb34929 Mon Sep 17 00:00:00 2001
From: mohakmaheshwari1205
<68627419+mohakmaheshwari1205@users.noreply.github.com>
Date: Thu, 8 Oct 2020 10:04:35 +0530
Subject: [PATCH 014/129] Circular linked list
please add this file.
---
Circular_linked_list.cpp | 173 +++++++++++++++++++++++++++++++++++++++
1 file changed, 173 insertions(+)
create mode 100644 Circular_linked_list.cpp
diff --git a/Circular_linked_list.cpp b/Circular_linked_list.cpp
new file mode 100644
index 00000000..145c9022
--- /dev/null
+++ b/Circular_linked_list.cpp
@@ -0,0 +1,173 @@
+#include
+using namespace std;
+
+struct Node
+{
+ int data;
+ struct Node *next;
+};
+//insert a new node in an empty list
+struct Node *insertInEmpty(struct Node *last, int new_data)
+{
+ // if last is not null then list is not empty, so return
+ if (last != NULL)
+ return last;
+
+ // allocate memory for node
+ struct Node *temp = new Node;
+
+ // Assign the data.
+ temp -> data = new_data;
+ last = temp;
+
+ // Create the link.
+ last->next = last;
+
+ return last;
+}
+//insert new node at the beginning of the list
+struct Node *insertAtBegin(struct Node *last, int new_data)
+{
+ //if list is empty then add the node by calling insertInEmpty
+ if (last == NULL)
+ return insertInEmpty(last, new_data);
+
+ //else create a new node
+ struct Node *temp = new Node;
+
+ //set new data to node
+ temp -> data = new_data;
+ temp -> next = last -> next;
+ last -> next = temp;
+
+ return last;
+}
+//insert new node at the end of the list
+struct Node *insertAtEnd(struct Node *last, int new_data)
+{
+ //if list is empty then add the node by calling insertInEmpty
+ if (last == NULL)
+ return insertInEmpty(last, new_data);
+
+ //else create a new node
+ struct Node *temp = new Node;
+
+ //assign data to new node
+ temp -> data = new_data;
+ temp -> next = last -> next;
+ last -> next = temp;
+ last = temp;
+
+ return last;
+}
+
+//insert a new node in between the nodes
+struct Node *insertAfter(struct Node *last, int new_data, int after_item)
+{
+ //return null if list is empty
+ if (last == NULL)
+ return NULL;
+
+ struct Node *temp, *p;
+ p = last -> next;
+ do
+ {
+ if (p ->data == after_item)
+ {
+ temp = new Node;
+ temp -> data = new_data;
+ temp -> next = p -> next;
+ p -> next = temp;
+
+ if (p == last)
+ last = temp;
+ return last;
+ }
+ p = p -> next;
+ } while(p != last -> next);
+
+ cout << "The node with data "< next; // Point to the first Node in the list.
+
+// Traverse the list starting from first node until first node is visited again
+
+do {
+ cout << p -> data << "==>";
+ p = p -> next;
+ } while(p != last->next);
+ if(p == last->next)
+ cout<data;
+ cout<<"\n\n";
+ }
+
+//delete the node from the list
+void deleteNode(Node** head, int key)
+{
+ // If linked list is empty retun
+ if (*head == NULL)
+ return;
+
+ // If the list contains only a single node,delete that node; list is empty
+ if((*head)->data==key && (*head)->next==*head) {
+ free(*head);
+ *head=NULL;
+ }
+Node *last=*head,*d;
+
+// If key is the head
+if((*head)->data==key) {
+ while(last->next!=*head) // Find the last node of the list
+ last=last->next;
+
+ // point last node to next of head or second node of the list
+ last->next=(*head)->next;
+ free(*head);
+ *head=last->next;
+ }
+
+// end of list is reached or node to be deleted not there in the list
+while(last->next!=*head&&last->next->data!=key) {
+ last=last->next;
+}
+// node to be deleted is found, so free the memory and display the list
+if(last->next->data==key) {
+ d=last->next;
+ last->next=d->next;
+ cout<<"The node with data "<
Date: Thu, 8 Oct 2020 12:35:13 +0530
Subject: [PATCH 015/129] Binary Search Tree
BST with Inorder, Preorder and Postorder output.
---
binarySearchTree.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
create mode 100644 binarySearchTree.c
diff --git a/binarySearchTree.c b/binarySearchTree.c
new file mode 100644
index 00000000..3a139436
--- /dev/null
+++ b/binarySearchTree.c
@@ -0,0 +1,52 @@
+#include
+#include
+struct node
+{ int data;
+ struct node* left;
+ struct node* right;
+};
+struct node* createNode(int value){
+ struct node* newNode = malloc(sizeof(struct node));
+ newNode->data = value;
+ newNode->left = newNode->right= NULL;
+ return newNode;
+}
+struct node* insert(struct node* root, int data)
+{ if (root == NULL) {return createNode(data);}
+ if (data < root->data) {root->left = insert(root->left, data);}
+ else if (data > root->data) {root->right = insert(root->right, data);}
+ return root;
+}
+void inorder(struct node* root){
+ if(root == NULL) return;
+ inorder(root->left);
+ printf("%d ", root->data);
+ inorder(root->right);
+}
+void preorder(struct node* root){
+ if(root == NULL) return;
+ printf("%d ", root->data);
+ preorder(root->left);
+ preorder(root->right);
+}
+void postorder(struct node* root){
+ if(root == NULL) return;
+ postorder(root->left);
+ postorder(root->right);
+ printf("%d ", root->data);
+}
+int main(){
+ int inp, rt;
+ struct node *root = NULL;
+ printf("Enter the value of the ROOT:\n");
+ scanf("%d", &rt);
+ root = insert(root, rt);
+ while(1){ printf("Enter Value or -1 to STOP:\n");
+ scanf("%d", &inp);
+ if(inp==-1){break;}
+ insert(root, inp); }
+
+ printf("Your INORDER output is:\n"); inorder(root);
+ printf("\nYour PREORDER output is:\n"); preorder(root);
+ printf("\nYour POSTORDER output is:\n"); postorder(root);
+}
From 8f93dee0524fc0a0925818a6058dcb193268a9f1 Mon Sep 17 00:00:00 2001
From: Yash2rule <53874370+Yash2rule@users.noreply.github.com>
Date: Thu, 8 Oct 2020 15:56:01 +0530
Subject: [PATCH 016/129] added tower of hanoi program in c language
---
towerofhanoi.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
create mode 100644 towerofhanoi.c
diff --git a/towerofhanoi.c b/towerofhanoi.c
new file mode 100644
index 00000000..2ed07993
--- /dev/null
+++ b/towerofhanoi.c
@@ -0,0 +1,77 @@
+/******************************************************************************
+
+ Online C Compiler.
+ Code, Compile, Run and Debug C program online.
+Write your code in this editor and press "Run" button to compile and execute it.
+
+*******************************************************************************/
+
+
+/*
+
+ * C program for Tower of Hanoi using Recursion
+
+ */
+
+#include
+
+
+
+void towers(int, char, char, char);
+
+
+
+int main()
+
+{
+
+ int num;
+
+
+
+ printf("Enter the number of disks : ");
+
+ scanf("%d", &num);
+
+ printf("The sequence of moves involved in the Tower of Hanoi are :\n");
+
+ towers(num, 'A', 'C', 'B');
+
+ return 0;
+
+}
+
+void towers(int num, char frompeg, char topeg, char auxpeg)
+
+{
+
+ if (num == 1)
+
+ {
+
+ printf("\n Move disk 1 from peg %c to peg %c", frompeg, topeg);
+
+ return;
+
+ }
+
+ towers(num - 1, frompeg, auxpeg, topeg);
+
+ printf("\n Move disk %d from peg %c to peg %c", num, frompeg, topeg);
+
+ towers(num - 1, auxpeg, topeg, frompeg);
+
+}
+/*OUTPUT :
+
+Enter the number of disks : 3
+The sequence of moves involved in the Tower of Hanoi are :
+
+Move disk 1 from peg A to peg C
+Move disk 2 from peg A to peg B
+Move disk 1 from peg C to peg B
+Move disk 3 from peg A to peg C
+Move disk 1 from peg B to peg A
+Move disk 2 from peg B to peg C
+Move disk 1 from peg A to peg C
+*/
\ No newline at end of file
From d3044d9c2cddc8eec0997d6be8c71951b518b4de Mon Sep 17 00:00:00 2001
From: kri14 <63444812+kri14@users.noreply.github.com>
Date: Thu, 8 Oct 2020 20:54:03 +0530
Subject: [PATCH 017/129] matrix multiplication for unknown matrix
this is a simple program to first input a matrix and then perform matrix multiplication
---
matrix multiplication for unknown matrix | 38 ++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 matrix multiplication for unknown matrix
diff --git a/matrix multiplication for unknown matrix b/matrix multiplication for unknown matrix
new file mode 100644
index 00000000..383b5faf
--- /dev/null
+++ b/matrix multiplication for unknown matrix
@@ -0,0 +1,38 @@
+//matrix multiplication //
+#include
+main()
+{
+ int a1,a2,a3;
+ printf ("enter a,b,c(m[a][b]&m[b][c]):\n");
+ scanf("%d%d%d",&a1,&a2,&a3);
+
+ int m1[a1][a2],m2[a2][a3],c[a1][a3];
+ printf ("enter values of m[%d][%d]\n",a1,a2);
+ for(int i=1;i<=a1;i++)
+ {
+ for(int j=1;j<=a2;j++)
+ scanf("%d",&m1[i][j]);
+ }
+ printf ("\n enter values of m[%d][%d]\n",a2,a3);
+ for(int i=1;i<=a2;i++)
+ {
+ for(int j=1;j<=a3;j++)
+ scanf("%d",&m2[i][j]);
+ }
+ printf("MULTIPLICATION OF MATRIX :\n");
+ for(int i=1;i<=a1;i++)
+ {
+ for(int j=1;j<=a3;j++)
+ { int x=0;
+ for(int k=1;k<=a2;k++)
+ x=x+(m1[i][k]*m2[k][j]);
+ c[i][j]=x;
+ }
+ }
+ for(int i=1;i<=a1;i++)
+ {
+ for(int j=1;j<=a3;j++)
+ printf("%d\t",c[i][j]);
+ printf("\n");
+ }
+}
From 070820e20f19c91c95e913e3d68f7e05797fb8a3 Mon Sep 17 00:00:00 2001
From: Yash2rule <53874370+Yash2rule@users.noreply.github.com>
Date: Thu, 8 Oct 2020 21:47:29 +0530
Subject: [PATCH 018/129] added java program for selection sort
---
SelectionSort.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
create mode 100644 SelectionSort.java
diff --git a/SelectionSort.java b/SelectionSort.java
new file mode 100644
index 00000000..c5e11d6e
--- /dev/null
+++ b/SelectionSort.java
@@ -0,0 +1,51 @@
+import java.util.Scanner;
+
+public class SelectionSort {
+
+ public static void selectionSorting(int arr[]) {
+
+ int i=0;
+ int minIndex=0;
+ while(i
Date: Fri, 9 Oct 2020 12:02:00 +0545
Subject: [PATCH 019/129] Create bubble-sort.py
---
bubble-sort.py | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 bubble-sort.py
diff --git a/bubble-sort.py b/bubble-sort.py
new file mode 100644
index 00000000..90da2c2c
--- /dev/null
+++ b/bubble-sort.py
@@ -0,0 +1,29 @@
+# Optimized bubble sort in python
+
+
+def bubbleSort(array):
+
+ # Run loops two times: one for walking throught the array
+ # and the other for comparison
+ for i in range(len(array)):
+
+ # swapped keeps track of swapping
+ swapped = True
+ for j in range(0, len(array) - i - 1):
+
+ # To sort in descending order, change > to < in this line.
+ if array[j] > array[j + 1]:
+
+ # Swap if greater is at the rear position
+ (array[j], array[j + 1]) = (array[j + 1], array[j])
+ swapped = False
+
+ # If there is not swapping in the last swap, then the array is already sorted.
+ if swapped:
+ break
+
+
+data = [-2, 45, 0, 11, -9]
+bubbleSort(data)
+print('Sorted Array in Ascending Order:')
+print(data)
From 586f4d2114d0709fc85d738b54f871c14406edfb Mon Sep 17 00:00:00 2001
From: vedika1810 <65010751+vedika1810@users.noreply.github.com>
Date: Fri, 9 Oct 2020 14:08:56 +0530
Subject: [PATCH 020/129] Create linkedlistcreate.c
created my first PR-creation of a singly linked list
---
linkedlistcreate.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 linkedlistcreate.c
diff --git a/linkedlistcreate.c b/linkedlistcreate.c
new file mode 100644
index 00000000..f17c40c6
--- /dev/null
+++ b/linkedlistcreate.c
@@ -0,0 +1,37 @@
+#include
+struct node
+{
+ int data;
+ struct node*next;
+};
+int main()
+{
+ int n,i;
+ struct node *head,*prev,*p;
+ printf("enter the size of list:");
+ scanf("%d",&n);
+ head=NULL;
+ for(i=0;idata);
+ p->next=NULL;
+ if(head==NULL)
+ head=p;
+ else
+ prev->next=p;
+ prev=p;
+ }
+ display(head);
+ return 0;
+}
+void display(struct node *head)
+{
+ if(head==NULL)
+ printf("NULL");
+ else
+ {
+ printf("%d\t",head->data);
+ display(head->next);
+ }
+}
From 2814f8aaf2352d9781d3f00ff1588baa996d8ee8 Mon Sep 17 00:00:00 2001
From: Indhu R <64062602+IndhuR@users.noreply.github.com>
Date: Fri, 9 Oct 2020 15:07:37 +0530
Subject: [PATCH 021/129] created balancing equation
The program shows whether the given equation is balanced or not.
---
balancing_equation.c | 74 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100644 balancing_equation.c
diff --git a/balancing_equation.c b/balancing_equation.c
new file mode 100644
index 00000000..2d9169d7
--- /dev/null
+++ b/balancing_equation.c
@@ -0,0 +1,74 @@
+#include
+#define SIZE 50
+char stack[SIZE];
+int Top = -1;
+void push(char item)
+{
+ if( Top >= SIZE-1 )
+ printf("\nStack overflow.\n");
+ else
+ stack[++Top] = item;
+}
+char pop()
+{
+ char item;
+ if( Top<0 )
+ {
+ printf("\nStack underflow : INVALID EXPRESSION\n");
+ }
+ else
+ {
+ return(stack[Top--]);
+ }
+}
+void checkExp(char exp[])
+{
+ int i=0;
+ char c = exp[i],item;
+ while(exp[i]!='\0')
+ {
+ if(c=='{'||c=='['||c=='(')
+ push(c);
+ else if(c=='}')
+ {
+ item = pop();
+ if( item!='{' )
+ {
+ printf("missing pair of %c.\n",item);
+ printf("Non balanced expression.\n");
+ return;
+ }
+ }
+ else if(c==']')
+ {
+ item = pop();
+ if( item!='[' ){
+ printf("missing pair of %c.\n",item);
+ printf("Non balanced expression.\n");
+ return;
+ }
+ }
+ else if(c==')')
+ {
+ item = pop();
+ if( item!='(' ){
+ printf("missing pair of %c.\n",item);
+ printf("Non balanced expression.\n");
+ return;
+ }
+ }
+ c=exp[++i];
+ }
+ if(Top<0)
+ printf("Balanced Expression.\n");
+ else
+ printf("Non balanced expression:(Since it has odd number of symbols)\n");
+}
+int main()
+{
+ char exp[SIZE];
+ printf("Enter expression.\n");
+ gets(exp);
+ checkExp(exp);
+ return 0;
+}
From e7b8288c1a054bcffd0905efcc6b2638983387e9 Mon Sep 17 00:00:00 2001
From: Maulik Chavda <44502272+maulikchavda@users.noreply.github.com>
Date: Fri, 9 Oct 2020 16:00:25 +0530
Subject: [PATCH 022/129] Added BFS(Breath First Search) Code in C
---
BFS.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 174 insertions(+)
create mode 100644 BFS.c
diff --git a/BFS.c b/BFS.c
new file mode 100644
index 00000000..d7294ed1
--- /dev/null
+++ b/BFS.c
@@ -0,0 +1,174 @@
+#include
+#include
+
+#define MAX 100
+
+#define initial 1
+#define waiting 2
+#define visited 3
+
+int n;
+int adj[MAX][MAX];
+int state[MAX];
+void create_graph();
+void BF_Traversal();
+void BFS(int v);
+
+int queue[MAX], front = -1,rear = -1;
+void insert_queue(int vertex);
+int delete_queue();
+int isEmpty_queue();
+
+int main()
+{
+ create_graph();
+ BF_Traversal();
+ return 0;
+}
+
+void BF_Traversal()
+{
+ int v;
+
+ for(v=0; v rear)
+ return 1;
+ else
+ return 0;
+}
+
+int delete_queue()
+{
+ int delete_item;
+ if(front == -1 || front > rear)
+ {
+ printf("Queue Underflow\n");
+ exit(1);
+ }
+
+ delete_item = queue[front];
+ front = front+1;
+ return delete_item;
+}
+
+void create_graph()
+{
+ int count,max_edge,origin,destin;
+
+ printf("Enter number of vertices : ");
+ scanf("%d",&n);
+ max_edge = n*(n-1);
+
+ for(count=1; count<=max_edge; count++)
+ {
+ printf("Enter edge %d( -1 -1 to quit ) : \n",count);
+ scanf("%d %d",&origin,&destin);
+
+ if((origin == -1) && (destin == -1))
+ break;
+
+ if(origin>=n || destin>=n || origin<0 || destin<0)
+ {
+ printf("Invalid edge!\n");
+ count--;
+ }
+ else
+ {
+ adj[origin][destin] = 1;
+ }
+ }
+}
+
+/* ""OUTPUT""
+Enter number of vertices : 9
+Enter edge 1( -1 -1 to quit ) :
+0
+1
+Enter edge 2( -1 -1 to quit ) :
+0
+3
+Enter edge 3( -1 -1 to quit ) :
+0
+4
+Enter edge 4( -1 -1 to quit ) :
+1
+2
+Enter edge 5( -1 -1 to quit ) :
+3
+6
+Enter edge 6( -1 -1 to quit ) :
+4
+7
+Enter edge 7( -1 -1 to quit ) :
+6
+4
+Enter edge 8( -1 -1 to quit ) :
+6
+7
+Enter edge 9( -1 -1 to quit ) :
+2
+5
+Enter edge 10( -1 -1 to quit ) :
+4
+5
+Enter edge 11( -1 -1 to quit ) :
+7
+5
+Enter edge 12( -1 -1 to quit ) :
+7
+8
+Enter edge 13( -1 -1 to quit ) :
+-1
+-1
+Enter Start Vertex for BFS:
+0
+0 1 3 4 2 6 5 7 8
+
+*/
From d6ab84ee74a518b04f84a9751bdd5ea3506f95b2 Mon Sep 17 00:00:00 2001
From: Maulik Chavda <44502272+maulikchavda@users.noreply.github.com>
Date: Fri, 9 Oct 2020 16:05:57 +0530
Subject: [PATCH 023/129] Added Red Black Tree Code in C
---
mainREDBLACKTREE.c | 231 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 231 insertions(+)
create mode 100644 mainREDBLACKTREE.c
diff --git a/mainREDBLACKTREE.c b/mainREDBLACKTREE.c
new file mode 100644
index 00000000..8bd570b1
--- /dev/null
+++ b/mainREDBLACKTREE.c
@@ -0,0 +1,231 @@
+#include
+#include
+#define RED 0
+#define BLACK 1
+struct rbnode
+{
+ int value;
+ int color;
+ struct rbnode*left,*right,*parent;
+};
+void flipcolor(struct rbnode*node)
+{
+ (node->color)=1-(node->color);
+}
+struct rbnode*singleleftrotate(struct rbnode*gp)
+{
+ struct rbnode*p=gp->right;
+ gp->right=p->left;
+ if(p->left!=NULL)
+ {
+ p->left->parent=gp;
+ }
+ p->parent=gp->parent;
+ p->left=gp;
+ gp->parent=p;
+ flipcolor(gp);
+ flipcolor(p);
+ return p;
+}
+struct rbnode*singlerightrotate(struct rbnode*gp)
+{
+ struct rbnode*p=gp->left;
+ gp->left=p->right;
+ if(p->right!=NULL)
+ {
+ p->right->parent=gp;
+ }
+ p->parent=gp->parent;
+ p->right=gp;
+ gp->parent=p;
+ flipcolor(gp);
+ flipcolor(p);
+ return p;
+}
+struct rbnode*doubleleftrightrotate(struct rbnode*gp)
+{
+ struct rbnode*c,*p;
+ p=gp->left;
+ c=p->right;
+ p->right=c->left;
+ if(c->left!=NULL)
+ {
+ c->left->parent=p;
+ }
+ c->left=p;
+ p->parent=c;
+ gp->left=c;
+ c->parent=gp;
+ return singlerightrotate(gp);
+}
+struct rbnode*doublerightleftrotate(struct rbnode*gp)
+{
+ struct rbnode*c,*p;
+ p=gp->right;
+ c=p->left;
+ p->left=c->right;
+ if(c->right!=NULL)
+ {
+ c->right->parent=p;
+ }
+ c->right=p;
+ p->parent=c;
+ gp->right=c;
+ c->parent=gp;
+ return singleleftrotate(gp);
+}
+int isroot(struct rbnode*node)
+{
+ if(node->parent==NULL)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+int getcolor(struct rbnode*node)
+{
+ if(node==NULL)
+ {
+ return BLACK;
+ }
+ else
+ {
+ return node->color;
+ }
+}
+struct rbnode*getuncle(struct rbnode*node)
+{
+ struct rbnode*p,*gp;
+ p=node->parent;
+ gp=p->parent;
+ if(p==gp->left)
+ {
+ return gp->right;
+ }
+ else
+ {
+ return gp->left;
+ }
+}
+struct rbnode*insert(struct rbnode*root,int v)
+{
+ struct rbnode*newnode,*x,*p,*gp,*uncle;
+ newnode=(struct rbnode*)malloc(sizeof(struct rbnode));
+ if(newnode==NULL)
+ {
+ printf("Malloc failed");
+ }
+ newnode->value=v;
+ newnode->color=RED;
+ newnode->left=NULL;
+ newnode->right=NULL;
+ if(root==NULL)
+ {
+ newnode->color=BLACK;
+ newnode->parent=NULL;
+ return newnode;
+ }
+ p=root;
+ while(1)
+ {
+ if(vvalue)
+ {
+ if(p->left==NULL)
+ {
+ p->left=newnode;
+ newnode->parent=p;
+ break;
+ }
+ p=p->left;
+ }
+ else
+ {
+ if(p->right==NULL)
+ {
+ p->right=newnode;
+ newnode->parent=p;
+ break;
+ }
+ p=p->right;
+ }
+ }
+ x=newnode;
+ while(1)
+ {
+ p=x->parent;
+ if(p->color==BLACK)
+ break;
+ gp=p->parent;
+ uncle=getuncle(newnode);
+ if(getcolor(uncle)==RED)
+ {
+ p->color=BLACK;
+ uncle->color=BLACK;
+ gp->color=RED;
+ if(isroot(gp)){root=gp;gp->color=BLACK;break;}
+ x=gp;
+ continue;
+ }
+ else
+ {
+ if(p==gp->left)
+ {
+ if(newnode==p->left)
+ {
+ if(isroot(gp)) root=singlerightrotate(gp);
+ else if(gp==gp->parent->left) gp->parent->left=singlerightrotate(gp);
+ else gp->parent->right=singlerightrotate(gp);
+ }
+ else
+ {
+ if(isroot(gp)) root=doubleleftrightrotate(gp);
+ else if(gp==gp->parent->left) gp->parent->left=doubleleftrightrotate(gp);
+ else gp->parent->right=doubleleftrightrotate(gp);
+ }
+ }
+ else
+ {
+ if(newnode==p->right)
+ {
+ if(isroot(gp)) root=singleleftrotate(gp);
+ else if(gp==gp->parent->left) gp->parent->left=singleleftrotate(gp);
+ else gp->parent->right=singleleftrotate(gp);
+ }
+ else
+ {
+ if(isroot(gp)) root=doublerightleftrotate(gp);
+ else if(gp==gp->parent->left) gp->parent->left=doublerightleftrotate(gp);
+ else gp->parent->right=doublerightleftrotate(gp);
+ }
+ }
+ break;
+ }
+ }
+ return root;
+}
+void traverse(struct rbnode*root)
+{
+ if(root==NULL) return;
+ traverse(root->left);
+ printf("%d %s\n",root->value,(root->color)?"BLACK":"RED");
+ traverse(root->right);
+}
+int main(int argc, char *argv[])
+{
+ struct rbnode*root=NULL;
+ int value;
+ printf("\nEnter node values = ");
+ while(1)
+ {
+ scanf("%d",&value);
+ if(value==-1) break;
+ root=insert(root,value);
+ traverse(root);
+ }
+ printf("\nDisplaying Tree : \n");
+ traverse(root);
+ return 0;
+}
From bb09c11be0f75da2b7c71b34537b957e71478e33 Mon Sep 17 00:00:00 2001
From: Ishan-1101 <67185870+Ishan-1101@users.noreply.github.com>
Date: Fri, 9 Oct 2020 22:54:32 +0530
Subject: [PATCH 024/129] Create function overloading
My First PR
---
function overloading | 62 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100644 function overloading
diff --git a/function overloading b/function overloading
new file mode 100644
index 00000000..53fe48bf
--- /dev/null
+++ b/function overloading
@@ -0,0 +1,62 @@
+// area of a circle, a rectangle and a triangle, using concept of function overloading.
+#include
+#include
+using namespace std;
+//Area of circle
+float area(float r)
+{
+ float ret=3.14*pow(r,2);
+ return ret;
+}
+//Area of the rectangle
+float area(float l,float b)
+{
+ float ret=l*b;
+ return ret;
+}
+//Area of the triangle
+float area(float s1,float s2,float s3)
+{
+ float t=(s1+s2+s3)/2;
+ float ret=sqrt(t*(t-s1)*(t-s2)*(t-s3));
+ return ret;
+}
+int main()
+{
+ int ch;
+ while(1){
+ cout<<"\n 1. Area of circle \n"<<"2. Area of reactangle\n"<<"3. Area of triangle\n"<<"Enter your choice: ";
+ cin>>ch;
+ switch(ch)
+ {
+ case 1:
+ {
+ float n;
+ cout<<"\nEnter radius: ";
+ cin>>n;
+ cout<<"\nArea of sphere: "<>l>>b;
+ cout<<"Area of Rectangle: "<>s1>>s2>>s3;
+ cout<
Date: Sat, 10 Oct 2020 11:00:08 +0530
Subject: [PATCH 025/129] Added two Searching Algorithms
---
Binary_Search.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++
Linear_Search.c | 53 ++++++++++++++++++++++++++
2 files changed, 151 insertions(+)
create mode 100644 Binary_Search.c
create mode 100644 Linear_Search.c
diff --git a/Binary_Search.c b/Binary_Search.c
new file mode 100644
index 00000000..e63af64b
--- /dev/null
+++ b/Binary_Search.c
@@ -0,0 +1,98 @@
+#include
+#include
+
+void binarySearch(int searchValue, int a[], int n);
+
+void selectionSort(int a[], int n)
+{
+ int i, j, minimunIndex, temp;
+
+ printf("Just started to sort Using the Selection Sort Algorithm\n");
+ // Started Sorting Using Selection sort
+ for ( i = 0; i < n; i++)
+ {
+ minimunIndex = i;
+
+ for ( j = i + 1; j < n; j++)
+ {
+ if (a[minimunIndex] > a[j])
+ minimunIndex = j;
+ }
+ temp = a[i];
+ a[i] = a[minimunIndex];
+ a[minimunIndex] = temp;
+ }
+ // Now the Array has been sorted in Ascending Order
+ printf("Ended Sorting using Selection Sort\n");
+}
+
+
+void main()
+{
+ int length, i, searchValue;
+ printf("Welcome to the Binary Search!!\n");
+ printf("You can search the data element from an array, don't worry I will do it for you\n");
+ printf("For simplicity here the data elements are considered as integers\n");
+ printf("So let me know how many integers you want:\n");
+ scanf("%d", &length);
+
+ // Creating an array using calloc i.e. array for the user defined length
+ int *a = (int *) calloc (length, sizeof(int));
+
+ // Accepting the data elements for the array
+ printf("Please enter the integers now:\n");
+ for ( i = 0; i < length; i++)
+ {
+ scanf("%d", &a[i]);
+ }
+
+ // Accepting the Value to be searched
+ printf("Please enter the value you want me to search for:\n");
+ scanf("%d", &searchValue);
+
+ // Binary Search needs the sorted array as input without which the search can't occur
+ // Hence sorting elements before the Search
+ selectionSort(a, length);
+ // Implementing the Binary Search on the Sorted Array
+ binarySearch(searchValue, a, length);
+
+ printf("Thanks for Investing time in Me!!");
+}
+
+void binarySearch(int searchValue, int a[], int n)
+{
+ int middle, first, last;
+ first = 0; // First initalized to the first position of the array
+ last = n-1; // Last initialized to the last position of the array
+
+ middle = first + last / 2; // Middle position of the array is calculated using this formula
+
+ printf("Starting to search the Data element --> %4d\n", searchValue);
+ // Search until the last element is greater then equal to the first element
+ while( first <= last)
+ {
+ // If the searched value is greater then the element at the middle position modify the first position to the upper half of the array
+ if(a[middle] < searchValue)
+ first = middle + 1;
+
+ // Also check if the the element at the middle position is equal to the searched value
+ else if(a[middle] == searchValue)
+ {
+ printf("The element %d was found at the location %d starting from 0\n", searchValue, middle);
+ break;
+ }
+ // If the searched value is lesser then the element at the middle position modify the last position to the lower half of the array
+ else
+ last = middle - 1;
+
+ middle = first + last / 2;
+ }
+
+ // If first becomes greater then the last position in the array then the element is not at all found in the array
+ if (first > last)
+ {
+ printf("Sorry the element you wanted me to Search doesn't exist in the given array\n");
+ }
+
+ printf("Just Ended Binary Search\n");
+}
\ No newline at end of file
diff --git a/Linear_Search.c b/Linear_Search.c
new file mode 100644
index 00000000..8f962354
--- /dev/null
+++ b/Linear_Search.c
@@ -0,0 +1,53 @@
+#include
+#include
+void linearSearch(int searchValue, int a[], int n);
+
+void main()
+{
+ int length, j, searchValue;
+ printf("Welcome to Linear Search!!\n");
+ printf("You can search a data element from an array\n");
+ printf("For Simplicity lets start with the data elements as integers.\n");
+ printf("Please enter the length of the array you want me to create:\n");
+ scanf("%d", &length);
+
+ // Creating an array using calloc i.e. array for the user defined length
+ int *a = (int *) calloc (length, sizeof(int));
+
+ // Accepting the data elements for the array
+ printf("Now you can enter the integers of your choice:\n");
+ for(j = 0; j < length; j++)
+ {
+ scanf("%d", &a[j]);
+ }
+
+ // Accepting the Value to be searched
+ printf("Now Please enter the value you want me to search\n");
+ scanf("%d", &searchValue);
+
+ // Implementing the Linear Search
+ linearSearch(searchValue, a, length);
+
+ printf("Thanks For investing time in Me!!");
+}
+
+void linearSearch(int searchValue, int a[], int n)
+{
+ int i;
+ printf("I have just started to search for the Value --> %4d\n", searchValue);
+ // Linearly Search for element in the array for the searched value
+ for ( i = 0; i < n; i++)
+ {
+ if (a[i] == searchValue)
+ {
+ printf("Here you go the element %d is found at %d location from the starting from 0\n",searchValue, i);
+ break;
+ }
+ }
+ // If the whole array is traversed and the searched value is not found at any location then it doesn't exist in the data structure
+ if ( i == n)
+ {
+ printf("Sorry, the element you wanted me to found doesn't exist in the given array.\n");
+ }
+ printf("The Linear Search has Ended\n");
+}
\ No newline at end of file
From 044e1cc7890cbc315032f43899a56019d7fcc632 Mon Sep 17 00:00:00 2001
From: Amit Sagar <61499207+Amit-Sagar@users.noreply.github.com>
Date: Sat, 10 Oct 2020 15:24:04 +0530
Subject: [PATCH 026/129] Create Armstrong_number.c
Adding Armstrong number program
---
Armstrong_number.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 Armstrong_number.c
diff --git a/Armstrong_number.c b/Armstrong_number.c
new file mode 100644
index 00000000..a3c2d76d
--- /dev/null
+++ b/Armstrong_number.c
@@ -0,0 +1,19 @@
+#include
+ int main()
+{
+int n,r,sum=0,temp;
+printf("enter the number=");
+scanf("%d",&n);
+temp=n;
+while(n>0)
+{
+r=n%10;
+sum=sum+(r*r*r);
+n=n/10;
+}
+if(temp==sum)
+printf("armstrong number ");
+else
+printf("not armstrong number");
+return 0;
+}
From 75657ba4e61b42fb1026a270697aa26056814aed Mon Sep 17 00:00:00 2001
From: choudharyrajritu <72249151+choudharyrajritu@users.noreply.github.com>
Date: Sat, 10 Oct 2020 15:33:42 +0530
Subject: [PATCH 027/129] Create hactoberfest.html
---
hactoberfest.html | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 hactoberfest.html
diff --git a/hactoberfest.html b/hactoberfest.html
new file mode 100644
index 00000000..08ffcfd3
--- /dev/null
+++ b/hactoberfest.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+ Hactoberfest2020
+
+
+ This is hactoberfest pull request 1
+ Only Unique lines to get pull request accepted,
+ I will accept your request in 24 hrs if not then send me email
+
+ - Dont modify above line
+ - Starting from here...
+ - Happy hacking...
+ - Happy hacking.2121..
+ - All the best for future
+ - Visit here for register in this fest.
+
+ To create a pull request,first you should fork the file and edit or create the file ,then commit changes and give pull req
+
+
+
From 55e51cf600ebcc48d9ec61682e95427250b95501 Mon Sep 17 00:00:00 2001
From: SUMYAK JAIN <3456gaurav@gmail.com>
Date: Sat, 10 Oct 2020 15:39:19 +0530
Subject: [PATCH 028/129] Create Bit_stuffed_data.c
---
Bit_stuffed_data.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
create mode 100644 Bit_stuffed_data.c
diff --git a/Bit_stuffed_data.c b/Bit_stuffed_data.c
new file mode 100644
index 00000000..8073357e
--- /dev/null
+++ b/Bit_stuffed_data.c
@@ -0,0 +1,26 @@
+// data communiction and networking Bit Stuffed data algorithm implemented
+#include "stdio.h"
+int main()
+{
+int i=0,c=0;
+char data[100];
+printf("Enter the data: ");
+scanf("%s",data);
+printf("\nBit Stuffed Data \n");
+printf("01111110");
+for(i=0;data[i]; i++)
+{
+ if(data[i]=='1')
+ c++;
+ else
+ c=0;
+printf("%c",data[i]);
+if(c==5)
+ {
+ printf("0");
+ c=0;
+ }
+}
+printf("01111110");
+return 1;
+}
From 80c00394780306cd23c32be0cd96f7ba0acbaf19 Mon Sep 17 00:00:00 2001
From: choudharyrajritu1 <72594304+choudharyrajritu1@users.noreply.github.com>
Date: Sat, 10 Oct 2020 15:39:20 +0530
Subject: [PATCH 029/129] Create calculator.c
---
calculator.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 calculator.c
diff --git a/calculator.c b/calculator.c
new file mode 100644
index 00000000..a8bd462a
--- /dev/null
+++ b/calculator.c
@@ -0,0 +1,29 @@
+#include
+int main() {
+ char operator;
+ double first, second;
+ printf("Enter an operator (+, -, *,): ");
+ scanf("%c", &operator);
+ printf("Enter two operands: ");
+ scanf("%lf %lf", &first, &second);
+
+ switch (operator) {
+ case '+':
+ printf("%.1lf + %.1lf = %.1lf", first, second, first + second);
+ break;
+ case '-':
+ printf("%.1lf - %.1lf = %.1lf", first, second, first - second);
+ break;
+ case '*':
+ printf("%.1lf * %.1lf = %.1lf", first, second, first * second);
+ break;
+ case '/':
+ printf("%.1lf / %.1lf = %.1lf", first, second, first / second);
+ break;
+ // operator doesn't match any case constant
+ default:
+ printf("Error! operator is not correct");
+ }
+
+ return 0;
+}
From 2961dd1011804ace2df3b932f0c0acc0ab984f52 Mon Sep 17 00:00:00 2001
From: OarabileMwiya <42150074+OarabileMwiya@users.noreply.github.com>
Date: Sat, 10 Oct 2020 17:52:17 +0200
Subject: [PATCH 030/129] Add files via upload
Separate bad apples from good apples using training agents.
---
data.txt | 121 ++++++++++++++++++++
mwi00174_ECA.py | 290 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 411 insertions(+)
create mode 100644 data.txt
create mode 100644 mwi00174_ECA.py
diff --git a/data.txt b/data.txt
new file mode 100644
index 00000000..bfb94ee3
--- /dev/null
+++ b/data.txt
@@ -0,0 +1,121 @@
+Color Size Class
+-0.731271511775 0.694867473874 A
+0.527549237953 -0.489861948521 B
+-0.00912982581612 -0.101017870423 A
+0.303185945446 0.577446702271 A
+-0.812280826452 -0.943305046956 B
+0.67153020784 -0.13446586419 B
+0.524560164916 -0.995787893298 B
+-0.10922561189 0.443080064682 A
+-0.542475557459 0.890541391108 A
+0.802854915223 -0.938820033933 B
+-0.949108278013 0.082824945587 A
+0.878298325557 -0.237591524624 B
+-0.566801205739 -0.155766848835 A
+-0.94191842485 -0.556616667454 A
+-0.124224812699 -0.0083755172363 A
+-0.533831099485 -0.538266916918 B
+-0.562437925325 -0.0807930685245 A
+-0.420436770819 -0.957020589468 B
+0.675155951325 0.112908645305 A
+0.284588725865 -0.628187468211 B
+0.985086824352 0.719893057591 C
+-0.758220080388 -0.33460962928 A
+0.442968815167 0.422383539391 A
+0.872881173599 -0.155786000077 B
+0.660071386549 0.340611132828 C
+-0.393262978134 0.175161212287 A
+0.764958001664 0.692394836857 C
+0.0105676411592 0.178004515965 A
+-0.930948339697 -0.514520052914 A
+0.594808495109 -0.171372001398 B
+-0.653985196842 0.0975975227763 A
+0.406081524131 0.348971661005 A
+-0.250593958997 -0.122076739911 A
+0.0168529765 0.55688523 A
+0.0418768352263 -0.213489810072 A
+-0.0206129590755 -0.940850072066 B
+-0.913025419287 0.406764177208 A
+0.966375434619 0.18636746076 C
+-0.212800627244 -0.659301606289 B
+0.00447711686697 0.964153275077 A
+0.541046279662 0.0792348968996 A
+0.720579557841 -0.535647743874 B
+0.0275433263753 0.904934776537 A
+0.155589615602 -0.0817365361787 A
+-0.461441045117 0.0959926189325 A
+0.91423256292 -0.988581741099 B
+0.567310465231 0.640971823851 C
+0.772359161652 0.481006823666 C
+0.618279801745 0.037356567046 A
+0.122715729557 -0.147818640624 A
+-0.887753404959 0.740020310353 A
+0.139998667753 -0.600321159646 B
+0.00944093485773 -0.0301497755445 A
+-0.28642007091 -0.307844161964 A
+0.0769575914757 0.246978905595 A
+0.224904929565 -0.0837063998006 A
+-0.944050031832 -0.540789937446 A
+-0.645577482123 0.168921741557 A
+0.722017721707 0.596877881155 C
+0.594195125271 0.632874741121 C
+-0.489411919825 0.683489664548 A
+0.346227050877 -0.833531724392 B
+-0.966618739769 -0.97088005015 B
+0.511173550504 -0.500881548693 B
+-0.781022745411 0.249604168305 A
+-0.311154271807 -0.860969242938 B
+-0.680748950612 0.054760798096 A
+-0.663710107555 -0.454171126363 A
+-0.158162641582 -0.623921390497 B
+0.0202319618574 -0.581818014896 B
+-0.958363782981 -0.964270958344 B
+0.935806620302 0.75106848847 C
+-0.49528379544 -0.983039475073 B
+0.757435796418 -0.924166938803 B
+0.638828221226 0.924402250362 C
+0.14056114049 -0.656965809645 B
+0.73556212887 0.947550472319 C
+-0.134099757799 -0.61176271003 B
+0.79935653927 -0.963814032719 B
+0.974099435856 0.565400751459 C
+-0.321808704298 -0.573940407238 B
+0.348910139448 0.675402140308 C
+0.864374943787 -0.312300370418 B
+0.764786404933 0.374220364307 C
+-0.830639539167 -0.660611716411 B
+0.821975567016 -0.574063610017 B
+0.682264391412 -0.263784001189 B
+0.908614914344 0.774530209434 C
+-0.791450003971 -0.921724402806 B
+0.57623289745 0.657011942938 C
+0.563807203266 -0.243920742323 B
+0.141563051198 -0.552571854502 B
+0.850134404217 -0.0844614819175 B
+0.655536313291 -0.975236511027 B
+0.340823278048 -0.816633754767 B
+0.976316997212 -0.157972825139 B
+0.826784034332 0.939626553676 C
+0.95990577178 0.0858263949694 C
+0.552417965972 0.969791742288 C
+0.607712561968 0.814307533994 C
+0.681437044493 0.492369770809 C
+0.926771766643 0.616505256745 C
+0.813879009012 0.835413167676 C
+0.385113929206 0.697982244973 C
+0.712554277826 0.793208742233 C
+0.92015763393 0.142465388435 C
+0.551514500631 0.683861717087 C
+0.582181436736 0.617309240328 C
+0.9472322191 0.0907540076517 C
+0.0905741795363 0.929890657573 C
+0.522131319706 0.94703956916 C
+0.489261235477 0.975183382445 C
+0.795818343274 0.49754692715 C
+0.874235919078 0.564947370742 C
+0.692536133202 0.534999580285 C
+0.41604005413 0.747884149626 C
+0.4268739968 0.630006887857 C
+0.413380626503 0.687585244489 C
+0.826290010407 0.456495689574 C
+0.407847188838 0.629821117579 C
\ No newline at end of file
diff --git a/mwi00174_ECA.py b/mwi00174_ECA.py
new file mode 100644
index 00000000..3d5bb08c
--- /dev/null
+++ b/mwi00174_ECA.py
@@ -0,0 +1,290 @@
+import random
+
+#
+# NAME:Oarabile Mwiya
+# ID :201700174.
+# ECA
+
+# VectorAdd() returns a vector obtained by adding two vectors,
+#which are parameters of the function
+# result is a vector
+def VectorAdd(a,b):
+
+ #Check equality of the vectors
+ assert len(a)==len(b)
+
+ #Initialise an empty vector list
+ newVector = []
+
+ #Iterate with respect to the vector length and add corresponding values
+ for i in range(len(a)):
+
+ v = a[i] + b[i]
+
+ newVector.append(v)
+
+
+ return newVector
+# performs vector subtraction on two vectors and returns a
+# vector
+def VectorSub(a,b):
+ #check if length of vectors are equal
+ assert len(a)==len(b)
+
+ #Initialize an empty vector list
+ newVector = []
+
+ #Iterate the indices wrt to vector length and subtract corresponding values
+ for i in range(len(a)):
+
+ v = a[i] - b[i]
+
+ newVector.append(v)
+
+ return newVector
+
+
+# Implement this: VectorMult() performs vector multiplication and returns a scalar
+# (number)
+def VectorMult(a,b):
+ #compare length equality of vector a and b
+ assert len(a)==len(b)
+
+ total = 0
+
+ #Iterate the vector indices wrt to the vector length and multiply corresponding values
+ for i in range(len(a)):
+ v = a[i] * b[i]
+ total = total + v
+ return total
+
+
+# DO NOT MODIFY THIS FUNCTION
+def argMax(scores):
+ """
+ Returns the key with the highest value.
+ """
+ if len(scores) == 0: return None
+ all = scores.items()
+ values = [x[1] for x in all]
+ maxIndex = values.index(max(values))
+ return all[maxIndex][0]
+
+
+#MulticlassPerceptronLearning Function
+
+def MulticlassPerceptronLearning(trainingvectors):
+
+ #Initalize weight
+ weights={'A':[0,0,0],'B':[0,0,0],'C':[0,0,0]}
+
+ #Set threshold to zero
+ threshold = 0
+
+ #Initialize scores of class(A,B,C respectively )
+ scoreA = 0
+
+ scoreB = 0
+
+ scoreC = 0
+
+ #Check if selected apple is bad
+ Badapple = True
+
+ #Feature Vector for apples
+ VectorApples = ""
+
+ #Declare and initialize variable iteration
+ iteration = 0
+
+ #Run the loop for a thousand iterations and check if a Bad apple is found
+ while(Badapple == True and iteration < 1000):
+
+ #Initialize empty list for classification
+ classification = []
+
+ #Increment variable iteration by 1 and ouput each iteration at each interval
+ iteration += 1
+ print "\nIteration Number:",iteration
+
+ #Iterate apples in the trainingvectors using for loop
+ for AppleVector in trainingvectors:
+
+ #Distiguish apart classless features
+ appleFeatures = [AppleVector[0], AppleVector[1]]
+
+ #Instance of the current feature vector
+ VectorApples = AppleVector[2]
+
+ #Threshold is appended to the feature vector
+ appleFeatures.append(1)
+
+ # Feature vectors mutplied with correspong weight vectors
+
+ scoreA = VectorMult(appleFeatures, weights['A'])
+
+ scoreB = VectorMult(appleFeatures, weights['B'])
+
+ scoreC = VectorMult(appleFeatures, weights['C'])
+
+ #Scores stored in a dictionary
+ scores = {'A': scoreA, 'B': scoreB, 'C': scoreC}
+
+ #Using percept identify class with highest score
+ MaximumClass = argMax(scores)
+
+ #Check if The highest score correspond with the Current class
+ if(MaximumClass != VectorApples):
+
+ #Subtract Apple Feature Vector From Incorrect Class Vector and output desired results
+ print "Bad Apple Detectad : ",AppleVector
+
+ bad = VectorSub(weights[MaximumClass],appleFeatures)
+
+ weights[MaximumClass] = bad
+
+ #Add Apple Feature Vector To Correct Class Vector
+
+ Good = VectorAdd(weights[VectorApples],appleFeatures)
+
+ weights[VectorApples] = Good
+
+ #append bad apples to classification list
+ classification.append("Bad")
+
+ #If its highest score classify it a good apple in list then transcend to next iteration
+ else:
+ classification.append("Good")
+
+ print "\AFTER ITERATION NUMBER:",iteration
+ print weights
+
+ # Check If Bad Apple Was Found
+ if "Bad" in classification:
+ Badapple = True
+ else:
+ Badapple = False
+
+ print "\n\nFinal W:",weights
+ return weights
+
+
+
+
+
+ #LoadFile function to load file
+
+def LoadFile(fileName):
+
+ dataFile=open(fileName,"r")
+
+ #Initalize empty apples list
+ Apples = []
+
+ #Intialize empty firstlist variable
+ firstlist = []
+
+ #Initialize empty secondlist variable
+ secondlist = []
+
+ #start from the first value in tha data file
+ next(dataFile)
+
+ #Iterate line by line the data txt file
+ for line in dataFile:
+
+ #Our data file cointains list of apples in terms of(color ,size and class) thus use them to split data
+ #Use split to convert each corresponding line into an array
+ lineSplit = line.split()
+
+ #Split color from the data text and store in array..
+ color = float(lineSplit[0])
+
+ #split size from the data text and store in array..
+ size = float(lineSplit[1])
+
+ #Append the split features into apples empty list ..
+ Apples.append([color,size,lineSplit[2]])
+
+ #Random number seed generator
+ random.seed(2)
+
+ #Randomise apples
+ random.shuffle(Apples)
+
+ # system must read in the data file, split such that 70% of apples are used for training and 30% for testing
+ #Extract first 84apples which is 70% for training
+ firstlist = Apples[:84]
+
+ #Extract last 84apples which is 70% for training
+ secondlist = Apples[84:]
+
+ #Return list
+ return firstlist,secondlist
+
+#Evaluate Function(Interpretation of classified apples)..
+def Evaluate(weights,appleVectors):
+
+ numapples=len(appleVectors)
+ numcorrect=0
+
+ #Initialize scores of class(A,B,C respectively )
+ scoreA = 0
+
+ scoreB = 0
+
+ scoreC = 0
+
+ print "\n\nAPPLES CLASSIFICATION"
+
+ #Iterate apples in apple set
+ for SetApples in appleVectors:
+
+ # Extract cost and size
+ appleFeatures = [SetApples[0], SetApples[1]]
+
+ # Set vector to apples class
+ VectorApples = SetApples[2]
+
+ #Threshold appended to vector
+ appleFeatures.append(1)
+ print "\n\n Apple Being Classified:",SetApples
+
+ # Feature vectors mutplied with correspong weight vectors
+ scoreA = VectorMult(appleFeatures, weights['A'])
+
+ scoreB = VectorMult(appleFeatures, weights['B'])
+
+ scoreC = VectorMult(appleFeatures, weights['C'])
+
+ #Scores stored in a dictionary
+ scores = {'A': scoreA, 'B': scoreB, 'C': scoreC}
+
+ # Determine Class With Max Score
+ MaximumClass = argMax(scores)
+
+ print "Maximum Class Score : ",MaximumClass
+
+ #Check if max class equals the current apple class and iterate if condition met
+ if(MaximumClass == VectorApples):
+ numcorrect+=1
+
+
+ return round(float(numcorrect)/numapples*100,2)
+
+
+
+# DO NOT MODIFY THIS FUNCTION
+def RunExperiment():
+ training,testing=LoadFile("data.txt")
+ w=MulticlassPerceptronLearning(training)
+ score=Evaluate(w,testing)
+
+ print "Evaluation Score:",score
+
+RunExperiment()
+
+
+#Performance of Machine Learning model****
+# The model has an evaluation score of 97.22 which is much closer to a perfect score (100) which derives
+#that the model can clearly classify apples as bad or good apples based on the color , size and class.
From ad484c967629c4d22d5ed99697156ea4640445e5 Mon Sep 17 00:00:00 2001
From: kaushikijain <72103964+kaushikijain@users.noreply.github.com>
Date: Sat, 10 Oct 2020 22:50:28 +0530
Subject: [PATCH 031/129] Create Insert Interval.cpp
---
Insert Interval.cpp | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 Insert Interval.cpp
diff --git a/Insert Interval.cpp b/Insert Interval.cpp
new file mode 100644
index 00000000..b14d9c49
--- /dev/null
+++ b/Insert Interval.cpp
@@ -0,0 +1,27 @@
+//https://leetcode.com/problems/insert-interval/
+
+//This is the link to the problem you can go and see the problem from there
+
+class Solution {
+public:
+ vector> insert(vector>& intervals, vector& newInterval) {
+ int n = intervals.size();
+ vector > ans;
+ for(int i = 0; i < n; ++i){
+ if(intervals[i][1] < newInterval[0]){
+ ans.push_back(intervals[i]);
+ }
+ else if(newInterval[1] < intervals[i][0]){
+ ans.push_back(newInterval);
+ newInterval = intervals[i];
+ }
+ else{
+ newInterval[0] = min(newInterval[0],intervals[i][0]);
+ newInterval[1] = max(newInterval[1],intervals[i][1]);
+ }
+
+ }
+ ans.push_back(newInterval);
+ return ans;
+ }
+};
From 8c120b57f87b6b07ebb977b413b5e570d5d08f28 Mon Sep 17 00:00:00 2001
From: Maulik Chavda <44502272+maulikchavda@users.noreply.github.com>
Date: Sun, 11 Oct 2020 10:43:28 +0530
Subject: [PATCH 032/129] Queue Using Stack in C
---
mainqusingstack.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 144 insertions(+)
create mode 100644 mainqusingstack.c
diff --git a/mainqusingstack.c b/mainqusingstack.c
new file mode 100644
index 00000000..6c99c1da
--- /dev/null
+++ b/mainqusingstack.c
@@ -0,0 +1,144 @@
+#include
+#include
+#define N 5
+
+int top1=-1,top2=-1;
+int s1[N]={},s2[N]={};
+
+void push(int val,int n)
+{
+ if(n==-1)
+ {
+ if(top1!=N-1)
+ {
+ s1[++top1]=val;
+ }
+ else
+ {
+ printf("\n Queue is full");
+ }
+ }
+ else
+ {
+ s2[++top2]=val;
+ }
+}
+int pop(int n)
+{
+ int temp;
+ if(n==-1)
+ {
+ temp=s1[top1--];
+ }
+ else
+ {
+ temp=s2[top2--];
+ }
+ return temp;
+}
+void insertvalue(int value)
+{
+ push(value,1);
+}
+int deletevalue()
+{
+ int temp;
+ if(top1==-1&&top2==-1)
+ {
+ printf("Queue is empty");
+ }
+ else
+ {
+ if(top2!=-1)
+ {
+ pop(2);
+ }
+ else
+ {
+ while(top1!=-1)
+ {
+ temp=pop(1);
+ push(temp,2);
+ }
+ pop(2);
+ }
+ }
+}
+void display()
+{
+ int i;
+ for(i=top2;i>-1;i--)
+ {
+ printf("%d\n",s2[i]);
+ }
+ for(i=0;i<=top1;i++)
+ {
+ printf("%d\n",s1[i]);
+ }
+ printf("\n");
+}
+int main(int argc, char *argv[]) {
+ int n,value,temp;
+ printf("\n 1.Enqueue \t\n 2.Dequeue \t\n 3.Display \t\n 4.EXIT \t\n");
+ do
+ {
+ printf("\nEnter choice = ");
+ scanf("%d",&n);
+ switch(n)
+ {
+ case 1:
+ printf("\n Enter value to be inserted = ");
+ scanf("%d",&value);
+ insertvalue(value);
+ break;
+ case 2:
+ temp=deletevalue();
+ printf("%d is deleted\n",temp);
+ break;
+ case 3:
+ display();
+ break;
+ case 4:
+ printf("EXIT");
+ }
+ }while(n!=4);
+ return 0;
+}
+
+/* ""OUTPUT""
+
+ 1.Enqueue
+ 2.Dequeue
+ 3.Display
+ 4.EXIT
+
+Enter choice = 1
+
+ Enter value to be inserted = 10
+
+Enter choice = 1
+
+ Enter value to be inserted = 20
+
+Enter choice = 1
+
+ Enter value to be inserted = 30
+
+Enter choice = 3
+30
+20
+10
+
+
+Enter choice = 2
+30 is deleted
+
+Enter choice = 3
+20
+10
+
+
+Enter choice = 4
+EXIT
+
+*/
From ca3a2ed765b4d8655f37749013110334f012c082 Mon Sep 17 00:00:00 2001
From: Rohit Singh <55148217+Rohit14kvs@users.noreply.github.com>
Date: Sun, 11 Oct 2020 14:29:44 +0530
Subject: [PATCH 033/129] create figure.py
---
figure.py | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
create mode 100644 figure.py
diff --git a/figure.py b/figure.py
new file mode 100644
index 00000000..58b7665e
--- /dev/null
+++ b/figure.py
@@ -0,0 +1,22 @@
+import turtle
+
+t = turtle.Turtle()
+s = turtle.Screen()
+s.bgcolor("black")
+t.pencolor("green")
+t.speed(0.2)
+t.penup()
+t.goto(0, 200)
+t.pendown()
+a = 0
+b = 0
+while True :
+ t.forward(a)
+ t.right(b)
+ a += 3
+ b += 1
+ if b == 200 :
+ break
+ t.hideturtle()
+
+turtle.done()
From 1a54a5cd3f75aebeb1a5f7b88cd487f315552093 Mon Sep 17 00:00:00 2001
From: Jakob Waibel
Date: Sun, 11 Oct 2020 12:25:33 +0200
Subject: [PATCH 034/129] feat: implementing counting-sort
---
counting-sort.cpp | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 counting-sort.cpp
diff --git a/counting-sort.cpp b/counting-sort.cpp
new file mode 100644
index 00000000..ee1050f5
--- /dev/null
+++ b/counting-sort.cpp
@@ -0,0 +1,38 @@
+#include
+using namespace std;
+
+int main()
+{
+ static int array[]{4,12,56,754,1235,435,64,1,2,3,4};
+ int max = array[0];
+ for (int i = 0; i < sizeof(array)/sizeof(array[0]); i++) {
+ if (array[i] > max) {
+ max = array[i];
+ }
+ }
+
+ int bookkeeping[max];
+
+ for (int i = 0; i < sizeof(bookkeeping)/sizeof(bookkeeping[0])+1; i++) {
+ bookkeeping[i] = 0;
+ }
+
+ for(int i : array) {
+ bookkeeping[i] = bookkeeping[i]+1;
+ }
+
+ int count = 0;
+
+ for (int i = 0; i < sizeof(bookkeeping)/sizeof(bookkeeping[0])+1; i++) {
+ if (bookkeeping[i] != 0) {
+ array[count++] = i;
+ bookkeeping[i]--;
+ i--;
+
+ }
+ }
+
+ for (int i = 0; i < sizeof(array)/sizeof(array[0]);i++) {
+ cout << array[i] << " ";
+ }
+}
\ No newline at end of file
From b1261a10bcd75034d77d4fc0cd637d5acaf660b6 Mon Sep 17 00:00:00 2001
From: Jakob Waibel
Date: Sun, 11 Oct 2020 12:27:44 +0200
Subject: [PATCH 035/129] feat: implementing merge-sort
---
merge-sort.cpp | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
create mode 100644 merge-sort.cpp
diff --git a/merge-sort.cpp b/merge-sort.cpp
new file mode 100644
index 00000000..b6de43c3
--- /dev/null
+++ b/merge-sort.cpp
@@ -0,0 +1,65 @@
+#include
+using namespace std;
+
+void print(int a[], int sz)
+{
+ for (int i = 0; i < sz; i++) cout << a[i] << " ";
+ cout << endl;
+}
+
+void merge(int a[], const int low, const int mid, const int high)
+{
+ int *temp = new int[high-low+1];
+
+ int left = low;
+ int right = mid+1;
+ int current = 0;
+
+ while(left <= mid && right <= high) {
+ if(a[left] <= a[right]) {
+ temp[current] = a[left];
+ left++;
+ }
+ else {
+ temp[current] = a[right];
+ right++;
+ }
+ current++;
+ }
+
+ if(left > mid) {
+ for (int i = right; i <= high; i++) {
+ temp[current] = a[i];
+ current++;
+ }
+ }
+ else {
+ for(int i=left; i <= mid; i++) {
+ temp[current] = a[i];
+ current++;
+ }
+ }
+ for(int i=0; i<=high-low;i++) {
+ a[i+low] = temp[i];
+ }
+ delete[] temp;
+}
+
+void merge_sort(int a[], const int low, const int high)
+{
+ if(low >= high) return;
+ int mid = (low+high)/2;
+ merge_sort(a, low, mid);
+ merge_sort(a, mid+1, high);
+ merge(a, low, mid, high);
+}
+
+int main()
+{
+ int a[] = {38, 27, 43, 3, 9, 82, 10};
+ int arraySize = sizeof(a)/sizeof(int);
+ print(a, arraySize);
+ merge_sort(a, 0, (arraySize-1) );
+ print(a, arraySize);
+ return 0;
+}
\ No newline at end of file
From 36a757a0d32704fec48aa54eed8f565a0bfec2f2 Mon Sep 17 00:00:00 2001
From: michal-dbrnowski
Date: Sun, 11 Oct 2020 12:40:35 +0200
Subject: [PATCH 036/129] Create sieve_of_eratosthenes.py
---
sieve_of_eratosthenes.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 sieve_of_eratosthenes.py
diff --git a/sieve_of_eratosthenes.py b/sieve_of_eratosthenes.py
new file mode 100644
index 00000000..5f52d45b
--- /dev/null
+++ b/sieve_of_eratosthenes.py
@@ -0,0 +1,13 @@
+def sieve_of_eratosthenes(n: int) -> list:
+ """
+ Return ordered list of primes in the interval from 2 to n.
+
+ :param n: (int) right-bound of interval
+ :return: (list) ordered list of all prime numbers from 2 to n
+ """
+ primes = list(range(2, n + 1))
+ for i in primes:
+ for j in range(2, n // i + 1):
+ if i * j in primes:
+ primes.remove(i * j)
+ return primes
\ No newline at end of file
From ee72afc2d7c02e6c2e860c8be3c5f866484a872e Mon Sep 17 00:00:00 2001
From: JahnaviChitta <39951127+JahnaviChitta@users.noreply.github.com>
Date: Sun, 11 Oct 2020 16:15:57 +0530
Subject: [PATCH 037/129] Add Milk scheduling greedy algo from spoj
https://www.spoj.com/problems/MSCHED/ is the link for this problem, and this is the basic yet important algorithm that one needs to know to learn greedy.
---
milkScheduling_greedy.cpp | 49 +++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 milkScheduling_greedy.cpp
diff --git a/milkScheduling_greedy.cpp b/milkScheduling_greedy.cpp
new file mode 100644
index 00000000..dd8f4225
--- /dev/null
+++ b/milkScheduling_greedy.cpp
@@ -0,0 +1,49 @@
+// This is a very famous greedy alogrithm
+// This is written by me, and this passed as test cases
+// U can find the problem from link given below
+
+
+// https://www.spoj.com/problems/MSCHED/
+
+#include
+using namespace std;
+#include
+typedef vector v;
+bool cmp(vector a, vector b){
+ return (a[0] >= b[0]);
+}
+
+int main() {
+ int n; cin >> n;
+ vector< v > arr;
+ for(int i = 0; i < n; i++){
+ v t;
+ int gallons, dead;
+ cin >> gallons >> dead;
+ t.push_back(gallons);
+ t.push_back(dead);
+ arr.push_back(t);
+ }
+ bool slot[n];
+ sort(arr.begin(), arr.end(), cmp);
+ /*for(int i = 0; i < n; i++){
+ cout << arr[i][0] << " " << arr[i][1] << "\n";
+ }
+ */
+ for(int i = 0; i < n; i++) slot[i] = false;
+
+ int res = 0;
+ for(int i = 0; i < n; i++){
+ for(int j = min(n, arr[i][1]) -1; j >= 0; j--){
+ if (slot[j] == false){
+ res += arr[i][0];
+ slot[j] = true;
+ break;
+ }
+ }
+ }
+ cout << res << "\n";
+
+
+ return 0;
+}
From 2e9f5fcd205dfbdc3ff0c32e3e4fe67b313898ff Mon Sep 17 00:00:00 2001
From: michal-dbrnowski
Date: Sun, 11 Oct 2020 12:46:06 +0200
Subject: [PATCH 038/129] Create fibonacci.py
---
fibonacci.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 fibonacci.py
diff --git a/fibonacci.py b/fibonacci.py
new file mode 100644
index 00000000..9d8e844d
--- /dev/null
+++ b/fibonacci.py
@@ -0,0 +1,19 @@
+def fibonacci(n):
+ """
+ Return n-th Fibonacci number.
+
+ Raises TypeError if n is not integer.
+ Raises ValueError if n is negative.
+ :param n: (int) natural number
+ :return: (int) n-th Fibonacci number
+ """
+ a, b = 0, 1
+ if n == 0:
+ return a
+ elif n == 1:
+ return b
+ else:
+ for _ in range(2, n + 1):
+ c = a + b
+ a, b = b, c
+ return b
\ No newline at end of file
From 1aa3cdf80a8121aa5405e45cf6aca03bfadc2467 Mon Sep 17 00:00:00 2001
From: JahnaviChitta <39951127+JahnaviChitta@users.noreply.github.com>
Date: Sun, 11 Oct 2020 16:20:05 +0530
Subject: [PATCH 039/129] Add python code to evaluate post fix expression.
This is an algorithm to evaluate any post fix expression in python using list as stack.
---
postFixEvaluation.py | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 postFixEvaluation.py
diff --git a/postFixEvaluation.py b/postFixEvaluation.py
new file mode 100644
index 00000000..98cb8a12
--- /dev/null
+++ b/postFixEvaluation.py
@@ -0,0 +1,28 @@
+## Algorithm to evaluate any postfix expression in python using list as stack
+
+
+def postFixOp(s):
+ n = len(s)
+ stk = []
+ for i in s:
+ #print(stk)
+ if i.isnumeric() :
+ stk.append(i)
+ else:
+ b = stk[-1]
+ stk.pop()
+ a = stk[-1]
+ stk.pop()
+ if i == '+':
+ stk.append(int(a)+int(b))
+ elif i == '-':
+ stk.append(int(a)-int(b))
+ elif i == '*':
+ stk.append(int(a)*int(b))
+ elif stk == '/':
+ sk.append(int(a)/int(b))
+
+ return stk[0]
+
+s = input()
+print(postFixOp(s))
From b40ed97af54e449a08b6206a68b8b3b677176f62 Mon Sep 17 00:00:00 2001
From: JahnaviChitta <39951127+JahnaviChitta@users.noreply.github.com>
Date: Sun, 11 Oct 2020 16:24:50 +0530
Subject: [PATCH 040/129] Add cpp code to find the median of incoming nums
This is an cpp code to find the median of incoming numbers with less complexity of O(nlog(n)). Knowing this algorithm lets beginners to obtain grip on priority queue and stack.
---
medianOfIncomingNums.cpp | 47 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
create mode 100644 medianOfIncomingNums.cpp
diff --git a/medianOfIncomingNums.cpp b/medianOfIncomingNums.cpp
new file mode 100644
index 00000000..f343daeb
--- /dev/null
+++ b/medianOfIncomingNums.cpp
@@ -0,0 +1,47 @@
+// cpp program to find the median of incoming numbers in O(nlog(n)) complexity
+
+#include
+using namespace std;
+#include
+
+int main() {
+ int n; cin >> n;
+ priority_queue leftMxPq;
+ priority_queue , greater> rgtMnPq;
+ float cm = 0.0f; //cm = current median
+ int left_size;
+ int right_size;
+ for(int i = 0; i < n; i++){
+ int x;
+ cin >> x;
+ left_size = leftMxPq.size();
+ right_size = rgtMnPq.size();
+ if (x > cm){
+ if (right_size > left_size){
+ int t = rgtMnPq.top();
+ leftMxPq.push(t);
+ rgtMnPq.pop();
+ }
+ rgtMnPq.push(x);
+ }
+ else{
+ if (left_size > right_size){
+ int t = leftMxPq.top();
+ rgtMnPq.push(t);
+ leftMxPq.pop();
+ }
+ leftMxPq.push(x);
+ }
+ left_size = leftMxPq.size();
+ right_size = rgtMnPq.size();
+ if (left_size == right_size)
+ cm = (leftMxPq.top() + rgtMnPq.top())/2.0f;
+ else if (left_size > right_size)
+ cm = leftMxPq.top();
+ else
+ cm = rgtMnPq.top();
+
+ printf("%.2f ", cm);
+ }
+ return 0;
+}
From 9201446371ee927d78c6d0ec6b029e37e5fbf606 Mon Sep 17 00:00:00 2001
From: Rupali409 <54534133+Rupali409@users.noreply.github.com>
Date: Sun, 11 Oct 2020 17:27:55 +0530
Subject: [PATCH 041/129] Create corrected_calculator_c
Here i had added correction in line enter an operator (+,-,*,/).
---
corrected_calculator_c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
create mode 100644 corrected_calculator_c
diff --git a/corrected_calculator_c b/corrected_calculator_c
new file mode 100644
index 00000000..718e5b8d
--- /dev/null
+++ b/corrected_calculator_c
@@ -0,0 +1,29 @@
+#include
+int main() {
+ char operator;
+ double first, second;
+ printf("Enter an operator (+, -, *, /): ");
+ scanf("%c", &operator);
+ printf("Enter two operands: ");
+ scanf("%lf %lf", &first, &second);
+
+ switch (operator) {
+ case '+':
+ printf("%.1lf + %.1lf = %.1lf", first, second, first + second);
+ break;
+ case '-':
+ printf("%.1lf - %.1lf = %.1lf", first, second, first - second);
+ break;
+ case '*':
+ printf("%.1lf * %.1lf = %.1lf", first, second, first * second);
+ break;
+ case '/':
+ printf("%.1lf / %.1lf = %.1lf", first, second, first / second);
+ break;
+ // operator doesn't match any case constant
+ default:
+ printf("Error! operator is not correct");
+ }
+
+ return 0;
+}
From 217573a1e22863f571059ee0168d63710c9c3975 Mon Sep 17 00:00:00 2001
From: sagarmaheshwari <56976819+sagarmaheshwari@users.noreply.github.com>
Date: Sun, 11 Oct 2020 19:47:22 +0530
Subject: [PATCH 042/129] Add files via upload
modified_kaprekar_numbers.c - for Modified Kaprekar Numbers challenge on Hackerrank, 30 points
encryption_hackerrank.c - for encryption challenge on hackerrank, 30 points
---
encryption_hackerrank.c | 74 +++++++++++++++++++++++++
modified_kaprekar_numbers.c | 107 ++++++++++++++++++++++++++++++++++++
2 files changed, 181 insertions(+)
create mode 100644 encryption_hackerrank.c
create mode 100644 modified_kaprekar_numbers.c
diff --git a/encryption_hackerrank.c b/encryption_hackerrank.c
new file mode 100644
index 00000000..3493ac46
--- /dev/null
+++ b/encryption_hackerrank.c
@@ -0,0 +1,74 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+char* readline();
+
+// Complete the encryption function below.
+
+// Please either make the string static or allocate on the heap. For example,
+// static char str[] = "hello world";
+// return str;
+//
+// OR
+//
+// char* str = "hello world";
+// return str;
+//
+char* encryption(char* s) {
+
+
+}
+
+int main()
+{
+ FILE* fptr = fopen(getenv("OUTPUT_PATH"), "w");
+
+ char* s = readline();
+
+ char* result = encryption(s);
+
+ fprintf(fptr, "%s\n", result);
+
+ fclose(fptr);
+
+ return 0;
+}
+
+char* readline() {
+ size_t alloc_length = 1024;
+ size_t data_length = 0;
+ char* data = malloc(alloc_length);
+
+ while (true) {
+ char* cursor = data + data_length;
+ char* line = fgets(cursor, alloc_length - data_length, stdin);
+
+ if (!line) { break; }
+
+ data_length += strlen(cursor);
+
+ if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') { break; }
+
+ size_t new_length = alloc_length << 1;
+ data = realloc(data, new_length);
+
+ if (!data) { break; }
+
+ alloc_length = new_length;
+ }
+
+ if (data[data_length - 1] == '\n') {
+ data[data_length - 1] = '\0';
+ }
+
+ data = realloc(data, data_length);
+
+ return data;
+}
diff --git a/modified_kaprekar_numbers.c b/modified_kaprekar_numbers.c
new file mode 100644
index 00000000..0d03b8ba
--- /dev/null
+++ b/modified_kaprekar_numbers.c
@@ -0,0 +1,107 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+char* readline();
+
+// Complete the kaprekarNumbers function below.
+void kaprekarNumbers(int p, int q) {
+ int flag=0;
+ for(long i=p;i<=q;i++){
+ long long int num=i*i,x,y;
+ if(i<=9){
+ x=num/10;
+ y=num-(x*10);
+ }
+ else if(i<=99){
+ x=num/100;
+ y=num-(x*100);
+ }
+ else if(i<=999){
+ x=num/1000;
+ y=num-(x*1000);
+ }
+ else if(i<=9999){
+ x=num/10000;
+ y=num-(x*10000);
+ }
+ else if(i<=99999){
+ x=num/100000;
+ y=num-(x*100000);
+ }
+ if(x+y==i){
+ printf("%ld ",i);
+ flag=1;
+ }
+ }
+ if(flag==0){
+ printf("INVALID RANGE");
+ }
+
+}
+
+int main()
+{
+ char* p_endptr;
+ char* p_str = readline();
+ int p = strtol(p_str, &p_endptr, 10);
+
+ if (p_endptr == p_str || *p_endptr != '\0') { exit(EXIT_FAILURE); }
+
+ char* q_endptr;
+ char* q_str = readline();
+ int q = strtol(q_str, &q_endptr, 10);
+
+ if (q_endptr == q_str || *q_endptr != '\0') { exit(EXIT_FAILURE); }
+
+ kaprekarNumbers(p, q);
+
+ return 0;
+}
+
+char* readline() {
+ size_t alloc_length = 1024;
+ size_t data_length = 0;
+ char* data = malloc(alloc_length);
+
+ while (true) {
+ char* cursor = data + data_length;
+ char* line = fgets(cursor, alloc_length - data_length, stdin);
+
+ if (!line) {
+ break;
+ }
+
+ data_length += strlen(cursor);
+
+ if (data_length < alloc_length - 1 || data[data_length - 1] == '\n') {
+ break;
+ }
+
+ alloc_length <<= 1;
+
+ data = realloc(data, alloc_length);
+
+ if (!line) {
+ break;
+ }
+ }
+
+ if (data[data_length - 1] == '\n') {
+ data[data_length - 1] = '\0';
+
+ data = realloc(data, data_length);
+ } else {
+ data = realloc(data, data_length + 1);
+
+ data[data_length] = '\0';
+ }
+
+ return data;
+}
From 5250e0cca3dd063d2a157db95dc5645fdd8c98be Mon Sep 17 00:00:00 2001
From: michal-dbrnowski
Date: Sun, 11 Oct 2020 16:29:44 +0200
Subject: [PATCH 043/129] Create prime_factors.py
---
prime_factors.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 prime_factors.py
diff --git a/prime_factors.py b/prime_factors.py
new file mode 100644
index 00000000..909c93e1
--- /dev/null
+++ b/prime_factors.py
@@ -0,0 +1,14 @@
+import math
+
+def factors(value):
+ factors = []
+ while value % 2 == 0:
+ factors.append(2)
+ value //= 2
+ for i in range(3, math.isqrt(value) + 1, 2):
+ while value % i == 0:
+ factors.append(i)
+ value //= i
+ if value > 2:
+ factors.append(value)
+ return factors
From e9856d7a1fd7739895cae98c01c51db20f546adb Mon Sep 17 00:00:00 2001
From: michal-dbrnowski
Date: Sun, 11 Oct 2020 16:34:06 +0200
Subject: [PATCH 044/129] Create perfect_numbers.py
---
perfect_numbers.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 perfect_numbers.py
diff --git a/perfect_numbers.py b/perfect_numbers.py
new file mode 100644
index 00000000..244159d6
--- /dev/null
+++ b/perfect_numbers.py
@@ -0,0 +1,13 @@
+def classify(number):
+ if number == 0: raise ValueError("Zero is not a natural number")
+ if number < 0: raise ValueError("Negative integer is not a natural number")
+ aliquots = []
+ for i in range(1, number):
+ if number % i == 0:
+ aliquots.append(i)
+ if sum(aliquots) == number:
+ return "perfect"
+ elif sum(aliquots) > number:
+ return "abundant"
+ elif sum(aliquots) < number:
+ return "deficient"
\ No newline at end of file
From 1f5a7058d0cc2e57d04739d8026bd75ed44a2494 Mon Sep 17 00:00:00 2001
From: anvitareddy6
Date: Sun, 11 Oct 2020 20:50:07 +0530
Subject: [PATCH 045/129] added mergesort.cpp
---
mergesort.cpp | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
create mode 100644 mergesort.cpp
diff --git a/mergesort.cpp b/mergesort.cpp
new file mode 100644
index 00000000..4404ed52
--- /dev/null
+++ b/mergesort.cpp
@@ -0,0 +1,108 @@
+#include
+using namespace std;
+
+// Merges two subarrays of arr[].
+// First subarray is arr[l..m]
+// Second subarray is arr[m+1..r]
+void merge(int arr[], int l, int m, int r)
+{
+ int n1 = m - l + 1;
+ int n2 = r - m;
+
+ // Create temp arrays
+ int L[n1], R[n2];
+
+ // Copy data to temp arrays L[] and R[]
+ for(int i = 0; i < n1; i++)
+ L[i] = arr[l + i];
+ for(int j = 0; j < n2; j++)
+ R[j] = arr[m + 1 + j];
+
+ // Merge the temp arrays back into arr[l..r]
+
+ // Initial index of first subarray
+ int i = 0;
+
+ // Initial index of second subarray
+ int j = 0;
+
+ // Initial index of merged subarray
+ int k = l;
+
+ while (i < n1 && j < n2)
+ {
+ if (L[i] <= R[j])
+ {
+ arr[k] = L[i];
+ i++;
+ }
+ else
+ {
+ arr[k] = R[j];
+ j++;
+ }
+ k++;
+ }
+
+ // Copy the remaining elements of
+ // L[], if there are any
+ while (i < n1)
+ {
+ arr[k] = L[i];
+ i++;
+ k++;
+ }
+
+ // Copy the remaining elements of
+ // R[], if there are any
+ while (j < n2)
+ {
+ arr[k] = R[j];
+ j++;
+ k++;
+ }
+}
+
+// l is for left index and r is
+// right index of the sub-array
+// of arr to be sorted */
+void mergeSort(int arr[], int l, int r)
+{
+ if (l < r)
+ {
+
+ // Same as (l+r)/2, but avoids
+ // overflow for large l and h
+ int m = l + (r - l) / 2;
+
+ // Sort first and second halves
+ mergeSort(arr, l, m);
+ mergeSort(arr, m + 1, r);
+
+ merge(arr, l, m, r);
+ }
+}
+
+// UTILITY FUNCTIONS
+// Function to print an array
+void printArray(int A[], int size)
+{
+ for(int i = 0; i < size; i++)
+ cout << A[i] << " ";
+}
+
+// Driver code
+int main()
+{
+ int arr[] = { 12, 11, 13, 5, 6, 7 };
+ int arr_size = sizeof(arr) / sizeof(arr[0]);
+
+ cout << "Given array is \n";
+ printArray(arr, arr_size);
+
+ mergeSort(arr, 0, arr_size - 1);
+
+ cout << "\nSorted array is \n";
+ printArray(arr, arr_size);
+ return 0;
+}
From 16a5036b794511e8f2ddd326e4dd15124c65caa6 Mon Sep 17 00:00:00 2001
From: Srinidh <56586240+srinidh-007@users.noreply.github.com>
Date: Sun, 11 Oct 2020 21:53:24 +0530
Subject: [PATCH 046/129] Create Hash.c
Implementing hash data structure
---
Hash.c | 366 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 366 insertions(+)
create mode 100644 Hash.c
diff --git a/Hash.c b/Hash.c
new file mode 100644
index 00000000..a75e620b
--- /dev/null
+++ b/Hash.c
@@ -0,0 +1,366 @@
+/*
+** Hash table implementation in c
+** @Author Srinidh Reddy
+*/
+
+#include
+#include
+#include
+
+#define CAPACITY 50000 // Size of the Hash Table
+
+unsigned long hash_function(char* str) {
+ unsigned long i = 0;
+ for (int j=0; str[j]; j++)
+ i += str[j];
+ return i % CAPACITY;
+}
+
+typedef struct Ht_item Ht_item;
+
+// Define the Hash Table Item here
+struct Ht_item {
+ char* key;
+ char* value;
+};
+
+
+typedef struct LinkedList LinkedList;
+
+// Define the Linkedlist here
+struct LinkedList {
+ Ht_item* item;
+ LinkedList* next;
+};
+
+
+typedef struct HashTable HashTable;
+
+// Define the Hash Table here
+struct HashTable {
+ // Contains an array of pointers
+ // to items
+ Ht_item** items;
+ LinkedList** overflow_buckets;
+ int size;
+ int count;
+};
+
+
+static LinkedList* allocate_list () {
+ // Allocates memory for a Linkedlist pointer
+ LinkedList* list = (LinkedList*) malloc (sizeof(LinkedList));
+ return list;
+}
+
+static LinkedList* linkedlist_insert(LinkedList* list, Ht_item* item) {
+ // Inserts the item onto the Linked List
+ if (!list) {
+ LinkedList* head = allocate_list();
+ head->item = item;
+ head->next = NULL;
+ list = head;
+ return list;
+ }
+
+ else if (list->next == NULL) {
+ LinkedList* node = allocate_list();
+ node->item = item;
+ node->next = NULL;
+ list->next = node;
+ return list;
+ }
+
+ LinkedList* temp = list;
+ while (temp->next->next) {
+ temp = temp->next;
+ }
+
+ LinkedList* node = allocate_list();
+ node->item = item;
+ node->next = NULL;
+ temp->next = node;
+
+ return list;
+}
+
+static Ht_item* linkedlist_remove(LinkedList* list) {
+ // Removes the head from the linked list
+ // and returns the item of the popped element
+ if (!list)
+ return NULL;
+ if (!list->next)
+ return NULL;
+ LinkedList* node = list->next;
+ LinkedList* temp = list;
+ temp->next = NULL;
+ list = node;
+ Ht_item* it = NULL;
+ memcpy(temp->item, it, sizeof(Ht_item));
+ free(temp->item->key);
+ free(temp->item->value);
+ free(temp->item);
+ free(temp);
+ return it;
+}
+
+static void free_linkedlist(LinkedList* list) {
+ LinkedList* temp = list;
+ while (list) {
+ temp = list;
+ list = list->next;
+ free(temp->item->key);
+ free(temp->item->value);
+ free(temp->item);
+ free(temp);
+ }
+}
+
+static LinkedList** create_overflow_buckets(HashTable* table) {
+ // Create the overflow buckets; an array of linkedlists
+ LinkedList** buckets = (LinkedList**) calloc (table->size, sizeof(LinkedList*));
+ for (int i=0; isize; i++)
+ buckets[i] = NULL;
+ return buckets;
+}
+
+static void free_overflow_buckets(HashTable* table) {
+ // Free all the overflow bucket lists
+ LinkedList** buckets = table->overflow_buckets;
+ for (int i=0; isize; i++)
+ free_linkedlist(buckets[i]);
+ free(buckets);
+}
+
+
+Ht_item* create_item(char* key, char* value) {
+ // Creates a pointer to a new hash table item
+ Ht_item* item = (Ht_item*) malloc (sizeof(Ht_item));
+ item->key = (char*) malloc (strlen(key) + 1);
+ item->value = (char*) malloc (strlen(value) + 1);
+
+ strcpy(item->key, key);
+ strcpy(item->value, value);
+
+ return item;
+}
+
+HashTable* create_table(int size) {
+ // Creates a new HashTable
+ HashTable* table = (HashTable*) malloc (sizeof(HashTable));
+ table->size = size;
+ table->count = 0;
+ table->items = (Ht_item**) calloc (table->size, sizeof(Ht_item*));
+ for (int i=0; isize; i++)
+ table->items[i] = NULL;
+ table->overflow_buckets = create_overflow_buckets(table);
+
+ return table;
+}
+
+void free_item(Ht_item* item) {
+ // Frees an item
+ free(item->key);
+ free(item->value);
+ free(item);
+}
+
+void free_table(HashTable* table) {
+ // Frees the table
+ for (int i=0; isize; i++) {
+ Ht_item* item = table->items[i];
+ if (item != NULL)
+ free_item(item);
+ }
+
+ free_overflow_buckets(table);
+ free(table->items);
+ free(table);
+}
+
+void handle_collision(HashTable* table, unsigned long index, Ht_item* item) {
+ LinkedList* head = table->overflow_buckets[index];
+
+ if (head == NULL) {
+ // We need to create the list
+ head = allocate_list();
+ head->item = item;
+ table->overflow_buckets[index] = head;
+ return;
+ }
+ else {
+ // Insert to the list
+ table->overflow_buckets[index] = linkedlist_insert(head, item);
+ return;
+ }
+ }
+
+void ht_insert(HashTable* table, char* key, char* value) {
+ // Create the item
+ Ht_item* item = create_item(key, value);
+
+ // Compute the index
+ unsigned long index = hash_function(key);
+
+ Ht_item* current_item = table->items[index];
+
+ if (current_item == NULL) {
+ // Key does not exist.
+ if (table->count == table->size) {
+ // Hash Table Full
+ printf("Insert Error: Hash Table is full\n");
+ // Remove the create item
+ free_item(item);
+ return;
+ }
+
+ // Insert directly
+ table->items[index] = item;
+ table->count++;
+ }
+
+ else {
+ // Scenario 1: We only need to update value
+ if (strcmp(current_item->key, key) == 0) {
+ strcpy(table->items[index]->value, value);
+ return;
+ }
+
+ else {
+ // Scenario 2: Collision
+ handle_collision(table, index, item);
+ return;
+ }
+ }
+}
+
+char* ht_search(HashTable* table, char* key) {
+ // Searches the key in the hashtable
+ // and returns NULL if it doesn't exist
+ int index = hash_function(key);
+ Ht_item* item = table->items[index];
+ LinkedList* head = table->overflow_buckets[index];
+
+ // Ensure that we move to items which are not NULL
+ while (item != NULL) {
+ if (strcmp(item->key, key) == 0)
+ return item->value;
+ if (head == NULL)
+ return NULL;
+ item = head->item;
+ head = head->next;
+ }
+ return NULL;
+}
+
+void ht_delete(HashTable* table, char* key) {
+ // Deletes an item from the table
+ int index = hash_function(key);
+ Ht_item* item = table->items[index];
+ LinkedList* head = table->overflow_buckets[index];
+
+ if (item == NULL) {
+ // Does not exist. Return
+ return;
+ }
+ else {
+ if (head == NULL && strcmp(item->key, key) == 0) {
+ // No collision chain. Remove the item
+ // and set table index to NULL
+ table->items[index] = NULL;
+ free_item(item);
+ table->count--;
+ return;
+ }
+ else if (head != NULL) {
+ // Collision Chain exists
+ if (strcmp(item->key, key) == 0) {
+ // Remove this item and set the head of the list
+ // as the new item
+
+ free_item(item);
+ LinkedList* node = head;
+ head = head->next;
+ node->next = NULL;
+ table->items[index] = create_item(node->item->key, node->item->value);
+ free_linkedlist(node);
+ table->overflow_buckets[index] = head;
+ return;
+ }
+
+ LinkedList* curr = head;
+ LinkedList* prev = NULL;
+
+ while (curr) {
+ if (strcmp(curr->item->key, key) == 0) {
+ if (prev == NULL) {
+ // First element of the chain. Remove the chain
+ free_linkedlist(head);
+ table->overflow_buckets[index] = NULL;
+ return;
+ }
+ else {
+ // This is somewhere in the chain
+ prev->next = curr->next;
+ curr->next = NULL;
+ free_linkedlist(curr);
+ table->overflow_buckets[index] = head;
+ return;
+ }
+ }
+ curr = curr->next;
+ prev = curr;
+ }
+
+ }
+ }
+}
+
+void print_search(HashTable* table, char* key) {
+ char* val;
+ if ((val = ht_search(table, key)) == NULL) {
+ printf("%s does not exist\n", key);
+ return;
+ }
+ else {
+ printf("Key:%s, Value:%s\n", key, val);
+ }
+}
+
+void print_table(HashTable* table) {
+ printf("\n-------------------\n");
+ for (int i=0; isize; i++) {
+ if (table->items[i]) {
+ printf("Index:%d, Key:%s, Value:%s", i, table->items[i]->key, table->items[i]->value);
+ if (table->overflow_buckets[i]) {
+ printf(" => Overflow Bucket => ");
+ LinkedList* head = table->overflow_buckets[i];
+ while (head) {
+ printf("Key:%s, Value:%s ", head->item->key, head->item->value);
+ head = head->next;
+ }
+ }
+ printf("\n");
+ }
+ }
+ printf("-------------------\n");
+}
+
+int main() {
+ HashTable* ht = create_table(CAPACITY);
+ ht_insert(ht, "1", "First address");
+ ht_insert(ht, "2", "Second address");
+ ht_insert(ht, "Hel", "Third address");
+ ht_insert(ht, "Cau", "Fourth address");
+ print_search(ht, "1");
+ print_search(ht, "2");
+ print_search(ht, "3");
+ print_search(ht, "Hel");
+ print_search(ht, "Cau"); // Collision!
+ print_table(ht);
+ ht_delete(ht, "1");
+ ht_delete(ht, "Cau");
+ print_table(ht);
+ free_table(ht);
+ return 0;
+}
From 2da4e5c5b9710f80c47bdcfe2c56b151f1bd9f0a Mon Sep 17 00:00:00 2001
From: Sunitha654321 <71882432+Sunitha654321@users.noreply.github.com>
Date: Sun, 11 Oct 2020 22:14:10 +0530
Subject: [PATCH 047/129] Create factorial_java
---
factorial_java | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 factorial_java
diff --git a/factorial_java b/factorial_java
new file mode 100644
index 00000000..722f654c
--- /dev/null
+++ b/factorial_java
@@ -0,0 +1,14 @@
+class FactorialExample2{
+ static int factorial(int n){
+ if (n == 0)
+ return 1;
+ else
+ return(n * factorial(n-1));
+ }
+ public static void main(String args[]){
+ int i,fact=1;
+ int number=4;//It is the number to calculate factorial
+ fact = factorial(number);
+ System.out.println("Factorial of "+number+" is: "+fact);
+ }
+}
From 07e818cc08905c9f7ebd241b9d584aa2bd618939 Mon Sep 17 00:00:00 2001
From: Srinidh <56586240+srinidh-007@users.noreply.github.com>
Date: Sun, 11 Oct 2020 22:30:07 +0530
Subject: [PATCH 048/129] Create Print_Pascal_Triangle_of_size_n.py
For a given user input say n, it prints pascal triangle of n rows
---
Print_Pascal_Triangle_of_size_n.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 Print_Pascal_Triangle_of_size_n.py
diff --git a/Print_Pascal_Triangle_of_size_n.py b/Print_Pascal_Triangle_of_size_n.py
new file mode 100644
index 00000000..d72db198
--- /dev/null
+++ b/Print_Pascal_Triangle_of_size_n.py
@@ -0,0 +1,14 @@
+n=int(input("Enter number of rows: "))
+a=[]
+for i in range(n):
+ a.append([])
+ a[i].append(1)
+ for j in range(1,i):
+ a[i].append(a[i-1][j-1]+a[i-1][j])
+ if(n!=0):
+ a[i].append(1)
+for i in range(n):
+ print(" "*(n-i),end=" ",sep=" ")
+ for j in range(0,i+1):
+ print('{0:6}'.format(a[i][j]),end=" ",sep=" ")
+ print()
From 2ef02760ae611bb057dc559e2ead642e6c68317b Mon Sep 17 00:00:00 2001
From: Aastha Gupta <45624905+Aastha479@users.noreply.github.com>
Date: Sun, 11 Oct 2020 22:52:16 +0530
Subject: [PATCH 049/129] myPage.html
A simple HTML page with basic structure and layout, easy to understand.
---
myPage.html | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 myPage.html
diff --git a/myPage.html b/myPage.html
new file mode 100644
index 00000000..43e711eb
--- /dev/null
+++ b/myPage.html
@@ -0,0 +1,56 @@
+
+
+
+
+
+My Page
+Hello World!
+Success in Life
+
+
+
+
How to be a successful person:
+
+ - Strongly willing to learn
+ - Sustain Failure
+ - Strong Determination
+
+
+
Necessities for success:
+
+ - Good Idea
+ - Plan to work upon
+ - Smart work
+
+
+
+
+
+
From 2e2f17e03f34200001b4c8356e64ba7ed1161070 Mon Sep 17 00:00:00 2001
From: Srinidh <56586240+srinidh-007@users.noreply.github.com>
Date: Sun, 11 Oct 2020 22:55:08 +0530
Subject: [PATCH 050/129] Create Calculator.py
Simple calculator in python with modulo operator
---
Calculator.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 Calculator.py
diff --git a/Calculator.py b/Calculator.py
new file mode 100644
index 00000000..1b629da6
--- /dev/null
+++ b/Calculator.py
@@ -0,0 +1,50 @@
+# Simple Calculator in python
+# @Author Srinidh Reddy
+
+class cal():
+ def __init__(self,a,b):
+ self.a = a
+ self.b = b
+ def add(self):
+ return self.a + self.b
+ def mul(self):
+ return self.a * self.b
+ def div(self):
+ return self.a / self.b
+ def sub(self):
+ return self.a - self.b
+ def mod(self):
+ # Modulo operator works like a % b returns remainder when a is divided by b
+ # example 7 % 3 == 1
+ return self.a % self.b
+
+a=int(input("Enter first number: "))
+b=int(input("Enter second number: "))
+obj=cal(a,b)
+choice=1
+
+while choice != 0:
+ print("0. Exit")
+ print("1. Add")
+ print("2. Subtraction")
+ print("3. Multiplication")
+ print("4. Division")
+ print("5. Modulo")
+ choice=int(input("Enter choice: "))
+ if choice == 1:
+ print("Result: ",obj.add())
+ elif choice == 2:
+ print("Result: ",obj.sub())
+ elif choice == 3:
+ print("Result: ",obj.mul())
+ elif choice == 4:
+ print("Result: ",round(obj.div(),2))
+ elif choice == 5:
+ print("Result: ",obj.mod())
+ elif choice == 0:
+ print("Exiting the calculator")
+ else:
+ print("Invalid choice!!")
+
+
+print()
From b23492399ad655491363ac6e2819a7b4b4c165fe Mon Sep 17 00:00:00 2001
From: Srinidh <56586240+srinidh-007@users.noreply.github.com>
Date: Sun, 11 Oct 2020 23:04:13 +0530
Subject: [PATCH 051/129] Create Radix_sort.c
This is implementation of Radix sort for variable base
---
Radix_sort.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
create mode 100644 Radix_sort.c
diff --git a/Radix_sort.c b/Radix_sort.c
new file mode 100644
index 00000000..084540f0
--- /dev/null
+++ b/Radix_sort.c
@@ -0,0 +1,92 @@
+/*
+This is implementation of Radix sort for variable base
+@Author Srinidh Reddy
+*/
+
+#include
+#include
+
+//Function to find max element in array
+int find_max(int a[] , int n)
+{
+ int max = a[0];
+ for (int i = 1; i < n; i++)
+ {
+ if(a[i] > max)
+ {
+ max = a[i];
+ }
+ }
+ return max;
+}
+
+//Function for countsort
+// The digit is represented by dgt.
+void countsort(int a[],int n,int dgt,int base){
+
+ int i;
+ int arr_bucket[base];
+ int temp[n];
+ for(i=0;i=0;i--)
+ {
+ temp[arr_bucket[(a[i]/dgt)%base]-1] = a[i];
+ arr_bucket[(a[i]/dgt)%base]--;
+ }
+
+ for(i=0;i 0 ; dgt = dgt * base)
+ {
+ countsort(a, n , dgt, base);
+ }
+}
+
+int main()
+{
+ int x, n, base;
+ printf("Enter the number of elements for Sorting: ");
+ scanf("%d",&n);
+ int a[n];
+ printf("Enter the elements for Sorting: ");
+ for(x = 0; x < n; x++)
+ {
+ scanf("%d",&a[x]);
+ }
+ printf("Enter the base that has to be used for Sorting: ");
+ scanf("%d",&base);
+ radixsort(a , n ,base);
+ printf("The Sorted elements are: ");
+ for (int i = 0; i < n; i++)
+ {
+ printf("%d ", a[i]);
+ }
+
+ return 0;
+}
+
From 99905546f6eeb67ca4442b3976882f1ff8fa5e41 Mon Sep 17 00:00:00 2001
From: Ishan-1101 <67185870+Ishan-1101@users.noreply.github.com>
Date: Sun, 11 Oct 2020 23:49:26 +0530
Subject: [PATCH 052/129] Create queue operations.c
---
queue operations.c | 104 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 104 insertions(+)
create mode 100644 queue operations.c
diff --git a/queue operations.c b/queue operations.c
new file mode 100644
index 00000000..a8f62f2f
--- /dev/null
+++ b/queue operations.c
@@ -0,0 +1,104 @@
+ #include
+ #include
+ struct node
+ {
+ int data;
+ struct node *next;
+ };
+ struct node *front;
+ struct node *rear;
+ void insert();
+ void delete();
+ void display();
+ void main ()
+ {
+ int choice;
+ while(choice != 4)
+ {
+ printf("\n*************************Main Menu*****************************\n");
+ printf("\n=================================================================\n");
+ printf("\n1.insert an element\n2.Delete an element\n3.Display the queue\n4.Exit\n");
+ printf("\nEnter your choice ?");
+ scanf("%d",& choice);
+ switch(choice)
+ {
+ case 1:
+ insert();
+ break;
+ case 2:
+ delete();
+ break;
+ case 3:
+ display();
+ break;
+ case 4:
+ exit(0);
+ break;
+ default:
+ printf("\nEnter valid choice??\n");
+ }
+ }
+ }
+ void insert()
+ {
+ struct node *ptr;
+ int item;
+
+ ptr = (struct node *) malloc (sizeof(struct node));
+ if(ptr == NULL)
+ {
+ printf("\nOVERFLOW\n");
+ return;
+ }
+ else
+ {
+ printf("\nEnter value?\n");
+ scanf("%d",&item);
+ ptr -> data = item;
+ if(front == NULL)
+ {
+ front = ptr;
+ rear = ptr;
+ front -> next = NULL;
+ rear -> next = NULL;
+ }
+ else
+ {
+ rear -> next = ptr;
+ rear = ptr;
+ rear->next = NULL;
+ }
+ }
+ }
+ void delete ()
+ {
+ struct node *ptr;
+ if(front == NULL)
+ {
+ printf("\nUNDERFLOW\n");
+ return;
+ }
+ else
+ {
+ ptr = front;
+ front = front -> next;
+ free(ptr);
+ }
+ }
+ void display()
+ {
+ struct node *ptr;
+ ptr = front;
+ if(front == NULL)
+ {
+ printf("\nEmpty queue\n");
+ }
+ else
+ { printf("\nprinting values .....\n");
+ while(ptr != NULL)
+ {
+ printf("\n%d\n",ptr -> data);
+ ptr = ptr -> next;
+ }
+ }
+ }
From 1658b0fa98c0c70401c18abe9b38f09c0c815a3a Mon Sep 17 00:00:00 2001
From: praddyumnwadekar <55682027+praddyumnwadekar@users.noreply.github.com>
Date: Sun, 11 Oct 2020 23:52:30 +0530
Subject: [PATCH 053/129] Create ReverseAnInteger.c
---
ReverseAnInteger.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100644 ReverseAnInteger.c
diff --git a/ReverseAnInteger.c b/ReverseAnInteger.c
new file mode 100644
index 00000000..2555af0a
--- /dev/null
+++ b/ReverseAnInteger.c
@@ -0,0 +1,13 @@
+#include
+int main() {
+ int n, rev = 0, remainder;
+ printf("Enter an integer: ");
+ scanf("%d", &n);
+ while (n != 0) {
+ remainder = n % 10;
+ rev = rev * 10 + remainder;
+ n /= 10;
+ }
+ printf("Reversed number = %d", rev);
+ return 0;
+}
From 6ce33c776d4304e28889324f92f94705352ca3c2 Mon Sep 17 00:00:00 2001
From: umang <25umangagarwal@gmail.com>
Date: Mon, 12 Oct 2020 00:59:41 +0530
Subject: [PATCH 054/129] Added sorting algorithm
---
Bucketsort.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
quickSort.py | 38 ++++++++++++++++++++++++++++++++++++++
radixsort.py | 33 +++++++++++++++++++++++++++++++++
selectionsort.py | 20 ++++++++++++++++++++
4 files changed, 135 insertions(+)
create mode 100644 Bucketsort.py
create mode 100644 quickSort.py
create mode 100644 radixsort.py
create mode 100644 selectionsort.py
diff --git a/Bucketsort.py b/Bucketsort.py
new file mode 100644
index 00000000..c6b23a51
--- /dev/null
+++ b/Bucketsort.py
@@ -0,0 +1,44 @@
+"""
+This technique sorts the elements by first dividing the elements into several groups called buckets.
+The elements inside each bucket are sorted using any of the suitable sorting algorithms here we used- insertion sort
+ then all buckets are merged to give the sorted array
+
+"""
+def insertionSort(a):
+ for i in range(1,len(a)):
+ j=i-1
+ while(j>=0):
+ if a[j] > a[i]:
+ temp=a[j]
+ a[j]=a[i]
+ a[i]=temp
+ j-=1
+ i-=1
+def bucketsort(arr):
+ bucket_list=[]
+ slot=10
+ # creating empty buckets
+ for i in range(10):
+ bucket_list.append([])
+ sorted_bucket=[]
+ for element in arr:
+ # checking for float type elements
+ if float(element)>=0.0 and float(element)<=1.0:
+ index=int(slot*float(element))
+ bucket_list[index].append(float(element))
+ # checking for int tytpe elements.
+ else:
+ index=int(int(element)/10)
+ bucket_list[index].append(int(element))
+
+ for bucket in bucket_list:
+ insertionSort(bucket)
+ for i in bucket:
+ sorted_bucket.append(i)
+ print(sorted_bucket)
+
+
+
+#main
+bucket = [23,12,89,34,67,90,5,77]
+bucketsort(bucket)
\ No newline at end of file
diff --git a/quickSort.py b/quickSort.py
new file mode 100644
index 00000000..f2d638cb
--- /dev/null
+++ b/quickSort.py
@@ -0,0 +1,38 @@
+"""
+Quick sort using last element as pivot index.
+
+Initial array: [23, 45, 12, 78, 90, 1]
+-------------- [1, 45, 12, 78, 90, 23]
+-------------- [1, 12, 23, 78, 90, 45]
+-------------- [1, 12, 23, 45, 90, 78]
+-------------- [1, 12, 23, 45, 78, 90]
+Sorted array : [1, 12, 23, 45, 78, 90]
+
+"""
+def find_pviot_index(A,start,end):
+ pivot=A[end]
+ p_index=start
+ for iter in range(start,end):
+ if A[iter] <= pivot:
+ A[p_index],A[iter]=A[iter],A[p_index]
+ p_index+=1
+ A[p_index],A[end]=pivot,A[p_index]
+ return p_index
+
+def quick_sort(A,start,end):
+ if start < end:
+ pivot_index=find_pviot_index(A,start,end)
+ print("--------------",A)
+ quick_sort(A,start,pivot_index-1)
+ quick_sort(A,pivot_index+1,end)
+
+
+#main
+A=list()
+n=int(input("Enter how many numbers you want ot enter: "))
+for x in range(0,n):
+ num=int(input("enter num:"))
+ A.append(num)
+print("Initial array:",A)
+quick_sort(A,0,n-1)
+print("Sorted array :",A)
\ No newline at end of file
diff --git a/radixsort.py b/radixsort.py
new file mode 100644
index 00000000..41240a11
--- /dev/null
+++ b/radixsort.py
@@ -0,0 +1,33 @@
+def insertion(a,n,m):
+ for i in range(1,len(a)):
+ j=i-1
+ while(j>=0):
+ if ((a[j]%n)/m )>((a[i]%n)/m):
+ temp=a[j]
+ a[j]=a[i]
+ a[i]=temp
+ j-=1
+ i-=1
+
+def radix_sort(a,length):
+ n=10
+ m=1
+ for i in range(0,length):
+ insertion(a,n,m)
+ n=n*10
+ m=m*10
+ print(a)
+
+# main
+# Taking the list of numbers and user
+li=list()
+length_ofDigit=0
+n=int(input("Enter how many numbers you want ot enter: "))
+for x in range(0,n):
+ num=int(input("enter num:"))
+ li.append(num)
+ # Taking the len of longest digit (No of steps taken by this sort is equal to length of longest number)
+ if length_ofDigit a[j]:
+ minindex = j
+ a[i], a[minindex] = a[minindex], a[i]
+
+ # This will show the sorted array at each step
+ print("Sorted array at step", i + 1, a)
+
+print("------------------------")
+print("Final sorted array is:", a)
From 9ec879b37b188b75c94d44281afe66a65eed3a38 Mon Sep 17 00:00:00 2001
From: Muhammad Sameer Farooq
Date: Mon, 12 Oct 2020 01:28:02 +0500
Subject: [PATCH 055/129] Added Merge Sort
---
Merge Sort.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 Merge Sort.c
diff --git a/Merge Sort.c b/Merge Sort.c
new file mode 100644
index 00000000..8be18bdd
--- /dev/null
+++ b/Merge Sort.c
@@ -0,0 +1,60 @@
+#include
+
+void merge(int Array[],int iterator1,int j1,int iterator2,int j2)
+{
+ int TemporaryArray[50]; //array used for merging
+ int i,j,k;
+ i=iterator1; //beginning of the first list
+ j=iterator2; //beginning of the second list
+ k=0;
+
+ while(i<=j1 && j<=j2) //while elements in both lists
+ {
+ if(Array[i]
Date: Mon, 12 Oct 2020 09:29:57 +0530
Subject: [PATCH 056/129] Create Vowel or Consonant using pointers
---
Vowel or Consonant using pointers | 33 +++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 Vowel or Consonant using pointers
diff --git a/Vowel or Consonant using pointers b/Vowel or Consonant using pointers
new file mode 100644
index 00000000..6c023391
--- /dev/null
+++ b/Vowel or Consonant using pointers
@@ -0,0 +1,33 @@
+#include
+int main(void)
+{
+ char alpha;
+ char *pa=α
+ printf("Enter any alphabet:");
+ scanf("%c",pa);
+ {
+ if(*pa=='a')
+ printf("The alphabet is a vowel");
+ else if(*pa=='A')
+ printf("The alphabet is a vowel");
+ else if(*pa=='e')
+ printf("The alphabet is a vowel");
+ else if (*pa=='E')
+ printf("The alphabet is a vowel");
+ else if(*pa=='i')
+ printf("The alphabet is a vowel");
+ else if(*pa=='I')
+ printf("The alphabet is a vowel");
+ else if (*pa=='O')
+ printf("The alphabet is a vowel");
+ else if(*pa=='o')
+ printf("The alphabet is a vowel");
+ else if(*pa=='u')
+ printf("The alphabet is a vowel");
+ else if (*pa=='U')
+ printf("The alphabet is a vowel");
+ else
+ printf("The alphabet is a consonant");
+ }
+ return 0;
+}
From 072eac2a738417a013eedc5e3858f4f066a893f1 Mon Sep 17 00:00:00 2001
From: Gautam Jain <59042887+gautamjain9615@users.noreply.github.com>
Date: Mon, 12 Oct 2020 09:34:47 +0530
Subject: [PATCH 057/129] Create Bubble Sort using python
---
Bubble Sort using python | 15 +++++++++++++++
1 file changed, 15 insertions(+)
create mode 100644 Bubble Sort using python
diff --git a/Bubble Sort using python b/Bubble Sort using python
new file mode 100644
index 00000000..179130a4
--- /dev/null
+++ b/Bubble Sort using python
@@ -0,0 +1,15 @@
+def bubbleSort(arr):
+ for passnum in range(len(arr)-1,0,-1):
+ for i in range(passnum):
+ if arr[i]>arr[i+1]:
+ temp = arr[i]
+ arr[i] = arr[i+1]
+ arr[i+1] = temp
+
+n=int(input("Give range of list of numbers"))
+arr=[]
+for i in range(n):
+ arr.append(input("input a number"))
+
+bubbleSort(arr)
+print(arr)
From 1ee7dab6bf2859992e4ada06d063c00b4459b55f Mon Sep 17 00:00:00 2001
From: Gautam Jain <59042887+gautamjain9615@users.noreply.github.com>
Date: Mon, 12 Oct 2020 09:52:45 +0530
Subject: [PATCH 058/129] Rename Bubble Sort using python to
Bubble_Sort_using_python.py
---
Bubble Sort using python => Bubble_Sort_using_python.py | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Bubble Sort using python => Bubble_Sort_using_python.py (100%)
diff --git a/Bubble Sort using python b/Bubble_Sort_using_python.py
similarity index 100%
rename from Bubble Sort using python
rename to Bubble_Sort_using_python.py
From c51f432b96893ae910ca29fbc3bff483d6213308 Mon Sep 17 00:00:00 2001
From: Muhammad Tabish Khanday
Date: Mon, 12 Oct 2020 10:18:06 +0530
Subject: [PATCH 059/129] added towerofhanoi cpp program
---
towerofHanoi.cpp | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 towerofHanoi.cpp
diff --git a/towerofHanoi.cpp b/towerofHanoi.cpp
new file mode 100644
index 00000000..fc12ed57
--- /dev/null
+++ b/towerofHanoi.cpp
@@ -0,0 +1,23 @@
+#include
+using namespace std;
+
+void towerOfHanoi(int n, char source, char auxiliary, char destination) {
+ if (n == 0) {
+ return;
+ }
+
+ towerOfHanoi(n - 1, source, destination, auxiliary);
+
+ cout << source << " " << destination << endl;
+
+ towerOfHanoi(n - 1, auxiliary, source, destination);
+}
+
+int main() {
+
+ freopen("input.txt", "r", stdin);
+ freopen("output.txt", "w", stdout);
+
+
+ return 0;
+}
\ No newline at end of file
From df439e93b0f524e2a2a5f3da8b93a518694454ac Mon Sep 17 00:00:00 2001
From: Dev_Sumit <58663629+Mathur777@users.noreply.github.com>
Date: Mon, 12 Oct 2020 11:09:57 +0530
Subject: [PATCH 060/129] Factors of number
program to find factors of number
---
Factors.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 Factors.c
diff --git a/Factors.c b/Factors.c
new file mode 100644
index 00000000..54a1be32
--- /dev/null
+++ b/Factors.c
@@ -0,0 +1,19 @@
+#include
+
+int main()
+{
+ printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
+ int num, i;
+ printf("Enter the number to find the factors of : ");
+ scanf("%d",&num);
+ printf("\n\n\nFactors of %d are \n\n", num);
+
+ for(i = 1; i <= num/2; i++)
+ {
+ if(num%i == 0)
+ printf("\t\t\t%d\n", i);
+ }
+
+ printf("\n\n\n\n\t\t\tCoding is Fun !\n\n\n");
+ return 0;
+}
From 6586039d2b3fa6064a53612383360f79e38bc13a Mon Sep 17 00:00:00 2001
From: Jakob Waibel <59575534+JakWai01@users.noreply.github.com>
Date: Mon, 12 Oct 2020 10:07:49 +0200
Subject: [PATCH 061/129] Create binary-search.cpp
---
binary-search.cpp | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
create mode 100644 binary-search.cpp
diff --git a/binary-search.cpp b/binary-search.cpp
new file mode 100644
index 00000000..f64a05af
--- /dev/null
+++ b/binary-search.cpp
@@ -0,0 +1,28 @@
+#include
+#include
+
+using namespace std;
+
+int main()
+{
+ static int array[]{4,12,56,754,1235,435,64,1,2,3,4};
+ int size = sizeof(array)/sizeof(array[0]);
+ sort(array, array + size);
+ int x = 3;
+ int a = 0;
+ int b = size-1;
+
+ while (a <= b) {
+ int k = (a+b)/2;
+ if (array[k] == x) {
+ cout << "Found at index: " << k;
+ }
+ if (array[k] > x) {
+ b = k-1;
+ } else {
+ a = k+1;
+ }
+ }
+
+
+}
From 8e822a4cee6007f59953a86fcf191bedc5b554a4 Mon Sep 17 00:00:00 2001
From: Jakob Waibel <59575534+JakWai01@users.noreply.github.com>
Date: Mon, 12 Oct 2020 10:11:37 +0200
Subject: [PATCH 062/129] Create basic-search.cpp
---
basic-search.cpp | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 basic-search.cpp
diff --git a/basic-search.cpp b/basic-search.cpp
new file mode 100644
index 00000000..fb0de6ee
--- /dev/null
+++ b/basic-search.cpp
@@ -0,0 +1,20 @@
+#include
+#include
+
+using namespace std;
+
+int main()
+{
+ static int array[]{4,12,56,754,1235,435,64,1,2,3,4};
+ int size = sizeof(array)/sizeof(array[0]);
+ sort(array, array + size);
+ int x = 3;
+
+ for(int i = 0; i < size; i++) {
+ if (array[i] == x) {
+ cout << "Fount at index: " << i;
+ }
+ }
+
+
+}
From ff3a59cdddccb77821670d3a70b2a3c96f5dd348 Mon Sep 17 00:00:00 2001
From: Muhammad Tabish Khanday <61789893+mtabishk@users.noreply.github.com>
Date: Mon, 12 Oct 2020 13:43:47 +0530
Subject: [PATCH 063/129] fixed that bug
Added the remaining portion of the program
---
towerofHanoi.cpp | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/towerofHanoi.cpp b/towerofHanoi.cpp
index fc12ed57..61ba437c 100644
--- a/towerofHanoi.cpp
+++ b/towerofHanoi.cpp
@@ -13,11 +13,9 @@ void towerOfHanoi(int n, char source, char auxiliary, char destination) {
towerOfHanoi(n - 1, auxiliary, source, destination);
}
-int main() {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
-
-
- return 0;
-}
\ No newline at end of file
+int main() {
+ int n = 4; // Number of disks
+ towerOfHanoi(n, 'A', 'C', 'B'); // A, B and C are names of rods
+ return 0;
+}
From cc410d7d78d2e421cad3bd9c5b32c550e4f78f6a Mon Sep 17 00:00:00 2001
From: Mehul Minat <72225679+mehulminat@users.noreply.github.com>
Date: Mon, 12 Oct 2020 13:56:05 +0530
Subject: [PATCH 064/129] Create Factorial.c
Calculate factorial using for loop
---
Factorial.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 Factorial.c
diff --git a/Factorial.c b/Factorial.c
new file mode 100644
index 00000000..77466014
--- /dev/null
+++ b/Factorial.c
@@ -0,0 +1,17 @@
+#include
+using namespace std;
+int main()
+{
+ int i,fac=1,num;
+ cout<<"Enter number of which u want to calculate factorial";
+ cin>>num;
+
+ for(i=1;i<=num;i++)
+ {
+ fac=fac*i;
+ }
+
+ cout<<"factorial of " <
Date: Mon, 12 Oct 2020 14:42:56 +0530
Subject: [PATCH 065/129] Create Emi calculator.java
---
Emi calculator.java | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 Emi calculator.java
diff --git a/Emi calculator.java b/Emi calculator.java
new file mode 100644
index 00000000..8e8224d5
--- /dev/null
+++ b/Emi calculator.java
@@ -0,0 +1,35 @@
+//program to calculate emi in java
+import java.util.*;
+import java.util.Scanner;
+class Emi
+{
+ public static void main(String []args)
+ {
+ Scanner a = new Scanner(System.in);
+
+ double principal, rate, time, emi;
+
+ System.out.print("Enter principal: ");
+ principal = a.nextFloat();
+
+ System.out.print("Enter rate: ");
+ rate = a.nextFloat();
+
+ System.out.print("Enter time in year: ");
+ time = a.nextFloat();
+
+ rate=rate/(12*100);
+ time=time*12;
+
+
+ emi= emiCalculation(principal,rate,time);
+
+ System.out.print("Monthly EMI is= "+emi+"\n");
+
+ }
+ static double emiCalculation(double p,double r,double t)
+ {
+ double e= (p*r*Math.pow(1+r,t))/(Math.pow(1+r,t)-1);
+ return e;
+ }
+}
From 50e4e26bde65a87308ef72d7b8f75c3dc95bc1e3 Mon Sep 17 00:00:00 2001
From: Mehul Minat <72225679+mehulminat@users.noreply.github.com>
Date: Mon, 12 Oct 2020 14:54:45 +0530
Subject: [PATCH 066/129] Create calculatorv1.c
---
calculatorv1.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 calculatorv1.c
diff --git a/calculatorv1.c b/calculatorv1.c
new file mode 100644
index 00000000..085456e6
--- /dev/null
+++ b/calculatorv1.c
@@ -0,0 +1,40 @@
+# include
+using namespace std;
+
+int main()
+{
+ char op;
+ float num1, num2;
+
+ cout << "Enter operator either + or - or * or /: ";
+ cin >> op;
+
+ cout << "Enter two operands: ";
+ cin >> num1 >> num2;
+
+ switch(op)
+ {
+ case '+':
+ cout << num1+num2;
+ break;
+
+ case '-':
+ cout << num1-num2;
+ break;
+
+ case '*':
+ cout << num1*num2;
+ break;
+
+ case '/':
+ cout << num1/num2;
+ break;
+
+ default:
+ // If the operator is other than +, -, * or /, error message is shown
+ cout << "Error! operator is not correct";
+ break;
+ }
+
+ return 0;
+}
From e8db74637ece6a8ed7b54ad0f646317b1c69d2ef Mon Sep 17 00:00:00 2001
From: Rupali409 <54534133+Rupali409@users.noreply.github.com>
Date: Mon, 12 Oct 2020 15:18:23 +0530
Subject: [PATCH 067/129] Create Count_sort.py
i had created count sort by python with additional features.
Please check.
---
Created count_Sort.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 Created count_Sort.py
diff --git a/Created count_Sort.py b/Created count_Sort.py
new file mode 100644
index 00000000..7ba68d36
--- /dev/null
+++ b/Created count_Sort.py
@@ -0,0 +1,19 @@
+print("counting Sort")
+print("Range of input")
+n=int(input())
+l=[]
+print("Total elements:")
+t=int(input())
+print("input elements:")
+
+for j in range(0,t):
+ p=int(input())
+ if p>n:
+ print("out of bounds")
+ else:
+ l.append(p)
+print("Unsorted list is:")
+print(l)
+print("Sorted list is:")
+l.sort()
+print(l)
From 1551d142c3ac97b19e33323889f25b75b9d49be5 Mon Sep 17 00:00:00 2001
From: Himanshup01 <72742364+Himanshup01@users.noreply.github.com>
Date: Mon, 12 Oct 2020 17:27:50 +0530
Subject: [PATCH 068/129] Create bubblesort.c
---
bubblesort.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 bubblesort.c
diff --git a/bubblesort.c b/bubblesort.c
new file mode 100644
index 00000000..2e046460
--- /dev/null
+++ b/bubblesort.c
@@ -0,0 +1,24 @@
+#include
+int main()
+{
+ int n, temp, i, j;
+ printf ("Enter No of elements in the array \n");
+ scanf("%d",&n);
+ int number[n];
+ printf ("Enter the elements of array \n");
+ for(int i=0;i=0;i--){
+ for(j=0;j<=i;j++){
+ if(number[j]>number[j+1]){
+ temp=number[j];
+ number[j]=number[j+1];
+ number[j+1]=temp;
+ }
+ }
+ }
+ printf("Sorted elements: ");
+ for(i=0;i
Date: Mon, 12 Oct 2020 17:28:03 +0530
Subject: [PATCH 069/129] Create Josephus_Problem_Circular_LL.c
---
Josephus_Problem_Circular_LL.c | 54 ++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
create mode 100644 Josephus_Problem_Circular_LL.c
diff --git a/Josephus_Problem_Circular_LL.c b/Josephus_Problem_Circular_LL.c
new file mode 100644
index 00000000..da7e2937
--- /dev/null
+++ b/Josephus_Problem_Circular_LL.c
@@ -0,0 +1,54 @@
+#include
+#include
+
+typedef struct node{
+ int data;
+ struct node *next;
+} node;
+node *head=NULL, *p, *temp,*temp2;
+int main()
+{
+ int size, start, step,i;
+ printf("Enter the size of Circular Linked List");
+ scanf("%d", &size);
+ for(i=0;idata=i+1;
+ if(head==NULL){
+ head=p;
+ temp=head;
+ head->next= NULL;
+ }
+ else{
+ temp->next=p;
+ p->next=NULL;
+ temp=p;
+ }
+ if(i==size-1){p->next=head;}
+ }
+ temp=head;
+ printf("Your line-up of men is this: \n");
+ while(temp->next!=head){printf("%d ", temp->data); temp=temp->next;}
+ printf("%d\n", temp->data);
+ printf("Enter the starting position: ");
+ scanf("%d", &start);
+ printf("Enter the step size: ");
+ scanf("%d", &step);
+ temp=head;
+ while(temp->data!=start){
+ temp=temp->next;
+ }
+ while(temp->next!=temp){
+ for(i=0;inext;
+ temp2=temp->next;
+ }
+ temp->next=temp2->next;
+ temp2->next=NULL;
+ free(temp2);
+ }
+ printf("\n");
+ printf("%d survives! \n", temp->data);
+}
+
+
From 221b8f55427dc18e637a32198e91b65b06b89e91 Mon Sep 17 00:00:00 2001
From: snehasish-20 <63896969+snehasish-20@users.noreply.github.com>
Date: Mon, 12 Oct 2020 18:06:02 +0530
Subject: [PATCH 070/129] Create reverseLinkedList.c
---
reverseLinkedList.c | 67 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
create mode 100644 reverseLinkedList.c
diff --git a/reverseLinkedList.c b/reverseLinkedList.c
new file mode 100644
index 00000000..2b202e77
--- /dev/null
+++ b/reverseLinkedList.c
@@ -0,0 +1,67 @@
+// Iterative C program to reverse a linked list
+#include
+#include
+
+/* Link list node */
+struct Node {
+ int data;
+ struct Node* next;
+};
+
+/* Function to reverse the linked list */
+static void reverse(struct Node** head_ref)
+{
+ struct Node* prev = NULL;
+ struct Node* current = *head_ref;
+ struct Node* next = NULL;
+ while (current != NULL) {
+ // Store next
+ next = current->next;
+
+ // Reverse current node's pointer
+ current->next = prev;
+
+ // Move pointers one position ahead.
+ prev = current;
+ current = next;
+ }
+ *head_ref = prev;
+}
+
+/* Function to push a node */
+void push(struct Node** head_ref, int new_data)
+{
+ struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));
+ new_node->data = new_data;
+ new_node->next = (*head_ref);
+ (*head_ref) = new_node;
+}
+
+/* Function to print linked list */
+void printList(struct Node* head)
+{
+ struct Node* temp = head;
+ while (temp != NULL) {
+ printf("%d ", temp->data);
+ temp = temp->next;
+ }
+}
+
+/* Driver program to test above function*/
+int main()
+{
+ /* Start with the empty list */
+ struct Node* head = NULL;
+
+ push(&head, 20);
+ push(&head, 4);
+ push(&head, 15);
+ push(&head, 85);
+
+ printf("Given linked list\n");
+ printList(head);
+ reverse(&head);
+ printf("\nReversed Linked list \n");
+ printList(head);
+ getchar();
+}
From b6df09c8116100f00a322202a9b74967af603474 Mon Sep 17 00:00:00 2001
From: aniketbhaleraogithub
<44803603+aniketbhaleraogithub@users.noreply.github.com>
Date: Mon, 12 Oct 2020 18:11:07 +0530
Subject: [PATCH 071/129] Palindrome number check
---
palindrome.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 palindrome.c
diff --git a/palindrome.c b/palindrome.c
new file mode 100644
index 00000000..253cb68b
--- /dev/null
+++ b/palindrome.c
@@ -0,0 +1,19 @@
+#include
+ int main()
+{
+ int n,rem,rev=0,temp;
+ printf("enter the number=");
+ scanf("%d",&n);
+ temp=n;
+ while(n>0)
+ {
+ rem=n%10;
+ rev=(sum*10)+rem;
+ n=n/10;
+ }
+ if(temp==rev)
+ printf("Number is palindrome ");
+ else
+ printf("Number is not palindrome");
+ return 0;
+}
From c88add5bc04353e73496d9dfc55682a7ba8bb7c0 Mon Sep 17 00:00:00 2001
From: Muhammad Tabish Khanday
Date: Mon, 12 Oct 2020 18:18:34 +0530
Subject: [PATCH 072/129] Bubble Sort using recursion in cpp
---
bubble_sort_recursion.cpp | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 bubble_sort_recursion.cpp
diff --git a/bubble_sort_recursion.cpp b/bubble_sort_recursion.cpp
new file mode 100644
index 00000000..51ffa939
--- /dev/null
+++ b/bubble_sort_recursion.cpp
@@ -0,0 +1,35 @@
+// C/C++ program for recursive implementation of Bubble sort
+#include
+using namespace std;
+
+// A function to implement bubble sort
+void bubbleSort(int arr[], int n)
+{
+ // Base case
+ if (n == 1)
+ return;
+
+ for (int i = 0; i < n - 1; i++)
+ if (arr[i] > arr[i + 1])
+ swap(arr[i], arr[i + 1]);
+
+ bubbleSort(arr, n - 1);
+}
+
+
+void printArray(int arr[], int n)
+{
+ for (int i = 0; i < n; i++)
+ printf("%d ", arr[i]);
+ printf("\n");
+}
+
+int main()
+{
+ int arr[] = {64, 34, 25, 12, 22, 11, 90};
+ int n = sizeof(arr) / sizeof(arr[0]);
+ bubbleSort(arr, n);
+ printf("Sorted array : \n");
+ printArray(arr, n);
+ return 0;
+}
\ No newline at end of file
From 59bb980bcfd70b943e0b872dffc1f7ef21fea0d5 Mon Sep 17 00:00:00 2001
From: Rupali409 <54534133+Rupali409@users.noreply.github.com>
Date: Mon, 12 Oct 2020 18:57:37 +0530
Subject: [PATCH 073/129] Created basic_searchnumber.py
i had created a file in which we can search a number where number can be input from user and then it is sorted and it will return the index of that number.
---
basic_searchnumber.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 basic_searchnumber.py
diff --git a/basic_searchnumber.py b/basic_searchnumber.py
new file mode 100644
index 00000000..dddcbbd6
--- /dev/null
+++ b/basic_searchnumber.py
@@ -0,0 +1,20 @@
+l=[]
+print("Total number elements you want to add:")
+t=int(input())
+print("input elements:")
+
+for j in range(0,t):
+ p=int(input())
+ l.append(p)
+print("Unsorted list is:")
+print(l)
+print("Sorted list is:")
+l.sort()
+print(l)
+print("Enter the number you want to find index of :")
+n=int(input())
+if n in l:
+ print("number is at index:")
+ print(l.index(n))
+else:
+ print("element does not exits")
From cb6572943f7e11d91c7339aa28859e19de81302a Mon Sep 17 00:00:00 2001
From: Rupali409 <54534133+Rupali409@users.noreply.github.com>
Date: Mon, 12 Oct 2020 19:13:30 +0530
Subject: [PATCH 074/129] Created reverse string.py
i had created python file in which string is reversed.
---
Reverse String.py | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 Reverse String.py
diff --git a/Reverse String.py b/Reverse String.py
new file mode 100644
index 00000000..bd5f8388
--- /dev/null
+++ b/Reverse String.py
@@ -0,0 +1,5 @@
+print("enter a text you want to reverse")
+txt = str(input())
+a=txt[::-1]
+print("Reversed text is:")
+print(a)
From 05a42a46544650bbb4245f6423c265ce5a914384 Mon Sep 17 00:00:00 2001
From: divyanayak433 <59418316+divyanayak433@users.noreply.github.com>
Date: Mon, 12 Oct 2020 19:46:16 +0530
Subject: [PATCH 075/129] program to print maximum frequency element of a
tuple.
---
Max_frequence_of_tuple.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 Max_frequence_of_tuple.py
diff --git a/Max_frequence_of_tuple.py b/Max_frequence_of_tuple.py
new file mode 100644
index 00000000..c824f981
--- /dev/null
+++ b/Max_frequence_of_tuple.py
@@ -0,0 +1,21 @@
+# Maximum frequency in Tuple
+# Using loop + count()
+
+# initializing tuple
+test_tuple = (15, 12,33, 45,12 ,33 ,12)
+
+# printing original tuple
+print("The original tuple : " + str(test_tuple))
+
+# Maximum frequency in Tuple
+# Using loop + count()
+freq = 0
+res = test_tuple[0]
+for ele in test_tuple:
+ curr_freq = test_tuple.count(ele)
+ if(curr_freq> freq):
+ freq = curr_freq
+ res = ele
+# prints the leftmost highest frequency element of the tuple
+# printing result
+print("Maximum element frequency tuple : " + str(res))
From f0dc0998d65adba871f674455232f7386d696e2f Mon Sep 17 00:00:00 2001
From: malgorzatasobocinska
Date: Mon, 12 Oct 2020 19:48:58 +0200
Subject: [PATCH 076/129] added bubble sort implemenatation in java
---
BubbleSort.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 BubbleSort.java
diff --git a/BubbleSort.java b/BubbleSort.java
new file mode 100644
index 00000000..ff6a3509
--- /dev/null
+++ b/BubbleSort.java
@@ -0,0 +1,17 @@
+public class BubbleSort {
+ public static void BubbleSort(int arr[]){
+
+ int n = arr.length;
+
+ for (int i = 0; i < n - 1; i++) {
+ for (int j = 0; j < n - i - 1; j++) {
+ if(arr[j] > arr[j + 1]){
+ //swap
+ int temp = arr[j];
+ arr[j] = arr[j + 1];
+ arr[j + 1] = temp;
+ }
+ }
+ }
+ }
+}
From 0f1d4b84976e07baa3286669a38dfea790746530 Mon Sep 17 00:00:00 2001
From: Aaliya1708 <56965011+Aaliya1708@users.noreply.github.com>
Date: Mon, 12 Oct 2020 23:20:41 +0530
Subject: [PATCH 077/129] binarySearch
---
binarySearch.py | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 binarySearch.py
diff --git a/binarySearch.py b/binarySearch.py
new file mode 100644
index 00000000..204a091d
--- /dev/null
+++ b/binarySearch.py
@@ -0,0 +1,21 @@
+def bin_search(arr,x):
+ lo = 0
+ hi = len(arr)
+ while(lo<=hi):
+ mi = int((lo+hi)/2)
+ if(arr[mi]x):
+ hi=mi-1
+ else:
+ break
+ return mi
+
+
+def main():
+ arr = [128,15,3656,355,32,1,2546]
+ arr.sort()
+ x = 355
+ print("In The array "+str(x)+" exists at index",bin_search(arr,x))
+if _name=="main_":
+ main()
From 7067183832cfff376bed86e40ca7b89bbd6662cf Mon Sep 17 00:00:00 2001
From: Aaliya1708 <56965011+Aaliya1708@users.noreply.github.com>
Date: Mon, 12 Oct 2020 23:40:18 +0530
Subject: [PATCH 078/129] binaryExponentiation
---
binaryExponentiation.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 binaryExponentiation.cpp
diff --git a/binaryExponentiation.cpp b/binaryExponentiation.cpp
new file mode 100644
index 00000000..11be513e
--- /dev/null
+++ b/binaryExponentiation.cpp
@@ -0,0 +1,17 @@
+#include
+using namespace std;
+#define mod 1000000007
+int main()
+{
+ long long int a,b;
+ cin >> a >> b;
+ long long int res=1;
+ while(b>0)
+ {
+ if(b & 1)
+ res=(res*a)%(long long int)mod;
+ a=(a*a)%(long long int)mod;
+ b=b>>1;
+ }
+ cout << res;
+ }
From fb7b75d95a619a080b93508322426d0dd392b781 Mon Sep 17 00:00:00 2001
From: Rasika Deshpande <71489609+rasikadeshpande24@users.noreply.github.com>
Date: Tue, 13 Oct 2020 00:11:12 +0530
Subject: [PATCH 079/129] Add files via upload
---
stack.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
create mode 100644 stack.cpp
diff --git a/stack.cpp b/stack.cpp
new file mode 100644
index 00000000..a733ce43
--- /dev/null
+++ b/stack.cpp
@@ -0,0 +1,71 @@
+#include
+using namespace std;
+class Stack{
+ int stack[100], n = 100, top = -1;
+ public:
+ void push(int val);
+ void pop();
+ void display();
+};
+
+void Stack::push(int val) {
+ if(top >= n-1)
+ cout<<"Stack Overflow"<= 0) {
+ cout<<"Stack elements are:";
+ for(int i = top; i>= 0; i--)
+ cout<>ch;
+ switch(ch) {
+ case 1: {
+ cout<<"Enter value to be pushed:"<>val;
+ s.push(val);
+ break;
+ }
+ case 2: {
+ s.pop();
+ break;
+ }
+ case 3: {
+ s.display();
+ break;
+ }
+ case 4: {
+ cout<<"Exit"<
Date: Tue, 13 Oct 2020 09:34:20 +0530
Subject: [PATCH 080/129] create palindrome_number.c
---
palindrome_number.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 palindrome_number.c
diff --git a/palindrome_number.c b/palindrome_number.c
new file mode 100644
index 00000000..554598a5
--- /dev/null
+++ b/palindrome_number.c
@@ -0,0 +1,23 @@
+#include
+ int main()
+ {
+ int n, rev=0,t;
+ printf("Enter a number to check if it is a palindrome or not\n");
+ scanf("%d", &n);
+ t=n;
+ while(t!=0)
+ {
+
+ rev=rev*10+t%10;
+ t=t/10;
+
+ }
+ if(rev==n)
+ printf("%d is a palindrome number.\n",n);
+ else
+ {
+ printf("%d is not a palindrome number.\n",n);
+ }
+
+ return 0;
+}
From 028de1812725b6b17ab184681622a0fab7243e41 Mon Sep 17 00:00:00 2001
From: Danial Monachan <51749222+Danialmonachan11@users.noreply.github.com>
Date: Tue, 13 Oct 2020 10:08:51 +0530
Subject: [PATCH 081/129] Create quick_sort.py
added a Python File
---
quick_sort.py | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
create mode 100644 quick_sort.py
diff --git a/quick_sort.py b/quick_sort.py
new file mode 100644
index 00000000..984687dd
--- /dev/null
+++ b/quick_sort.py
@@ -0,0 +1,31 @@
+def partition(arr, low, high):
+ i = (low-1) # index of smaller element
+ pivot = arr[high] # pivot
+
+ for j in range(low, high):
+ if arr[j] <= pivot:
+
+ # increment index of smaller element
+ i = i+1
+ arr[i], arr[j] = arr[j], arr[i]
+
+ arr[i+1], arr[high] = arr[high], arr[i+1]
+ return (i+1)
+def quickSort(arr, low, high):
+ if len(arr) == 1:
+ return arr
+ if low < high:
+ pi = partition(arr, low, high)
+ quickSort(arr, low, pi-1)
+ quickSort(arr, pi+1, high)
+
+
+
+arr = [10, 7, 8, 9, 1, 5]
+n = len(arr)
+quickSort(arr, 0, n-1)
+print("Sorted array is:")
+for i in range(n):
+ print("%d" % arr[i]),
+
+
From b928adc22ee930809bb5110e8f999597701fc323 Mon Sep 17 00:00:00 2001
From: Danial Monachan <51749222+Danialmonachan11@users.noreply.github.com>
Date: Tue, 13 Oct 2020 10:18:12 +0530
Subject: [PATCH 082/129] Create palindrome.py
added a python file
---
palindrome.py | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 palindrome.py
diff --git a/palindrome.py b/palindrome.py
new file mode 100644
index 00000000..16016fb3
--- /dev/null
+++ b/palindrome.py
@@ -0,0 +1,16 @@
+def isPalindrome(str):
+
+ # Run loop from 0 to len/2
+ for i in range(0, int(len(str)/2)):
+ if str[i] != str[len(str)-i-1]:
+ return False
+ return True
+
+# main function
+s = "malayalam"
+ans = isPalindrome(s)
+
+if (ans):
+ print("Yes")
+else:
+ print("No")
From 93a00030f8eb48679f2886daa246d528556f928d Mon Sep 17 00:00:00 2001
From: pycrash
Date: Tue, 13 Oct 2020 11:55:21 +0530
Subject: [PATCH 083/129] Client server model project
---
.../README.md | 54 +++
.../client | Bin 0 -> 17984 bytes
.../client.c | 411 ++++++++++++++++++
.../screenshots/ss1.png | Bin 0 -> 357379 bytes
.../screenshots/ss2.png | Bin 0 -> 387891 bytes
.../screenshots/ss3.png | Bin 0 -> 417071 bytes
.../screenshots/ss4.png | Bin 0 -> 309035 bytes
.../screenshots/ss5.png | Bin 0 -> 408379 bytes
.../screenshots/ss6.png | Bin 0 -> 429365 bytes
.../screenshots/ss7.png | Bin 0 -> 437042 bytes
.../screenshots/ss8.png | Bin 0 -> 442609 bytes
.../server | Bin 0 -> 13552 bytes
.../server.c | 408 +++++++++++++++++
13 files changed, 873 insertions(+)
create mode 100644 Client Server Paradigm - Soket Programming/README.md
create mode 100644 Client Server Paradigm - Soket Programming/client
create mode 100644 Client Server Paradigm - Soket Programming/client.c
create mode 100644 Client Server Paradigm - Soket Programming/screenshots/ss1.png
create mode 100644 Client Server Paradigm - Soket Programming/screenshots/ss2.png
create mode 100644 Client Server Paradigm - Soket Programming/screenshots/ss3.png
create mode 100644 Client Server Paradigm - Soket Programming/screenshots/ss4.png
create mode 100644 Client Server Paradigm - Soket Programming/screenshots/ss5.png
create mode 100644 Client Server Paradigm - Soket Programming/screenshots/ss6.png
create mode 100644 Client Server Paradigm - Soket Programming/screenshots/ss7.png
create mode 100644 Client Server Paradigm - Soket Programming/screenshots/ss8.png
create mode 100644 Client Server Paradigm - Soket Programming/server
create mode 100644 Client Server Paradigm - Soket Programming/server.c
diff --git a/Client Server Paradigm - Soket Programming/README.md b/Client Server Paradigm - Soket Programming/README.md
new file mode 100644
index 00000000..8079f0dd
--- /dev/null
+++ b/Client Server Paradigm - Soket Programming/README.md
@@ -0,0 +1,54 @@
+
+## About the Project
+
+This project was build to learn the fundamentals of socket programming. Berkeley socket interface is used for implementing whatever I learned.
+The main features of this program are :
+1. Implemented client server paradigm.
+2. Functionality of sending and receiving text messages, basically a chat application.
+3. Functionality of sending various files such as text/images/audio/video.
+
+### Screenshots
+Running the server and client on same machine
+![Product Name Screen Shot][screenshot1]
+
+Sending a file
+![Product Name Screen Shot][screenshot2]
+
+Sending an txt file
+![Product Name Screen Shot][screenshot4]
+
+Sending a image
+![Product Name Screen Shot][screenshot5]
+
+Sending a audio file
+![Product Name Screen Shot][screenshot6]
+
+Sending a video file
+![Product Name Screen Shot][screenshot7]
+
+Chatting with the server
+![Product Name Screen Shot][screenshot8]
+
+
+
+
+### Installation
+
+1. Open the terminal run the server and give a port no.
+```sh
+./server portno
+```
+2. Open another terminal and run the client. If you are running the code in same machine then give address as 127.0.0.1 or if you are running the client in another machine then pass the server ip adderess (Can be found usisng ifconfig). Make sure that the port no. in both the cases are same
+```sh
+./client 127.0.0.1 portno
+```
+
+
+[screenshot1]: screenshots/ss1.png
+[screenshot2]: screenshots/ss2.png
+[screenshot3]: screenshots/ss3.png
+[screenshot4]: screenshots/ss4.png
+[screenshot5]: screenshots/ss5.png
+[screenshot6]: screenshots/ss6.png
+[screenshot7]: screenshots/ss7.png
+[screenshot8]: screenshots/ss8.png
diff --git a/Client Server Paradigm - Soket Programming/client b/Client Server Paradigm - Soket Programming/client
new file mode 100644
index 0000000000000000000000000000000000000000..361d2e10f60e3d3d0c92e39cde17633799d2a2a0
GIT binary patch
literal 17984
zcmeHPeQ+Gbm2XKFmW3_JUtnXv!-t3sc#*O32b^O`w#3+FV_{?y63lqDAJU#zyQv1O
zvSPU}8TVZ)+fDXK_QspG$(qQF3WY461D-G{zxTwV9esU&F8%du#xLLbb#~9ql{Z{W
zWmn*j?^|z)CVIbGQ%cz9@VA)$F1q`|@HT(V>i7FEeD{)o>ai#&lInoXDuUmP3bZ2l
zV;=I`J@D5&@U#d1B@g^^5BzQq{EP>l@W3zj!0+|Idpz)WJ@5k__*}%fSp4^S$p6v<
zKkb2cdfZ2VbdRBW|BS
z{!;w8(-8p0?4Rp_KL~uLm?yM44LKorevBedc%2J>Ug7mFd^PY{qDpL36Ib3h%tHa1
zc2T;Z=msM(kqGUH#DXH+9x?;+nk1u9vK<26
z8R|^Ji$usDB!zg&W;|?JZ`&J6#9=;Q_H>1eHX|AjkSIJ7FxnAMnr%HXe`iR9_aq`_
zNVEmwT|L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QWb)M(128hIR7FXaI{{srB@3B6wFYy1D!T&EtzJDr1d>?5&gqq0u
zyv{x3vjpos+Ryc$a_Q&46YDH}uE*jE{xd&{4B6uPHT6AKqx2PFaiQgNR^~Jax#*T-
z{lzYMZjPPuy|;_jbN#9V({qNt1-acke^N2~ZrATxZE^js4#)Mf>`V{+zpSw&&a$AQ
HZvFoUgcb_1
literal 0
HcmV?d00001
diff --git a/Client Server Paradigm - Soket Programming/client.c b/Client Server Paradigm - Soket Programming/client.c
new file mode 100644
index 00000000..5799f02d
--- /dev/null
+++ b/Client Server Paradigm - Soket Programming/client.c
@@ -0,0 +1,411 @@
+/* Created by pycrash */
+
+/* Socket programming in c to implement client server paradigm, this program offers mainly two functionalities -
+chatting among server and client using sockets,
+and sending files from client to server */
+
+/*
+provide three arguments
+filename server_ip_address port_no
+
+argv[0] filename
+argv[1] server_ip_address
+argv[2] port_no
+
+*/
+
+/*Client Model should have following functions
+1) Socket
+2) Connect
+3) Write
+4) Read
+5) close
+*/
+
+ //Contains declarartions for input and output
+#include
+ //Defines 4 variable types, several macros and various functions
+ //We will use atoi function to convert the string pointed to, by the argument to an integer
+#include
+ //defines one variable type, one macro, and various functions for manipulating arrays of characters
+#include
+ //for read, write and close
+#include
+ //conatins definitions of a no. of data types used in system calls
+#include
+ //contains constants and structures needed for internet domain addresses e.g. sockaddr_in
+#include
+ //definitions of structures needed for sockets e.g. defines sockaddr structure
+#include
+ //contains definition of Hostent structure
+#include
+ //declares several functions that are useful for testing and mapping characters.
+#include
+ // defines the structure of the data returned by the function fstat()
+#include
+ //defines the following requests and arguments for use by the functions fcntl() and open()
+#include
+ //definitions for internet operations
+#include
+
+//Error function to exit the program
+void error(const char *msg)
+{
+ /*perror is an inbuilt function that interprets the error no. and outputs the
+ output error description by using STDERR */
+
+ perror(msg);
+ exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+ /*The user need to provide 3 arguments, first one the file name,
+ second one -the ip address of server and lastly the port no. */
+
+ //socketfd is file descriptor
+ int socketfd, portno, n;
+
+ //sockaddr_in gives internet address
+ struct sockaddr_in serv_address;
+
+ //hostent structure is used to store info about the host such as host name, an IPv4 address etc.
+ struct hostent * server;
+ int sourse_fd;
+
+ //buffer will be transferred in a data stream
+ char buffer[1024];
+
+ //variables for operation - send file, chat etc.
+ int operation, sub_operation;
+
+ //file name variable
+ char str[20];
+ int file_name_len, read_len;
+
+ //checking if user provided 3 arguments or not
+ if (argc < 3)
+ {
+ //Terminating the program as user didnt provide 3 arguments
+ fprintf(stderr, "usage %s hostname port\n", argv[0]);
+ exit(0);
+ }
+
+ //converting the string argument into an int
+ portno = atoi(argv[2]);
+
+ //socket function returns a file descriptor, if its less than 0 then there is an error opening socket
+ /*socket function has 3 arguments, first one is domain, here we will use AF_INET which is an IPv4 protocol,
+ second argument is type, we will use SOCK_STREAM as it for TCP protocol, If we were to use UDP protocl, we would have provide SOCK_DGRAM as second argument,
+ third argument is protocol, which is 0 for TCP */
+ socketfd = socket(AF_INET, SOCK_STREAM, 0);
+
+ if (socketfd < 0)
+ {
+ //File descrpitor is less than 0, error opening socket
+ error("Error opening socket");
+ }
+
+ //getting info about host
+ server = gethostbyname(argv[1]);
+ if (server == NULL)
+ {
+ //server is null, no host exists
+ fprintf(stderr, "No such host exists");
+ }
+
+ //bzero clears data or anything in whatever it is refrenced to
+ //clearing serv_address so as to do operations on it
+ bzero((char*) &serv_address, sizeof(serv_address));
+
+ /*getting info such as port, using htons - host to network short,
+ converts port no. in host byte order to port no. in network byte order */
+ serv_address.sin_family = AF_INET;
+ bcopy((char*) server->h_addr, (char*) &serv_address.sin_addr.s_addr, server->h_length);
+ serv_address.sin_port = htons(portno);
+
+ //conneting to host, if file descriptor is less than 0, then the operation failed
+ if (connect(socketfd, (struct sockaddr *) &serv_address, sizeof(serv_address)) < 0)
+ error("connection Failed");
+
+ //clearing everything in the output buffer of a stream
+ fflush(stdout);
+
+ //Asking user what he wants to do
+ printf("What do you want me to do ?\n 1) Send File\n 2) Chat with server \nPress other key to terminate\n ");
+ //getting user input
+ scanf("%d", &operation);
+
+ //we will send this operation no. to server, so that server can execute operations accordingly
+ int number_to_send;
+ fflush(stdout);
+ number_to_send = operation;
+ int converted_number = htonl(number_to_send);
+
+ // Telling the server about the operation using write, there is a corresponding read in the server
+ write(socketfd, &converted_number, sizeof(converted_number));
+
+ //performing the operation according to user
+ switch (operation)
+ {
+ case 1:
+ //user selected send file
+ {
+ //asking user which type of file he/she wants to send
+ bzero(str, 20);
+ printf("Which type of file you want to send? \n1) Text file \n2) Image \n3) Audio \n4) Video \nPress any other key to terminate the program\n");
+
+ //we will send this sub - operation no. to server, so that server can execute sub-operations accordingly
+ scanf("%d", &sub_operation);
+ int sub_number_to_send;
+
+ //Telling the server about the sub - operation
+ fflush(stdout);
+ sub_number_to_send = sub_operation;
+ int sub_converted_number = htonl(sub_number_to_send);
+
+ // Telling the server about the sub-operation
+ write(socketfd, &sub_converted_number, sizeof(sub_converted_number));
+
+ switch (sub_operation)
+ {
+ //performing the sub operation according to user
+ case 1:
+ {
+ //User selected txt file
+ //asking the user, the name of the file he wants to send
+ //Note : The file should be in the same directory as this client.c file
+ printf("Type the name of your file that you want to send with the extension. Make sure that the file is in same directory as this file\n");
+
+ //clearing everything in str, so as to save the file name in str
+ //we will send this file name to server
+ bzero(str, 20);
+ scanf("%s", str);
+ n = write(socketfd, str, strlen(str));
+
+ //Starting the operation to send the txt file
+ FILE * f;
+
+ int words = 0;
+ char c;
+ f = fopen(str, "r");
+ while ((c = getc(f)) != EOF)
+ //Counting No of words in the file
+ {
+ fscanf(f, "%s", buffer);
+ if (isspace(c) || c == '\t')
+ words++;
+ }
+ //For printing the no. of words
+ //printf("Words = %d \n", words);
+
+ write(socketfd, &words, sizeof(int));
+ rewind(f);
+
+ // tells size of the file. Not required for the functionality in code.
+ /*
+ fseek(f, 0L, SEEK_END);
+ int sz = ftell(f);
+ printf("Size is %d \n", sz);
+ rewind(f);
+ */
+
+ char ch;
+ /*
+ On getting EOF (or error) from standard input, the client Stdin process, before it exits, needs to tell
+ the server that the client is done and there is nothing more coming down
+ the socket. The client has to signal "EOF" to the server.
+ */
+ //So we will keep sending the file through buffer until EOF is encountered
+ while (ch != EOF)
+ {
+
+ fscanf(f, "%s", buffer);
+ //For printing every word in the file
+ //printf("%s\n", buffer);
+ write(socketfd, buffer, 512);
+ ch = fgetc(f);
+ }
+ //The operation executed successfully
+ //The file was sent successfully
+ printf("The file was sent successfully\n");
+ break;
+ }
+ case 2:
+
+ {
+
+ /*memset copies the character 0 (an unsigned char) to the first 1024 characters of the string pointed to, by the argument buffer*/
+ memset(buffer, 0x00, 1024);
+
+ //User selected img file
+ //asking the user, the name of the file he wants to send
+ //Note : The file should be in the same directory as this client.c file
+ printf("Type the name of your image that you want to send with the extension. Make sure that the file is in same directory as this file\n");
+ scanf("%s", buffer);
+ printf("Sending your Image\n");
+ file_name_len = strlen(buffer);
+
+ //sending file name to server
+ send(socketfd, buffer, file_name_len, 0);
+
+ //opening the file in the buffer for reading
+ sourse_fd = open(buffer, O_RDONLY);
+ if (!sourse_fd)
+ {
+ //error opening the file
+ perror("Error reading file");
+ return 1;
+ }
+
+ while (1)
+ {
+
+ //reading the file and then sending it through buffer, if read_len is 0 then there is nothing to send and the loop gets terminated
+ memset(buffer, 0x00, 1024);
+ read_len = read(sourse_fd, buffer, 1024);
+ send(socketfd, buffer, read_len, 0);
+ if (read_len == 0)
+ {
+ break;
+ }
+ }
+ //Image was sent successfully
+ printf("Image sent\n");
+ break;
+ }
+ case 3:
+ {
+ /* memset copies the character 0 (an unsigned char) to the first 1024 characters of the string pointed to, by the argument buffer*/
+ memset(buffer, 0x00, 1024);
+
+ //User selected audio file
+ //asking the user, the name of the file he wants to send
+ //Note : The file should be in the same directory as this client.c file
+ printf("Type the name of your file that you want to send with the extension. Make sure that the file is in same directory as this file\n");
+ scanf("%s", buffer);
+ printf("Sending your audio file\n");
+ file_name_len = strlen(buffer);
+
+ //sending file name to server
+ send(socketfd, buffer, file_name_len, 0);
+
+ //opening the file in the buffer for reading
+ sourse_fd = open(buffer, O_RDONLY);
+ if (!sourse_fd)
+ {
+ //error opening the file
+ perror("Error : ");
+ return 1;
+ }
+
+ while (1)
+ {
+ //reading the file and then sending it through buffer, if read_len is 0 then there is nothing to send and the loop gets terminated
+ memset(buffer, 0x00, 1024);
+ read_len = read(sourse_fd, buffer, 1024);
+ send(socketfd, buffer, read_len, 0);
+ if (read_len == 0)
+ {
+ break;
+ }
+ }
+ //Audio file was sent successfully
+ printf("Audio sent\n");
+ break;
+ }
+ case 4:
+ {
+ /* memset copies the character 0 (an unsigned char) to the first 1024 characters of the string pointed to, by the argument buffer */
+ memset(buffer, 0x00, 1024);
+
+ //User selected video file
+ //asking the user, the name of the file he wants to send
+ //Note : The file should be in the same directory as this client.c file
+ printf("Type the name of your file that you want to send with the extension. Make sure that the file is in same directory as this file\n");
+ scanf("%s", buffer);
+
+ printf("Sending your video file\n");
+ file_name_len = strlen(buffer);
+
+ //sending file name to server
+ send(socketfd, buffer, file_name_len, 0);
+
+ //opening the file in the buffer for reading
+ sourse_fd = open(buffer, O_RDONLY);
+ if (!sourse_fd)
+ {
+ //error opening the file
+ perror("Error : ");
+ return 1;
+ }
+
+ while (1)
+ {
+ //reading the file and then sending it through buffer, if read_len is 0 then there is nothing to send and the loop gets terminated
+ memset(buffer, 0x00, 1024);
+ read_len = read(sourse_fd, buffer, 1024);
+ send(socketfd, buffer, read_len, 0);
+ if (read_len == 0)
+ {
+ break;
+ }
+ }
+ //Video file was sent successfully
+ printf("Video sent\n");
+ break;
+ }
+ default:
+ exit(0);
+ }
+ break;
+ }
+ case 2:
+ //user selected chat with server
+ //lets have a chat then
+ while (1)
+ {
+
+ //clearing buffer as will stream data through buffer only
+ fflush(stdout);
+ bzero(buffer, 1024);
+
+ //fgets reads a line from the specified stream and stores it into the string pointed to by buffer.
+ fgets(buffer, 1024, stdin);
+
+ //sending whatever is in buffer to sever
+ n = write(socketfd, buffer, strlen(buffer));
+
+ if (n < 0)
+ //file descriptor returns -1 which means write failed
+ error("Error Writing");
+
+ //again clearing buffer for reading data from server
+ bzero(buffer, 512);
+ //reading data from server
+ n = read(socketfd, buffer, 1024);
+ if (n < 0)
+ {
+ //file descriptor returns -1 which means read failed
+ error("Error reading");
+ }
+ printf("Server: %s\n", buffer);
+
+ //Server or client can anytime close the chat with keyword "Bye"
+ int i = strncmp("Bye", buffer, 3);
+ if (i == 0)
+ break;
+ }
+ break;
+
+ default:
+ //user entered other keyword, so we have to terminate the program
+ printf("Other key entered, terminating");
+ exit(0);
+ }
+
+ //closing the socket
+
+ close(socketfd);
+ return 0;
+}
diff --git a/Client Server Paradigm - Soket Programming/screenshots/ss1.png b/Client Server Paradigm - Soket Programming/screenshots/ss1.png
new file mode 100644
index 0000000000000000000000000000000000000000..7483acaf9f95e8b08e38e04a05678a3731fbe6f6
GIT binary patch
literal 357379
zcmZ^~1yGw&*EJg4f>YeJNP$2p?pi2NXpv$8Ql!P*t+>0ixI>XZDee}E7b)&3?!_f=
z)4t#P-|xROH#1ClnCBsxeb(OloVC`De6693k4udU008h`swij!09b(l0J;b^Ch{*k
zQ{D2&H*^=dmv6C=FJJ8U5y)#QS4Dl-Hx8Dr9%jxK04sY3JBw#75N8Vudlzd5*JHF!
zDFA>G@KQnct!LJOpGO;;V(Me#*SnRwl}urWKm0hBGR~B;GDKQH>@qw`8M9C~b;{ZA
zQM*
zd<2?b7-q_~eCt(2DjI3R6B~W`U^&>}kW^Jj#GDB|v67OPPP@^x0*>itcBiTty=Hj(
zqrO$C-rv9o6BTQIw)xEymw3Sofwy12KVBt-YNJl}V}@;S83Eg&$se$IZfFzs_EkUC
zACBHB-@rRfDs^HHE!6z!pWbzLK!+Q%>r61H{AVKsfj5XitD~b{Y?WbX+dS*PHhO@-K=F
zRC$LpnIpq>hdL(0!s4jqIPYwQDO{L2Ce%utQrE?Q#*9sM`|%;@2DY?J+l0dOsMJ
zs%CrR9u-G|dzaa3wr9rZnBbQ!u7d%6p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