Contents

Page No.

Abstract List of Symbols and Abbreviations List of Figures List of Tables

V VI VII VII

1. Introduction 1.1 1.2 General Organization of the Thesis

1 1 3 4 4 4 5 5 7 9 9 11 15 21 22 22 24 30 31

2. Preliminaries 2.1. 2.2. 2.3. Introduction Terminology and Notations Path complexity of a class

2.3.1. Introduction 2.3.2. The class Stack 3. Path complexity of the class BST 3.1. 3.2. 3.3. 3.4. State representation of BST Insert and delete operations on BST Path Complexity analysis of the class BST Bounds on path complexity of the class BST

4. Program for computing path complexity of the class BST 4.1. 4.2. Array representation of Binary Tree Program Listing

5. Conclusion References

IV

Abstract

Path complexity of a program is defined as the number of program execution paths as a function of input size n. This notion of program complexity has been extended to complexity of a class as follows. Class had data members and data operations. The notion of state for the class is defined based on structural representation of a class. We are assuming only those data operations that change state of a class. The path complexity of a class is defined to be the number of valid input sequences, each of them containing n data operations. We have analyzed the path complexity of the class Binary Search Tree (BST) based on the algorithms for insert and delete data operations. Later we modify program for delete operation to facilitate determination of path complexity for the class BST. The bounds for the path complexity of the class BST are determined. A program is developed to obtain path complexity of the class BST.

V

List of Symbols and Abbreviations

CFG FSD BST Control Flow Graph Finite state diagram Binary Search Tree An array of n ≥ 0 elements. Path complexity of program A over all inputs of size n>0. Path complexity of the class BST by insert and delete algorithms. Path complexity of the class BST by insert and modified delete algorithms. The set of all possible valid inputs of size n over {insert, delete}operations. Number of valid input sequences of length n over {insert, delete} operations. Number of valid input sequences of length n over {insert, delete} operations containing exactly k delete operations. B(i,j) The number of ways of picking j unordered outcomes from i possibilities. The greatest integer less than or equal to x, where x is a real number. The smallest integer greater than or equal to x, where x is a real number.

A[1,n] P(A,n) P1(BST,n) P2(BST,n) All_Seq(n) S(n) S(n,k)

VI

List of Figures

Page No.

Figure 2.1 Figure 2.2 Figure 2.3 Figure 2.4 Figure 2.5 Figure 3.1 Figure 3.2 Figure 3.3 Figure 3.4 Figure 3.5 Figure 3.6 Figure 3.7 Figure 3.8 Figure 4.1 Figure 4.2

An example of BST T. State diagram of an example DFSA for counting from one to four. State diagram for a simple class. State diagram of a class stack. Recurrence to obtain P(n,k) Finite state Diagram for a class BST for n=3 nodes BST of order n Insert operation on BST Delete operation for case 1 Delete operation for case 2 BST with odd number of nodes. Execution Paths for input sequences (iii), (iid) and (idi). Modified delete operation Array representation of binary tree. Modified array representation of binary tree.

4 6 7

7

8 10 10 13 15 15 16 18 19 22 23

List of Tables

Page No.

Table 3.1 Table 3.2 Table 3.3 Table 4.1

Number of distinct BSTs on n nodes Approximation of P1(BST,n) for n Approximation of P2(BST,n) for n Path complexity output for P1(BST,5) and P2(BST,5).

11 18 20 29

VII

Chapter 1

Introduction

1.1.

General

A program is the lowest level unit in software. Program complexity measures are used to

give critical information about reliability and maintainability of a software system. Major effort spent in software is during maintenance and testing period. Various program complexity measures have been...