right : leftp left :pif bal + then bal :- else bal : endif bal - then bal : else bal : endp : bal : end end end balancelprocedure balancer (var pnodevar hboolean)var nodebegin (*hright branch has shrunk*if bal then bal : elsif bal then bal :- :false else (*bal - rebalance* : leftif bal < then (*single ll rotation* left : rightp right :pif bal then bal :- bal : :false else bal : bal : endp : else (*double lr rotation* : rightp right : leftp left : left : rightp right :pif bal - then bal : else bal : endif bal + then bal :- else bal : endp : bal : end end end balancerprocedure delete (xintegervar pnodevar hboolean)var qnodeprocedure del (var rnodevar hboolean)begin (*~ *if right nil then del( righth)if then balancer(rhend else key : keyq count : countq :rr : lefth :true end end delbegin (*~ *if nil then (*key not in tree*elsif key then delete(xp lefth)if then balancel(phend elsif key then delete(xp righth)if then balancer(phend