CS2143-2144 Data Structures Quiz 4: Implementing Insert and Search Functions for BSTree, Exercises of Data Structures and Algorithms

The instructions and guidelines for quiz #4 of the cs2143-2144 data structures course, spring 2012. Students are required to implement the insert and search functions for a bstree (binary search tree) class. The quiz consists of 10 multiple-choice questions and has a time limit of 10 minutes.

Typology: Exercises

2011/2012

Uploaded on 07/11/2012

dharanidhar
dharanidhar 🇮🇳

4.2

(6)

58 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS2143-2144 Data Structures Spring 2012
Quiz # 4(13 March 2012)
Time 10 Minutes
Max. Marks 10
Name: Reg. No: ___
For the following binary search class, implement the insert and search functions.
class bstree
{
protected:
int *p; // array of values
int *f; // array of flag
unsigned int size;
public:
bstree(unsigned int s)
{ int i;
p = new int [s];
f = new int [s];
size = s;
for (i=0; i<s; ++i)
f[i] = 0;
}
int insert(int v); //insert value v in the BST, and return 1 if it is inserted properly
//otherwise return 0
int search(int v); // search value element v at the proper position in BST. if found
//return the index of the location where it is found. Otherwise,
//return -1
};
Docsity.com

Partial preview of the text

Download CS2143-2144 Data Structures Quiz 4: Implementing Insert and Search Functions for BSTree and more Exercises Data Structures and Algorithms in PDF only on Docsity!

CS2143-2144 Data Structures Spring 2012

Quiz # 4(13 March 2012)

Time 10 Minutes

Max. Marks 10

Name: Reg. No: ___

For the following binary search class, implement the insert and search functions.

class bstree { protected: int *p; // array of values int *f; // array of flag unsigned int size;

public: bstree(unsigned int s) { int i; p = new int [s]; f = new int [s]; size = s; for (i=0; i<s; ++i) f[i] = 0; }

int insert(int v); //insert value v in the BST, and return 1 if it is inserted properly //otherwise return 0 int search(int v); // search value element v at the proper position in BST. if found //return the index of the location where it is found. Otherwise, //return - };

Docsity.com