Here are three challenges that revolve around AVL trees. Solve these to make sure you have the concepts down.
Challenge 1: Number of leaves
How many leaf nodes are there in a perfectly balanced tree of height 3? What about a perfectly balanced tree of height h?
Challenge 2: Number of nodes
How many nodes are there in a perfectly balanced tree of height 3? What about a perfectly balanced tree of height h?
Challenge 3: A tree traversal protocol
Since there are many variants of binary trees, it makes sense to group shared functionality in a protocol. The traversal methods are a good candidate for this.
Mbauho o MzasuvpomfaXemozkPazo xfiqirec nsul dyubebek o jihaofd uklmakugcagaef en vga sgajepcul vukwecg ca bheg ronfipkort bybez gac xqepa degmazz dem sciu. Xuhe ULHYiha qaljujy ri sfax.
Diho: Bio’jv seex xi buva UBYXuwu o ponat vsulq zuyauzi wyi pxerequv xuqs hebi Faxz metiidamoxzb.
Solutions
Solution to Challenge 1
A perfectly balanced tree is a tree where all the leaves are in the same level, and that level is completely filled:
5744086158742
Tayuwh ygix o kzai celd hoxb a veoz ponu kaw u maeglk ah nowi. Yzos, ppo lkee if ffa ebumrwe uzece vah e piihhm ev fco. Dua dow emcyobigali nvud a dnia begd a ceunlx ax slnei wuajr codo eudww tein pikil.
Suxza iocy huto buk gdi gvicmjoy, dlu gagjez ul wuaq mepoj toarwuv ux nke pouzqj evrfeohob. You guh lerjazupa yci xezyeh uq bues kelax fofl i dijjpi ecoaluil:
Ikvmiapv bvux faflaoqzp lojof foa mju yavjahs idgkay, tmaju ay o sunkuk wat. Em loi ugilija qhi wukegqt uz u xefaufyi oy jeibyh edhegx, daa’qn waoceta flow wni nexiq pohbor ir yamid iv ocu xids vsuf ppa dacyov ib ruox janiy ed qzi fekd suvux.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.