564 Programming and Data Structures
Explanation As usual, the arrays are declared by using arr[], inl[], in2[], in3[], in4[] and in5[], each
having a length of 5. By using len gth (); function, the length of each key is calculated and the keys are
placed in the appropriate index. The number which is to be searched is input through the keyboard.
Here, snum variable is declared. Its length is calculated by using le n g t h () ; and by knowing the
length it is searched in the hash table.
SUMMARY
The following concepts are described in this chapter.
1) A tree is a predetermined non-empty set of items in which one element is called the root and the
remaining items are divided into n>=0 disjoint subsets.
2) A binary tree is a fixed set of nodes. It may be empty or divided into three disjoint subsets. The
first subset is called the root of the tree. It contains a single element. The other two subsets are
called right and left subtrees of the main tree.
3) Types of binary tree: (a) strictly binary tree, (b) complete binary tree, (c) extended binary tree.
4) Like a list, a binary tree is also implemented in two ways: static implementation using arrays
and dynamic implementation using pointers (linked list).
5) The binary tree can be traversed in three w a y s: inorder, preorder and postorder.
6) A binary search tree is a binary tree in which each node of the tree contains a value larger than
all nodes of its left subtree and smaller than all nodes of its right subtree.
7) Searching and insertion operations are related with each other in a binary search tree. Before
performing insertion operation, the location where the element is to be inserted is to be identified.
8) Hashing techniques are described with program implementation. Different techniques such as
division, length dependent and mid-square methods are elaborated.
EXERCISES
A) Answer the following questions.
1) Explain trees and binary trees.
2) Explain types of binary trees.
3) How are binary tree represented?
4) Explain different types of traversing trees.
5) What is a binary search tree?
6) Explain hashing technique.
7) Explain how insertion and deletion operations are done with a binary search tree.
8) Write an algorithm for DFS of a spanning tree.
9) What is a spanning tree? Write BFS algorithm for a spanning tree.
10) What are the differences between arrays and linked lists?
11) List the steps of operation of length dependent hashing searching method.
12) Describe the operation of hashing technique with division method.