TreeSearchTree,Node - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

TreeSearchTree,Node

Description:

return(Tree) if ( Node.val Tree.val ) return ( TreeSearch(Tree.left,Node) ) else return ( TreeSearch(Tree.right,Node) ) } ???????? ?????????. TreeSearch(Tree,Node) ... – PowerPoint PPT presentation

Number of Views:74
Avg rating:3.0/5.0
Slides: 7
Provided by: mao5
Category:

less

Transcript and Presenter's Notes

Title: TreeSearchTree,Node


1
??? ?????
  • ????? ????
  • ???????? ????????
  • TreeSearch(Tree,Node)
  • if ( (Tree null) OR (Tree.val Node.val) )
  • return(Tree)
  • if ( Node.val
  • return ( TreeSearch(Tree.left,Node) )
  • else return ( TreeSearch(Tree.right,Node) )
  • ???????? ?????????
  • TreeSearch(Tree,Node)
  • while ( (Tree null) AND (Node.val
    Tree.val) )
  • if (Node.val
  • Tree Tree.left
  • else Tree Tree.right
  • return ( Tree )
  • ??? ???? ?

2
??? ????? ????
  • ????? ???????
  • TreeMin(Tree)
  • while (Tree.left Null)
  • Tree Tree.left
  • return ( Tree )
  • ??? ???? ?
  • ????? ???????
  • TreeMax(Tree)
  • while (Tree.right Null)
  • Tree Tree.right
  • return ( Tree )
  • ??? ???? ?

3
??? ????? ????
  • ????? ??? ???????? ????? ?? ?????? ????? ?
  • ?. 363 , 397 , 344 , 330 , 398 , 401 , 252 , 2
  • ?. 363 , 245 , 912 , 240 , 911 , 202 , 925
  • ?. 363 , 278 , 381 , 382 , 266 , 219 , 387 ,
    293 , 2

4
?????? ?? ????
  • ??? ?? ???
  • IsFull(Tree)
  • if ( (Tree.leftnull) AND (Tree.rightnull)
    ) return (true)
  • if ( (Tree.leftnull) OR
    (Tree.rightnull) ) return ( false)
  • return ( IsFull(Tree.left) AND
    IsFull(Tree.right) )
  • ??? ?? ?????
  • IsComplete(Tree)
  • if (Treenull) return (true)
  • return ( IsComp(Tree.left) AND
    IsComp(Tree.right) AND

  • (Hight(Tree.left) Hight(Tree.right))
  • ????? ????? ???
  • Hight(Tree)
  • if (Tree null) return(-1)
  • else
  • return ( max(Higt(Tree.left),Hight(Tree.r
    ight)) 1 )

5
????
  • ????? ????? ??????? ???
  • Path(Tree,Node)
  • if (Tree Node) return ()
  • if (Tree.left Node) return (L)
  • if (Tree.right Node) return (R)
  • if (Tree null)
  • if ( Tree.left null ) LeftString
    Path(Tree.left,Node)
  • else LeftString null
  • if ( Tree.right null ) RightString
    PathTree.right,Node)
  • else RigthString null
  • if (LeftString) return (L LeftString)
  • if (RightString) return (R RightString)
  • return (null)

6
????
  • ????? ?? ????? ????? ???? ???????
  • FindFather(Tree,Node1,Node2)
  • Path1 Path(Tree,Node1)
  • Path2 Path(Tree,Node2)
  • while ( (Path1 Path2) AND (Path1) AND
    (Path2) )
  • if (Path1 L) Tree Tree.left
  • else if (Path1 R) Tree
    Tree.right
  • Path1
  • Path2
  • return ( Tree )
Write a Comment
User Comments (0)
About PowerShow.com