page320.html

来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 41 行

HTML
41
字号
<HTML><HEAD><TITLE>Implementing AVL Trees</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html4883" HREF="page321.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4881" HREF="page319.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4875" HREF="page319.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html4885" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION0010510000000000000000">Implementing AVL Trees</A></H2><P>Having already implemented a binary search tree class, <tt>BinarySearchTree</tt>,we can make use of much of the existing code to implement an AVL tree class.Program&nbsp;<A HREF="page320.html#progavlTreea"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> introduces the <tt>AVLTree</tt> classwhich extends the <tt>BinarySearchTree</tt> classintroduced in Program&nbsp;<A HREF="page311.html#progbinarySearchTreea"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.The <tt>AVLTree</tt> class inherits most of itsfunctionality from the binary tree class.In particular,it uses the inherited <tt>insert</tt> and <tt>withdraw</tt> methods!However, the inherited <tt>balance</tt>,<tt>attachKey</tt> and <tt>detachKey</tt> methods are overriddenand a number of new methods are declared.<P><P><A NAME="19440">&#160;</A><A NAME="progavlTreea">&#160;</A> <IMG WIDTH=575 HEIGHT=142 ALIGN=BOTTOM ALT="program19323" SRC="img1274.gif"  ><BR><STRONG>Program:</STRONG> <tt>AVLTree</tt> class <tt>__init__</tt> method.<BR><P><BR> <HR><UL> <LI> <A NAME="tex2html4886" HREF="page321.html#SECTION0010511000000000000000">Instance Attributes</A><LI> <A NAME="tex2html4887" HREF="page322.html#SECTION0010512000000000000000"><tt>__init__</tt> Method</A><LI> <A NAME="tex2html4888" HREF="page323.html#SECTION0010513000000000000000"><tt>adjustHeight</tt> and <tt>getHeight</tt> Methods    and <tt>balanceFactor</tt> Property</A></UL><HR><A NAME="tex2html4883" HREF="page321.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4881" HREF="page319.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4875" HREF="page319.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html4885" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright &#169; 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a>  All rights reserved.</ADDRESS></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?