1 / 13

Data structure

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

colton-wise
Download Presentation

Data structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Using C# Information Technology , 3’rd Semester Data structure 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. Next Lecture Removing nodes from a Binary Search Tree

More Related