Pages

Thursday, 23 January 2014

Radix Sort with unique Random Input


/* RADIX SORT */



/* Author :- Mufaddal Kagda *//

#include <stdio.h>
#include<time.h>
#define MAX 10
void insq(int,int,int*);
int b[MAX][MAX];
void print(int *a)
{
  int i;
  printf("\n");
  for (i = 0; i <MAX; i++)
    printf("%d\t", a[i]);
}

void radixsort(int *a, int n)
{
  int i,j,l=0,len[10],pos=0,temp=10,k,e=1;
 
  while(l<3)
  {
    k=0;
    for(i=0;i<10;i++)
    {
    len[i]=-1;
      }
   
     printf("\n");
  for(i=0;i<n;i++)
  {
pos=(a[i]%temp)/e;
insq(pos,a[i],len);

}
printf("\n\n");

 
  for(i=0;i<n;i++)
{
   for(j=0;j<=len[i];j++)
   {

a[k]=b[i][j];
k++;
                       }
}

temp=temp*10;
e=e*10;
l++;

   
}
 
 

}

void insq(int pos,int val,int *len)
{
  int i,j;
  len[pos]=len[pos]+1;
 
  b[pos][len[pos]]=val;
  /* printf("\n\n\n");
  for(i=0;i<4;i++)
  for(j=0;j<4;j++)
  printf("%d",b[i][j]);
  printf("\n");*/
 
}


int main()
{
  int arr[MAX];
  time_t t;
  int i, n;
  srand(time(&t));
 
  for (i = 0; i < MAX; i++)
   arr[i]=rand()%1000;

  printf("\nARRAY  : ");
  print(arr);

  radixsort(arr,MAX);

  printf("\nSORTED : ");
  print(arr);
  printf("\n");
  getch();
  return 0;
}

Wednesday, 22 January 2014

Check for balanced parentheses in an Expression

Algorithm:
1) Now traverse the expression string exp.
    a) If the current character is a starting bracket (‘(‘ or ‘{‘ or ‘[') then push it to stack.
    b) If the current character is a closing bracket (')' or '}' or ']‘) then pop from stack and if the popped character is the matching starting bracket then fine else parenthesis are not balanced.
2) After complete traversal, if there is some starting bracket left in stack then “not balanced”


Implementation :

/*  Author :- Mufaddal Kagda */

#include<stdio.h>
#include<conio.h>
#include<malloc.h>

struct node
{
int info;
struct node *link;
};
typedef struct node SNODE;
int push(SNODE **,int);
int display(SNODE *);
bool areParenthesisBalanced(char exp[]);
bool isMatchingPair(char character1, char character2);
int pop(SNODE **);
int main()
{
SNODE *pnew,*ptop;
int rv,ch,k,val;
system("CLS");
ptop=NULL;
char exp[100];
    while(1)
    {
   system("CLS");
printf("\n1.Insert an expression.");
printf("\n2.exit");
printf("\nEnter your choice : ");
scanf("%d",&ch);
switch(ch)
{
case 1:
  printf("\nEnter an Expression to check : ");
  scanf("%s",exp);
  if(areParenthesisBalanced(exp))
 printf("\n Balanced ");
   else
             printf("\n Not Balanced ");
             break;
       default:
exit(0);

        }
getch();
    }
 
     return 0;
}
int push(SNODE **aptop,int val)
{
SNODE *pnew;

pnew=(SNODE *)malloc(sizeof(SNODE));
pnew->info=val;
pnew->link=*aptop;

*aptop=pnew;
return 0;

}

int display(SNODE *pcurr)
{
while(pcurr !=NULL)
{
printf(" %d",pcurr->info);
pcurr=pcurr->link;
}
return 0;
}

int pop(SNODE **ptop)
{
SNODE *pdel;
int ret;
if(*ptop==NULL)
return -1;
pdel=*ptop;
(*ptop)=(*ptop)->link;
ret=pdel->info;
free(pdel);
return ret;

}
bool isMatchingPair(char character1, char character2)
{
   if(character1 == '(' && character2 == ')')
     return 1;
   else if(character1 == '{' && character2 == '}')
     return 1;
   else if(character1 == '[' && character2 == ']')
     return 1;
   else
     return 0;
}

bool areParenthesisBalanced(char exp[])
{
   int i = 0;

 
    SNODE *stack = NULL;

 
   while(exp[i])
   {
 
      if(exp[i] == '{' || exp[i] == '(' || exp[i] == '[')
        push(&stack, exp[i]);

 
      if(exp[i] == '}' || exp[i] == ')' || exp[i] == ']')
      {

 
         if(stack == NULL)
           return 0;

 
         else if ( !isMatchingPair(pop(&stack), exp[i]) )
           return 0;
      }
      i++;
   }

 
   if(stack == NULL)
     return 1; /*balanced*/
   else
     return 0;  /*not balanced*/
}

Monday, 2 September 2013

Class C Error in Counter Strike

LAN servers are restricted to local clients (class C).





When Connecting 2 or more Systems in a network for playing Counter Strike, many times we face a Class C Error.To Solve this no need to restart systems or CS game on all the Systems.


Solution:-

Restart the CS (Counter Strike) game of the System which is the "Host" of the game. And again start hosting the game and allow all others systems to connect. Thats it!!

If any other Queries ,please feel free to comment. i will try to respond as soon as possible. :)

Wednesday, 29 May 2013

How to Show Profile Pictures of your Whatsapp contacts in Gallery

For Android Phones---------------

Whatsapp Contacts Profile pictures are actually get Saved when we open it and will remain in phone till that contacts new Pic replace it. So if you want to show them up in Gallery then follow the below steps

1)  Open File Manger or say "my files".

2)  Go into Whatsapp Folder

3)  There will be several folders such as Backups,Media, Profile Pictures etc. Open Profile Pictures folder.

4)  There we can see Contacts Pictures with a one extra file which is " .nomedia " . 

5) Delete that  .nomedia  file.

And thats it. You are Done !!!

Note:-  Deleting .nomedia file is totally safe. If in future you want it back then just restart your Phone. :) 
 

How to Hide Media Files from showing up in Gallery of Android Phones

For Android Phones----------------

Many times we have to give our phone to Friends or Family when they ask for it and in some situations we can't refuse it. But we actually dont want them to see some Media Files( like pictures,vedios or Audios ) which are private.

In that case, u need the below tweak!!! 
Steps as Follows====

1) Open your phone's  File Manager

2) Go To that  Folder which contains your media files.

3) Rename the Folder by putting a dot(.) infront of the folder Name. ( but dont forget to change the  File Manager settings for showing Hidden Files)
                                       OR
3) Paste a " .nomedia " file in that folder.

and thats it. You are Done !!! 


NOTE :- You  dont need to get or create a " .nomedia " file. If you are Whatsapp User then you actually Have it. Its in your "Profile Pictures" Folder. Just Copy it and paste to the folder whichever you want.

If any have Query feel free to Comment here. I would Love to reply it asap.