Date post: | 01-Jan-2016 |
Category: |
Documents |
Upload: | colton-wise |
View: | 16 times |
Download: | 0 times |
DATA STRUCTURE
Presented By: Mahmoud Rafeek Alfarra
Using C#
MINISTRY OF EDUCATION & HIGHER EDUCATIONCOLLEGE OF SCIENCE AND TECHNOLOGYKHANYOUNIS- PALESTINE
Information Technology , 3’rd Semester
Lecture 15 :Trees Operations
Outline
Finding the Mini. & Maxi. Values Finding a Node in BST Removing a Leaf Node From a BST Emank X Mezank !!
Finding the Mini. Value in BST Due to the properties of a BST, the smallest
value in a BST will always be found at the last left child node of a subtree beginning with the left child of the root node.
3
Presented & Prepared by: Mahmoud R. Alfarra
The Minimumvalue
Finding the Mini. Value in BST
4
Presented & Prepared by: Mahmoud R. Alfarra
Let’s look at the code for the Node class first:
Implementation IN BST
Finding the Maxi. Value in BST
5
Presented & Prepared by: Mahmoud R. Alfarra
The largest value in a BST is found at the last right child
node of a subtree beginning with the right child of the
root node.
Implementation IN BST
The Minimumvalue
Removing Nodes8
Presented & Prepared by: Mahmoud R. Alfarra
For some cases, removing a node from a BST is almost
trivial.
For other cases, it is quite involved and demands that
we pay special care to the code we right.
Otherwise we run the risk of destroying the correct
hierarchical order of the BST.
Self Practice9
Presented & Prepared by: Mahmoud R. Alfarra
Develop an application which use a binary search tree to represent the information of students in our college.Using this application, we should perform the following tasks:• Insert new student •Find specific student• print the information of students using (InOrder, PreOrder, PostOrder traversing techniques)•Remove some leaves.
HW 1.1
Removing a Leaf Node From a BST10
Presented & Prepared by: Mahmoud R. Alfarra
Removing a leaf is the simplest case since there are no child nodes to take into consideration.
All we have to do is set each child node of the target node’s parent to null.
Of course, the node will still be there, but there will not be any references to the node.
Emank X Mezank !!
يقول النبي صلى الله عليه وسلم:
كفى بالمرء كذبًـا كفى بالمرء كذبًـا أن يحدَث< بكل ما أن يحدَث< بكل ما
سمـعسمـع