Presentation is loading. Please wait.

Presentation is loading. Please wait.

Presented By: Mahmoud Rafeek Alfarra

Similar presentations


Presentation on theme: "Presented By: Mahmoud Rafeek Alfarra"— Presentation transcript:

1 Presented By: Mahmoud Rafeek Alfarra
MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Data structure Using C# Information Technology , 3’rd Semester Lecture 15: Trees Operations Presented By: Mahmoud Rafeek Alfarra

2 Outline Finding the Mini. & Maxi. Values Finding a Node in BST
Removing a Leaf Node From a BST Emank X Mezank !!

3 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. The Minimum value Presented & Prepared by: Mahmoud R. Alfarra

4 Finding the Mini. Value in BST
Implementation IN BST 4 Let’s look at the code for the Node class first: Presented & Prepared by: Mahmoud R. Alfarra

5 Finding the Maxi. Value in BST
Implementation IN BST 5 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. The Minimum value Presented & Prepared by: Mahmoud R. Alfarra

6 Finding the Maxi. Value in BST
Implementation IN BST 6 Presented & Prepared by: Mahmoud R. Alfarra

7 Finding a Node in BST 7 Presented & Prepared by: Mahmoud R. Alfarra

8 Removing Nodes 8 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. Presented & Prepared by: Mahmoud R. Alfarra

9 Self Practice 9 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 Presented & Prepared by: Mahmoud R. Alfarra

10 Removing a Leaf Node From a BST
10 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. Presented & Prepared by: Mahmoud R. Alfarra

11 Removing a Leaf Node From a BST
11 Presented & Prepared by: Mahmoud R. Alfarra

12 كفى بالمرء كذبـًا أن يحدثَ بكل ما سمـع
Emank X Mezank !! يقول النبي صلى الله عليه وسلم: كفى بالمرء كذبـًا أن يحدثَ بكل ما سمـع

13 Removing nodes from a Binary Search Tree
Next Lecture Removing nodes from a Binary Search Tree


Download ppt "Presented By: Mahmoud Rafeek Alfarra"

Similar presentations


Ads by Google