Algorithm Design and Analysis :: Blog :: A general question


January 07, 2008

you are given an expression like (a+((b+c)))..... here extra braces are provided on b+c... i mean like (b+c) is ok... but ((b+c)) isnt as it contains redundant brackets.. So for a given expression you have to tell whether expression contains redundant paranthesis or not.....?

 

I would like you people to try this question.... its quite simple .... i will provide you with the answer in next couple of days................... 

Posted by Algorithm Design and Analysis - sam


Comments

  1. While addition is generally associative in code but you might not always get the same results. The order of operations does make a difference but it depends on operation and values. For example: floating-point numbers...

    class Program
    {
        static void Main(string[] args)
        {
            float a = float.MaxValue;
            float b = -a;
            float c = -1;

            Console.WriteLine(a+(b+c));
            Console.WriteLine((a+b)+c);
        }
    }

    Output is:

    0
    -1

    nicknick on Monday, 07 January 2008, 13:27 PST # |

  2. well sir my question wasnt what you have understood........ i hav a question in which you just have to report an error when a redundant bracket occurs..............

    samsam on Monday, 07 January 2008, 13:37 PST # |


You must be logged in to post a comment.