java语言程序设计基础篇 课后答案

  • I5_833761
    了解作者
  • 641.2KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-05 08:42
    上传日期
A computer is an electronic device that stores and processes data. A computer includes both hardware and software. In general, hardware is the physical aspect of the computer that can be seen, and software is the invisible instructions that control the hardware and make it work.
java复习答案.zip
  • java复习答案
  • 33review.doc
    50.5KB
  • 14review(AbstractClassAndInterfaces).doc
    85.5KB
  • 27review.doc
    72.5KB
  • 05review.doc
    86KB
  • 37review(DatabaseProgramming).doc
    53.5KB
  • 07reviewMultidimensionalArrays.doc
    81.5KB
  • 22review(Collections).doc
    59KB
  • 32review.doc
    40KB
  • 10review.doc
    41.5KB
  • 04review.doc
    78.5KB
  • 19review(BinaryIO).doc
    78KB
  • 16review(EventDrivenProgramming).doc
    43KB
  • 47review(RBTrees).doc
    56.5KB
  • 03review.doc
    103KB
  • 24review(Sorting).doc
    163.5KB
  • 09reviewStringTextIO.doc
    81KB
  • 42review(webservices).doc
    43KB
  • 41review(JSF).doc
    46KB
  • 13review(ExceptionHandling).doc
    43.5KB
  • 20review(Recursion).doc
    73.5KB
  • 43review(rmi).doc
    63.5KB
  • 28review.doc
    88.5KB
  • 31review.doc
    44.5KB
  • 02review.doc
    85KB
  • 12review(GUIBasics).doc
    64KB
  • 08review.doc
    60KB
  • 29review.doc
    51.5KB
  • 11review(InheritanceAndPolymorphism).doc
    66.5KB
  • 21review(Generics).doc
    60KB
  • 38review(advancedJDBC).doc
    49KB
  • 44review(Java2D).doc
    51KB
  • 25review(ListStackQueue).doc
    64.5KB
  • 45review(AVL).doc
    275.5KB
  • 36review.doc
    66KB
  • 01review.doc
    74.5KB
  • 06review.doc
    149KB
  • 15review(Graphics).doc
    48.5KB
  • 30review.doc
    38.5KB
  • 18review(AppletsAndMultimedia).doc
    46.5KB
  • 46review(2-4Trees).doc
    44KB
  • 26review(BST).doc
    114KB
  • 48review(Hashing).doc
    50.5KB
  • 35review.doc
    47.5KB
  • 39review(Servlets).doc
    54.5KB
  • 23reviewAlgorithmEfficiency.doc
    74KB
  • 34review.doc
    44.5KB
  • 17review(CreatingUserInterfaces).doc
    64KB
  • 40review(JSP).doc
    47.5KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/637b479c9f0e6d0d65242185/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/637b479c9f0e6d0d65242185/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">Chapter <span class="_ _0"></span>45<span class="_ _0"></span> AVL T<span class="_ _0"></span>rees<span class="_ _0"></span> and<span class="_ _0"></span> Splay<span class="_ _0"></span> T<span class="_ _0"></span>rees</div><div class="t m0 x1 h4 y3 ff2 fs1 fc1 sc0 ls0 ws0">1.<span class="_ _1"> </span>AVL trees are well-balanced. In an AVL tree, the difference </div><div class="t m0 x1 h4 y4 ff2 fs1 fc1 sc0 ls0 ws0">between the heights of two subtrees for every node is 0 or 1. </div><div class="t m0 x1 h4 y5 ff2 fs1 fc1 sc0 ls0 ws0">The <span class="ff3">balance factor</span> of a node is the height of its right subtree </div><div class="t m0 x1 h4 y6 ff2 fs1 fc1 sc0 ls0 ws0">minus the height of its left subtree. A node is said to be </div><div class="t m0 x1 h4 y7 ff3 fs1 fc1 sc0 ls0 ws0">balanced<span class="ff2"> if its balance factor is -1, 0, or 1. A node is said to </span></div><div class="t m0 x1 h4 y8 ff2 fs1 fc1 sc0 ls0 ws0">be <span class="ff3">left-heavy</span> if its balance factor is -1. A node is said to be </div><div class="t m0 x1 h4 y9 ff3 fs1 fc1 sc0 ls0 ws0">right-heavy<span class="ff2"> if its balance factor is +1.</span></div><div class="t m0 x2 h5 ya ff4 fs1 fc1 sc0 ls0 ws0">2.<span class="_ _2"> </span>If <span class="_ _0"></span>a node is not <span class="_ _0"></span>balanced after an <span class="_ _0"></span>insertion or <span class="_ _0"></span>deletion operation,<span class="_ _0"></span> you <span class="_ _0"></span>need to </div><div class="t m0 x3 h5 yb ff4 fs1 fc1 sc0 ls0 ws0">rebalance it. <span class="_ _0"></span>The <span class="_ _0"></span>process<span class="_ _3"></span> of <span class="_ _0"></span>rebalancing a <span class="_ _0"></span>node is called a <span class="_ _0"></span><span class="ff5">rotation</span>.<span class="_ _0"></span> There <span class="_ _0"></span>are four<span class="_ _0"></span> </div><div class="t m0 x3 h5 yc ff4 fs1 fc1 sc0 ls0 ws0">possible rotations: LL,<span class="_ _0"></span> <span class="_ _0"></span>LR, <span class="_ _0"></span>RR, and RL.</div><div class="t m0 x2 h4 yd ff2 fs1 fc1 sc0 ls0 ws0">An <span class="ff3">LL imbalance</span> occurs at a node A such that A has a balance</div><div class="t m0 x2 h4 ye ff2 fs1 fc1 sc0 ls0 ws0">factor -2 and a left child B with a balance factor -1 or 0. </div><div class="t m0 x2 h4 yf ff2 fs1 fc1 sc0 ls0 ws0">This type of imbalance can be fixed by performing a single </div><div class="t m0 x2 h4 y10 ff2 fs1 fc1 sc0 ls0 ws0">right rotation at A.</div><div class="t m0 x2 h5 y11 ff4 fs1 fc1 sc0 ls0 ws0">3.<span class="_ _2"> </span>In the <span class="_ _0"></span>BinaryTree <span class="_ _0"></span>class, the createNewNode() method <span class="_ _0"></span>creates a T<span class="_ _0"></span>reeNode object. </div><div class="t m0 x3 h5 y12 ff4 fs1 fc1 sc0 ls0 ws0">This method <span class="_ _0"></span>is defined protected <span class="_ _0"></span>in <span class="_ _0"></span>BinaryTree.<span class="_ _0"></span> It <span class="_ _0"></span>is overridden <span class="_ _0"></span>in the <span class="_ _0"></span>AVLT<span class="_ _0"></span>ree </div><div class="t m0 x3 h5 y13 ff4 fs1 fc1 sc0 ls0 ws0">class to create an AVLT<span class="_ _0"></span>reeNode. </div><div class="t m0 x2 h5 y14 ff4 fs1 fc1 sc0 ls0 ws0">4.<span class="_ _2"> </span>updateHeight(AVLTreeNode&lt;E&gt;) <span class="_ _0"></span>is invoked <span class="_ _0"></span>to update the <span class="_ _0"></span>height of <span class="_ _0"></span>a node.<span class="_ _0"></span> It is </div><div class="t m0 x3 h5 y15 ff4 fs1 fc1 sc0 ls0 ws0">invoked to <span class="_ _0"></span>rebalance the tree.<span class="_ _0"></span> balanceFactor is <span class="_ _0"></span>invoked to check the <span class="_ _0"></span>balance factor of<span class="_ _0"></span> </div><div class="t m0 x3 h5 y16 ff4 fs1 fc1 sc0 ls0 ws0">a node. It<span class="_ _0"></span> is invoked <span class="_ _0"></span>when a path <span class="_ _0"></span>is rebalanced. balancePath is invoked<span class="_ _0"></span> along the path</div><div class="t m0 x3 h5 y17 ff4 fs1 fc1 sc0 ls0 ws0">where a new <span class="_ _0"></span>node is inserted or <span class="_ _0"></span>a node is deleted.</div><div class="t m0 x2 h5 y18 ff4 fs1 fc1 sc0 ls0 ws0">5.<span class="_ _2"> </span> AVLTreeNode<span class="_ _0"></span> inherits fro<span class="_ _0"></span>m TreeNode.<span class="_ _0"></span> The <span class="_ _0"></span>height is a <span class="_ _0"></span>new data field <span class="_ _0"></span>defined <span class="_ _0"></span>in </div><div class="t m0 x3 h5 y19 ff4 fs1 fc1 sc0 ls0 ws0">AVLTreeNode.<span class="_ _0"></span> The data <span class="_ _0"></span>fields in <span class="_ _0"></span>TreeNode are <span class="_ _0"></span>left and <span class="_ _0"></span>right,<span class="_ _0"></span> pointing <span class="_ _0"></span>to the <span class="_ _0"></span>left and</div><div class="t m0 x3 h5 y1a ff4 fs1 fc1 sc0 ls0 ws0">right subtree.</div><div class="t m0 x2 h5 y1b ff4 fs1 fc1 sc0 ls0 ws0">6.<span class="_ _2"> </span>No.</div><div class="t m0 x2 h5 y1c ff4 fs1 fc1 sc0 ls0 ws0">7.</div></div></div><div class="pi" data-data='{"ctm":[1.568627,0.000000,0.000000,1.568627,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐