CS2143-2144 Data Structures Quiz 6: Implementing Functions for a Binary Tree, Exercises of Data Structures and Algorithms

The instructions for quiz #6 of the cs2143-2144 data structures course, spring 2012. Students are required to implement three functions (preordervisit, inordervisit, and postordervisit) for a binary tree class. The class definition and constructor are provided.

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 # 6(26 March 2012)
Time 10 Minutes
Max. Marks 10
Name: Reg. No: ___
For the following binary tree class (not a BST), implement the functions / methods
given in the class.
class btree
{
protected:
int *p; // array of values
int *f; // array of flag
unsigned int size;
public:
btree(unsigned int s)
{ int i;
p = new int [s];
f = new int [s];
size = s;
for (i=0; i<s; ++i)
f[i] = 0;
}
PreOrderVisit (int v) // A function to visit the tree in pre order, starting from
// node with index v,
InOrderVisit (int v) // A function to visit the tree in- In order, starting from node
// with index v,
PostOrderVisit (int v) // A function to visit the tree in post order, starting from
// node with index v,
};
Docsity.com

Partial preview of the text

Download CS2143-2144 Data Structures Quiz 6: Implementing Functions for a Binary Tree and more Exercises Data Structures and Algorithms in PDF only on Docsity!

CS2143-2144 Data Structures Spring 2012

Quiz # 6(26 March 2012)

Time 10 Minutes

Max. Marks 10

Name: Reg. No: ___

For the following binary tree class (not a BST), implement the functions / methods

given in the class.

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

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

PreOrderVisit (int v) // A function to visit the tree in pre order, starting from // node with index v, InOrderVisit (int v) // A function to visit the tree in- In order, starting from node // with index v, PostOrderVisit (int v) // A function to visit the tree in post order, starting from // node with index v, };

Docsity.com