Skip to content

Instantly share code, notes, and snippets.

View suryansh011's full-sized avatar

Suryansh Singh suryansh011

View GitHub Profile
@suryansh011
suryansh011 / dstask4.c
Created October 17, 2021 16:34
Link List Problem
#include<stdio.h>
#include<stdlib.h>
struct Node {
int data;
struct Node *link;
};
void printList(struct Node *head) {
struct Node *ptr = head;
@suryansh011
suryansh011 / union_sets.c
Created October 11, 2021 12:24
Union of Two Sets
/* WAP in 'C' to find out the union of two set */
#include <stdio.h>
int main() {
int i, j, k = 0; /* Counters */
int a[] = {1, 3, 5, 7, 9, 11};
int b[] = {2, 4, 6, 12, 14, 16, 18, 8, 10, 12, 14, 16, 18, 20};
int r[99] = {};
@suryansh011
suryansh011 / counting_sort.c
Created October 10, 2021 09:59
Counting Sort Algorithm in C
#include<stdio.h>
void countingSort(int arr[], int len, int k, int out[]) {
int i, j;
int temp[k];
for(i = 0; i < k; i++)
temp[i] = 0;
for(j = 0; j < len; j++)
@suryansh011
suryansh011 / simple_quick_sort.c
Created October 1, 2021 18:18
Simple Quick Sort
include <stdio.h>
int partition(int s[], int l, int h) {
int i, p, firsthigh, temp;
p = h;
firsthigh = l;
for (i = l; i < h; i++) {
if (s[i] < s[p]) {
temp = s[i];
@suryansh011
suryansh011 / pure_selection_sort.c
Created October 1, 2021 16:23
Pure Selection Sort in C
/* Selection Sort Algorithm */
#include <stdio.h>
int main() {
int i, j;
int min, temp;
int c = 0, s = 0;
int n;
#include <stdio.h>
int main()
{
int i, count = 0, low, high, mid, n, key, array[100];
scanf("%d",&n);
for(i = 0; i < n; i++)
scanf("%d",&array[i]);
scanf("%d", &key);
low = 0;
high = n - 1;
#include <stdio.h>
int main() {
int m, n, i, out;
scanf("%d", &m);
int arr[m];
for(i = 0; i < m; i++)
scanf("%d", &arr[i]);
scanf("%d", &n);
#include <stdio.h>
int main() {
int x1, x2, v1, v2, i = 0, flag = 0;
scanf("%d%d%d%d", &x1, &v1, &x2, &v2);
for (i = 0; i < 10000; i++) {
if ((x1 + i*v1) == (x2 + i*v2)) {
flag = 1;
break;
@suryansh011
suryansh011 / reverse_array.c
Created September 9, 2021 16:56
Reverse Array in C
#include <stdio.h>
int main() {
int num, i;
scanf("%d", &num);
int array[num];
for (i = 0; i < num; i++) {
scanf("%d", &array[i]);
}
@suryansh011
suryansh011 / nginx.conf
Created August 30, 2021 12:19
Nginx configuration with per user web directory
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;