    {"id":2388,"date":"2022-10-26T21:53:58","date_gmt":"2022-10-26T14:53:58","guid":{"rendered":"http:\/\/student-activity.binus.ac.id\/himmat\/?p=2388"},"modified":"2022-10-26T21:53:58","modified_gmt":"2022-10-26T14:53:58","slug":"apa-itu-avl-tree","status":"publish","type":"post","link":"https:\/\/student-activity.binus.ac.id\/himmat\/2022\/10\/apa-itu-avl-tree\/","title":{"rendered":"Apa Itu AVL Tree?"},"content":{"rendered":"<p><em><span style=\"font-weight: 400\">AVL Tree<\/span><\/em><span style=\"font-weight: 400\"> adalah salah satu bentuk <\/span><em><span style=\"font-weight: 400\">self-balancing tree<\/span><\/em><span style=\"font-weight: 400\"> dari sebuah <\/span><em><span style=\"font-weight: 400\">binary search tree<\/span><\/em><span style=\"font-weight: 400\">. <\/span><em><span style=\"font-weight: 400\">AVL Tree<\/span><\/em><span style=\"font-weight: 400\"> dikatakan <\/span><em><span style=\"font-weight: 400\">balance <\/span><\/em><span style=\"font-weight: 400\">(seimbang) apabila nilai absolut dari <\/span><em><span style=\"font-weight: 400\">balance factor<\/span><\/em><span style=\"font-weight: 400\"> dalam masing-masing <\/span><i><span style=\"font-weight: 400\">node<\/span><\/i><span style=\"font-weight: 400\"> tidak melebihi satu. Apabila nilai tersebut lebih dari satu, maka <\/span><i><span style=\"font-weight: 400\">node <\/span><\/i><span style=\"font-weight: 400\">tersebut akan dinyatakan sebagai tidak seimbang<\/span><span style=\"font-weight: 400\">. Karena terdapat sebuah <\/span><i><span style=\"font-weight: 400\">node <\/span><\/i><span style=\"font-weight: 400\">yang tidak seimbang<\/span><span style=\"font-weight: 400\">\u00a0maka <\/span><i><span style=\"font-weight: 400\">node <\/span><\/i><span style=\"font-weight: 400\">tersebut telah melakukan pelanggaran sifat <\/span><em><span style=\"font-weight: 400\">self-balancing tree<\/span><\/em><span style=\"font-weight: 400\"> dari sebuah <\/span><em><span style=\"font-weight: 400\">AVL Tree<\/span><\/em><span style=\"font-weight: 400\">, maka perlu dilakukan perbaikan pada <\/span><em><span style=\"font-weight: 400\">tree<\/span><\/em><span style=\"font-weight: 400\"> tersebut.\u00a0<\/span><\/p>\n<p><em><span style=\"font-weight: 400\">Balance factor <\/span><\/em><span style=\"font-weight: 400\">sebuah <\/span><i><span style=\"font-weight: 400\">node <\/span><\/i><span style=\"font-weight: 400\">dapat dihitung dengan mengurangi nilai <\/span><em><span style=\"font-weight: 400\">height subtree <\/span><\/em><span style=\"font-weight: 400\">anak kiri dengan nilai <\/span><em><span style=\"font-weight: 400\">height subtree <\/span><\/em><span style=\"font-weight: 400\">anak kanan dari <\/span><i><span style=\"font-weight: 400\">node tersebut<\/span><\/i><span style=\"font-weight: 400\">, sedangkan <\/span><em><span style=\"font-weight: 400\">height <\/span><\/em><span style=\"font-weight: 400\">sendiri adalah jumlah <\/span><em><span style=\"font-weight: 400\">edge<\/span><\/em><span style=\"font-weight: 400\"> yang ada dari <\/span><em><span style=\"font-weight: 400\">root <\/span><\/em><span style=\"font-weight: 400\">menuju <\/span><em><span style=\"font-weight: 400\">leaf<\/span><\/em><i><span style=\"font-weight: 400\"> node <\/span><\/i><span style=\"font-weight: 400\">paling bawah (<\/span><i><span style=\"font-weight: 400\">level <\/span><\/i><span style=\"font-weight: 400\">tertinggi).<\/span><i><\/i><\/p>\n<p style=\"text-align: center\"><a href=\"http:\/\/student-activity.binus.ac.id\/himmat\/wp-content\/uploads\/sites\/14\/2022\/10\/tidak-balance.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2389\" src=\"http:\/\/student-activity.binus.ac.id\/himmat\/wp-content\/uploads\/sites\/14\/2022\/10\/tidak-balance.png\" alt=\"\" width=\"321\" height=\"251\" \/><\/a><b><br \/>\nContoh tidak <\/b><b><i>balance<\/i><\/b><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center\"><b><a href=\"http:\/\/student-activity.binus.ac.id\/himmat\/wp-content\/uploads\/sites\/14\/2022\/10\/balance.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2390\" src=\"http:\/\/student-activity.binus.ac.id\/himmat\/wp-content\/uploads\/sites\/14\/2022\/10\/balance.png\" alt=\"\" width=\"321\" height=\"251\" \/><\/a><br \/>\nContoh <\/b><b><i>balance<\/i><\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Untuk memperbaiki tree yang melanggar sifat <\/span><em><span style=\"font-weight: 400\">self-balancing tree<\/span><\/em><span style=\"font-weight: 400\">, maka dilakukanlah <\/span><em><span style=\"font-weight: 400\">rotation<\/span><\/em><span style=\"font-weight: 400\">. <\/span><span style=\"font-weight: 400\">Ketika melakukan <em>rotation<\/em> pada <\/span><i><span style=\"font-weight: 400\">node X, Y, <\/span><\/i><span style=\"font-weight: 400\">dan <\/span><i><span style=\"font-weight: 400\">Z<\/span><\/i><span style=\"font-weight: 400\">, <\/span><i><span style=\"font-weight: 400\">node<\/span><\/i> <i><span style=\"font-weight: 400\">Y <\/span><\/i><span style=\"font-weight: 400\">sebagai titik putar dikatakan sebagai <\/span><i><span style=\"font-weight: 400\"><em>pivot <\/em>node<\/span><\/i><span style=\"font-weight: 400\">, sehingga putaran bertumpu pada <\/span><i><span style=\"font-weight: 400\">pivot node<\/span><\/i><span style=\"font-weight: 400\"> tersebut. <\/span><span style=\"font-weight: 400\">Untuk kasus yang tidak berat sebelah (<\/span><em><span style=\"font-weight: 400\">balance factor<\/span><\/em><i><span style=\"font-weight: 400\"> node<\/span><\/i><span style=\"font-weight: 400\"> yang tidak <\/span><em><span style=\"font-weight: 400\">balance <\/span><\/em><span style=\"font-weight: 400\">berbeda tanda dengan <\/span><em><span style=\"font-weight: 400\">balance <\/span><\/em><i><span style=\"font-weight: 400\">factor<\/span><\/i><span style=\"font-weight: 400\"> anak <\/span><i><span style=\"font-weight: 400\">node<\/span><\/i><span style=\"font-weight: 400\">). Maka dilakukan <\/span><em><span style=\"font-weight: 400\">double rotations<\/span><\/em><span style=\"font-weight: 400\">.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">Referensi<\/span><\/p>\n<p><a href=\"https:\/\/www.tutorialspoint.com\/data_structures_algorithms\/avl_tree_algorithm.html\"><span style=\"font-weight: 400\">https:\/\/www.tutorialspoint.com\/data_structures_algorithms\/avl_tree_algorithm.html\u00a0<\/span><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>AVL Tree adalah salah satu bentuk self-balancing tree dari sebuah binary search tree. AVL Tree dikatakan balance (seimbang) apabila nilai absolut dari balance factor dalam masing-masing node tidak melebihi satu. Apabila nilai tersebut lebih dari satu, maka node tersebut akan dinyatakan sebagai tidak seimbang. Karena terdapat sebuah node yang tidak seimbang\u00a0maka node tersebut telah melakukan [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":2392,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[87,25,66,86,88],"class_list":["post-2388","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","tag-avl-tree","tag-computer-science","tag-node","tag-rotation","tag-tree"],"_links":{"self":[{"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/posts\/2388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/comments?post=2388"}],"version-history":[{"count":1,"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/posts\/2388\/revisions"}],"predecessor-version":[{"id":2393,"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/posts\/2388\/revisions\/2393"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/media\/2392"}],"wp:attachment":[{"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/media?parent=2388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/categories?post=2388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/student-activity.binus.ac.id\/himmat\/wp-json\/wp\/v2\/tags?post=2388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}