בגרות 2019

פתרון ב c#

public static bool Order(BinNode <Range>  t)

{

        if (t==null)

                return true;

        if( t.HasLeft() && !(t.GetValue().GetLow() ==  t.GetLeft().GetValue().GetLow()&& t.GetValue().GetHigh() >=  t.GetLeft().GetValue().GetHigh()) ))

        return false;

        if( t.HasRight() && !(t.GetValue().GetHigh() ==  t.GetRight().GetValue().GetHigh()&& t.GetValue().GetLow() >=  t.GetRight().GetValue().GetLow()) ))

        return false;

if(t.HasLeft() && t.HasRight()   && !(   t.GetLeft().getHigh < t.GetRight().GetLow() ))

        return false;

return Order(t.GetLeft())  &&  Order(t.GetRight());

}