GET ADMISSION in any stream CONTACT :: Mr. JAYDEEP MEHTA :: CONTACT NO :: 9228217183
Get & share knowledge with us... Be a part of GTU-MATERIAL. send study Material at gtumca1@gmail.com with your Name - College name...
Showing posts with label material. Show all posts
Showing posts with label material. Show all posts

Monday, March 21, 2011

DATA STRUCTURE MANAGEMENT

Gujarat Technological University

330701 DATA STRUCTURE MANAGEMENT. 21/01/2010. 11.00 am to 1.30 pm .... Any type
of printed/hand written/typed material, Mobile phone, Pager or ... All
Principals of Diploma Engineering colleges affiliated to GTU for display on ...
www.gtu.ac.in/ExamTimetable/Dec09Jan1... - Cached - Similar

Gujarat Technological University Diploma Engineering Sem-III Jan ...

330701 DATA STRUCTURE MANAGEMENT. BC CC. 086180319543 D145959 RABARI ...
www.gtu.ac.in/Result/Dec09Jan10/DE3Ja... - Cached - Similar

Monday, March 7, 2011

postfix

/*   Write a Program for to evaluate postfix expression    */
char postfix[100];
static i,top;
long int stack[20];
void main()
{
  int temp,p;
   clrscr();
   printf("Enter  Postfix Expression : ");
   scanf("%s",postfix);

   for(i=0;postfix[i]!='\0';i++)
    {

      if(postfix[i]=='$' || postfix[i]=='^')
       {
         temp = stack[top-1];
         p = stack[top-2];
         while(temp>1)
          {
            stack[top-2] *=p;
            temp--;
          }
         top--;
       }
      else if(postfix[i] == '+')
       {
         stack[top-2] += stack[top-1];
          top--;
       }
      else if(postfix[i] == '-')
       {
         stack[top-2] -= stack[top-1];
          top--;
       }
      else if(postfix[i] == '*')
       {
         stack[top-2] *= stack[top-1];
          top--;
       }
      else if(postfix[i] == '/')
       {
         stack[top-2] /= stack[top-1];
          top--;
       }
      else if(postfix[i]!=',')
       {
         stack[top] = postfix[i]-48;
          while(postfix[i+1]!=',')
            {
              stack[top] *= 10 + postfix[i+1]-48;
              i++;
            }
         top++;
       }
    }
    printf("\nValue of Postfix Expression : %ld",stack[top-1]);
 getch();
}




STAARRAY

/*  Write a Program to perform the following operation stack using array. */
/* PUSH, POP, ISEMPTY, ISFULL, PEEP   */
#define max 4
void push();
void pop();
int isempty();
int isfull();
void peep();
void disp();
int top=-1,stack[max];
void main()
{
  int ret,s1,choice;
  clrscr();
do
{
  printf("\n\n1 : Push element in Stack.\n");
  printf("2 : Pop an element from stack.\n");
  printf("3 : Peep an element into stack.\n");
  printf("4 : Exit from Program.\n");
  printf("Enter your choice :  ");
  scanf("%d",&choice);

  switch(choice)
   {
    case 1:
        ret = isfull();
          if(ret!=1)
           push();
           disp();
         break;
    case 2:
        ret = isempty();
         if(ret != 1)
           pop();
           disp();
         break;
    case 3:
         ret = isempty();
          if(ret != 1)
           peep();
           disp();
         break;
    case 4:
         exit();
    default :
        printf("\n\n\t\t######## INVALID CHOICE ##########\n\n");
   }

}while(s1);

}



int isfull()
{
  if(top == max)
   {
    printf("\n\n\t\t####### STCK IS OVERFLOW #########\n\n");
    return 1;
   }
  else
   return 0;
}


int isempty()
{
  if(top == -1)
   {
    printf("\n\n\t\t####### STCK IS UNDERFLOW #########\n\n");
    return 1;
   }
  else
   return 0;
}

void push()
{
  int item;
  printf("\nEnter an Integer value : ");
  scanf("%d",&item);
  top = top + 1;
  stack[top] = item;
}

void pop()
{
  int item;
  item = stack[top];
  top = top -1;
  printf("\n\n\t\t%d is deleted\n",item);
}


void peep()
{
  int item,p;
  printf("\n\nEnter position : ");
  scanf("%d",&p);
   printf("\n\nYour selected Element is %d ",stack[top-p+1]);
}

void disp()
{
  int i;
  printf("\n\nStack Contains : ");
  for(i=0;i<=top;i++)
   printf("%d ",stack[i]);
}

recursive

void main(int n)
{
  printf("%d  ",n);
  n++;
  if(n>100)
   exit(getch());
 main(n);
}

Twitter Delicious Facebook Digg Stumbleupon Favorites More