+ All Categories
Home > Documents > Data structure

Data structure

Date post: 01-Jan-2016
Category:
Upload: colton-wise
View: 16 times
Download: 0 times
Share this document with a friend
Description:
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 - PowerPoint PPT Presentation
13
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE nformation Technology , 3’rd Semester Lecture 15 : Trees Operations
Transcript

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

6

Presented & Prepared by: Mahmoud R. Alfarra

Finding the Maxi. Value in BST Implementation IN BST

Finding a Node in BST7

Presented & Prepared by: Mahmoud R. Alfarra

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.

Removing a Leaf Node From a BST

11

Presented & Prepared by: Mahmoud R. Alfarra

Emank X Mezank !!

يقول النبي صلى الله عليه وسلم:

كفى بالمرء كذبًـا كفى بالمرء كذبًـا أن يحدَث< بكل ما أن يحدَث< بكل ما

سمـعسمـع

Next Lecture

Removing nodes from a Binary Search Tree


Recommended