Skip to content

Instantly share code, notes, and snippets.

View priyadarshitathagat's full-sized avatar
🎯
Focused

Tathagat Priyadarshi priyadarshitathagat

🎯
Focused
View GitHub Profile
@priyadarshitathagat
priyadarshitathagat / Palindrome_Anagram
Created September 13, 2016 14:47
To check whether a given string is Palindrome or not if not, check whether any of its 'ANAGRAM' is Palindrome or not with a complexity of O(N)
import java.io.*;
import java.util.*;
class palin_anagram
{
void str(String s)
{
char ch[]=s.toCharArray();
Arrays.sort(ch);
int l=s.length();
if(l%2==0)
@priyadarshitathagat
priyadarshitathagat / prefix_to_postfix.c
Last active November 20, 2022 15:17
Prefix to Postfix conversion in c using stack
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
# define MAX 20
char str[MAX],stack[MAX];
int top=-1;
void push(char c)
{
stack[++top]=c;
@priyadarshitathagat
priyadarshitathagat / postfix_to_prefix.c
Created September 15, 2016 21:08
Postfix to Prefix conversion in c using stacks
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
# define MAX 20
char str[MAX],stack[MAX];
int top=-1;
void push(char c)
{
stack[++top]=c;
@priyadarshitathagat
priyadarshitathagat / pre_post_to_infix.c
Last active March 21, 2023 17:29
Postfix to Infix and Prefix to Infix conversion in c using stacks
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
# define MAX 20
char str[MAX],stack[MAX];
int top=-1;
void push(char c)
{
stack[++top]=c;
@priyadarshitathagat
priyadarshitathagat / sparce.c
Created September 15, 2016 21:11
Transpose and Fast_Transpose of a sparce matrix in c
#include<stdio.h>
struct spa
{
int row; int col; int val;
};
main()
{
struct spa a[20],b[20];
printf("Enter of rows, coloums, and number of elements\n");
scanf("%d%d%d",&a[0].row,&a[0].col,&a[0].val);
@priyadarshitathagat
priyadarshitathagat / sorting_strings.c
Created September 15, 2016 21:17
Program to sort strings in c using pointers
#include<stdio.h>
#include<string.h>
//to enter number of strings and then sort the string lexicographically
main()
{
char str[10][20],*p=&str[0][0];
printf("Enter n\n"); int i,n;
scanf("%d",&n);
for(i=0; i<n; i++)
scanf("%s",(p+i*20)+0);
@priyadarshitathagat
priyadarshitathagat / stack.c
Created September 17, 2016 16:48
Stack Implementation in c
#include<stdio.h>
main()
{ int a[20],front=-1,x,n;
printf("enter size of stack\n");
scanf("%d",&n); n=n-1;
while(1)
{ printf("Enter 1 to push,2 to pop and 3 to display:\n");
int c; scanf("%d",&c);
switch(c)
{ case 1:{front=push(&a,front,n); break;}
@priyadarshitathagat
priyadarshitathagat / queue.c
Created September 17, 2016 16:50
Queue Implementation in c
#include<stdio.h>
main()
{ int a[20],front=-1,rear=-1,x,n;
printf("enter size of queue\n");
scanf("%d",&n); n=n-1;
while(1)
{ printf("Enter 1 to push,2 to pop and 3 to display:\n");
int c; scanf("%d",&c);
switch(c)
{ case 1:{rear=push(&a,rear,n); break;}
@priyadarshitathagat
priyadarshitathagat / linked_stack.c
Last active October 7, 2016 06:59
Stack implementation using Linked List in c
#include <stdio.h>
#include<stdlib.h>
struct node
{
int val;
struct node *link;
};
struct node* getnode( )
{
@priyadarshitathagat
priyadarshitathagat / infix_to_postfix.c
Created September 23, 2016 19:58
Program to convert Infix expression to Postfix expression in c
#include<stdio.h>
#define max 100
int top=-1, a[max];
void push(char x)
{
a[++top]=x;
}
char pop()
{ if(top==-1)
return -1;