Program 5CUDA 1 Parentheses Matching Due Tues 11292016 Write

Program 5:CUDA 1 Parentheses Matching Due Tues 11-29-2016 Write a CUDA program that will determine whether a given input of parentheses match Write the code for serial version Write a CUDA version that works across multiple MPs Both versions should read in a file of parentheses They will return True if the series matches and False of they don\'t Analyze Compare the running times of the serial version vs the GPU version Run for several different inputs Deliver Source code for serial and CUDA versions Graph

Solution

paranthesis.cu

#include < stdio.h >
#define max 50

void main()
{
   //declaring variables
   char stack[max],input[100];
   int top,i;  
   top = -1;  
   printf(\"\ Enter expression: \");
   gets(input);  
   // processing each char
   for(i=0; input[i] != \'\\0\'; i++)
   {
       if( input[i]==\'(\' || input[i] ==\'[\' || input[i] == \'{\' )
       {
           top++;
           stack[top]= input[i];
       }
       else
       if ( input[i] == \')\' )
       {
           if( stack[top] == \'(\' )
           top--;
       }
       else
       {
           printf(\"wrong Paranthesis input\");
           exit(0);
       }
       }
       else
       if ( input[i] == \']\' )
       {
       if( stack[top] == \'[\' )
           top--;
       else
       {
           printf(\"wrong Paranthesis input\");
           exit(0);
       }
       }
       else
       if ( input[i] == \'}\' )
       {
       if( stack[top] == \'{\' )
           top--;
       else
       {
           printf(\"wrong Paranthesis input\");
           exit(0);
       }
       }
   } // end for
   if( top == -1 )
       printf(\"Youe entered expression is balanced one. Good job!!\");
   else
       printf(\"Youe entered expression is not balanced one. Try again!!\");
}

 Program 5:CUDA 1 Parentheses Matching Due Tues 11-29-2016 Write a CUDA program that will determine whether a given input of parentheses match Write the code fo
 Program 5:CUDA 1 Parentheses Matching Due Tues 11-29-2016 Write a CUDA program that will determine whether a given input of parentheses match Write the code fo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site