check expression

This section contains programs that implements different Data Structures both in Graphical and Console Mode.

check expression

Postby shariquekhan on April 21st, 2008, 12:36 pm

Salam Tahir bhai I pick this algorithm from data structure book yeh algorithm stack ko use kerte hue brackets ko check kerta hai ke string mein brackets "( ) or { } or [ ]"sahi hain ya nahi is mein mujhe thora masla hai file send ker raha hon check ker ke batai ke sahi implement kia hai ya nahi
mujhe masla variable 'j' mein pop karane ke bad if ki condition kya lage gi is mein hai check kare ke mai ne sahi lagai hai ya nahi
You do not have the required permissions to view the files attached to this post.
shariquekhan
 
Posts: 6
Joined: April 16th, 2008, 10:34 am

Re: check expression

Postby MT Shahzad on April 23rd, 2008, 10:51 am

Hello!

Please also post the algorithm, so that i can have a good look on your problem.
MT Shahzad
Web/Software Developer
http://mts.sw3solutions.com
User avatar
MT Shahzad
Site Admin
 
Posts: 300
Joined: February 29th, 2008, 8:11 am
Location: Muridke, Pakistan

Re: check expression

Postby shariquekhan on April 23rd, 2008, 5:42 pm

ok Tahir bhai I will post that algorithm later. I'm little bit busy now mai na ap ka reply parha to post send ker di. ap ne file download ker ke check ki. plz reply or mai algorithm kal tak send ker do ga. Thanks for a reply. or mujhe suggestion de ke agar mujhe system & securities ko apni field banana hai to kya karo
Thanks again for the reply
shariquekhan
 
Posts: 6
Joined: April 16th, 2008, 10:34 am

Re: check expression

Postby shariquekhan on April 23rd, 2008, 8:16 pm

Here is an algorithm

Code: Select all
valid= true                                 /* assume the string is valid */
s= the empty stack;
while(we have not read the entire string){
    read the next symbol (symb) of the string;
    if(symb == '(' || symb == '[' || symb == '{')
      push(s,symb);
   
    if(symb == ')' || symb == ']' || symb == '}')
      if ( empty(s) )
         valid= false;
     else{
          i= pop(s);
          if(i is is not the matching opner of symb)
             valid= false; 
      }//end else
}//end while

if ( !empty(s) )
         valid= false;

if(valid)
print "String is valid";

else
print "String is not valid";


is progarm mein yeh zaroor check kijie ga

if(i is is not the matching opner of symb)
valid= false;

yahan mujhe masla tha. check kerna ke yeh condition sahi lagai hai ya nahi progam mein
shariquekhan
 
Posts: 6
Joined: April 16th, 2008, 10:34 am


Return to Data Structures

Who is online

Users browsing this forum: No registered users and 0 guests