Beruflich Dokumente
Kultur Dokumente
Lecture No.
16
___________________________________________________________________
Data Structures
Lecture No. 16
Reading Material
Data Structures and Algorithm Analysis in C++
Chapter. 4
4.3 (all sub sections)
Summary
Inorder
successor
Page 1 of 18
We will get the inorder successor of node 3 i.e. number 4. Therefore we will connect
Page 2 of 18
Page 3 of 18
Page 4 of 18
Page 5 of 18
Lets see the code of the binary search tree (BST). We put the interface in the .h file.
We also have the state variable in addition to the public and private methods of the
class in it. In the public methods, the user of the class calls with their objects. Lets
create a .h file for binary search tree and the objects of binary search tree obtained
from the factory will use the attributes defined in the .h file. Here is the .h file.
/* binarysearchtree.h file contains the interface of binary search tree (BST) */
#ifndef _BINARY_SEARCH_TREE_H_
#define _BINARY_SEARCH_TREE_H_
#include <iostream.h>
// For NULL
Page 6 of 18
Sample Program
Here is the code of the program. BinarySearchTree.h file.
/* This file contains the declaration of binary node and the binary search tree */
#ifndef BINARY_SEARCH_TREE_H_
#define BINARY_SEARCH_TREE_H_
#include <iostream.h>
// For NULL
Page 9 of 18
Page 14 of 18
Page 18 of 18