Binary Search Trees and Recursion Lab in Computer Science II, Lab Reports of Data Structures and Algorithms

Instructions for lab 9 of computer science ii (csci 1200) focusing on binary search trees and recursion. Students are expected to have reviewed lectures 16 and 17 before starting. The lab involves examining the provided code in cs2set.h and test_cs2set.cpp, implementing a non-recursive replacement for the find function, and writing the copy_tree private member function for the copy constructor and assignment operator.

Typology: Lab Reports

Pre 2010

Uploaded on 08/09/2009

koofers-user-6ru
koofers-user-6ru 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Science II CSci 1200
Lab 9
Binary Search Trees and Recursion
Introduction
This lab explores binary search trees and their implementation in the cs2set
class, along with the use of recursive functions to manipulate binary search
trees. Once you have a basic understanding of trees, the actual code that you
have to write for the lab is quite short. Review the notes from Lectures 16
and 17 prior to starting.
Download the files:
http://www.cs.rpi.edu/academics/courses/spring07/cs2/lab09/cs2set.h
http://www.cs.rpi.edu/academics/courses/spring07/cs2/lab09/test_cs2set.cpp
Then, turn off all network connections.
Examine the code in cs2set.h and testset.cpp. The former contains
the implementation discussed in Lectures 16 and 17, including the functions
implemented in lecture as exercises. The latter contains code for testing
the implementation. Some of this has been commented out because all the
functions have not yet been implemented.
Checkpoints
1. The implementation of find provided in cs2set.h is recursive. Im-
plement and test a non-recursive replacement for this function.
2. The implementation of the copy constructor and the assignment op-
erator is not yet complete because each depends on a private member
function called copy_tree, the body of which has not yet been written.
Write copy_tree and then test to see if it works by “uncommenting”
the appropriate code from the main function.

Partial preview of the text

Download Binary Search Trees and Recursion Lab in Computer Science II and more Lab Reports Data Structures and Algorithms in PDF only on Docsity!

Computer Science II — CSci 1200

Lab 9

Binary Search Trees and Recursion

Introduction

This lab explores binary search trees and their implementation in the cs2set class, along with the use of recursive functions to manipulate binary search trees. Once you have a basic understanding of trees, the actual code that you have to write for the lab is quite short. Review the notes from Lectures 16 and 17 prior to starting. Download the files:

http://www.cs.rpi.edu/academics/courses/spring07/cs2/lab09/cs2set.h http://www.cs.rpi.edu/academics/courses/spring07/cs2/lab09/test_cs2set.cpp

Then, turn off all network connections. Examine the code in cs2set.h and testset.cpp. The former contains the implementation discussed in Lectures 16 and 17, including the functions implemented in lecture as exercises. The latter contains code for testing the implementation. Some of this has been commented out because all the functions have not yet been implemented.

Checkpoints

  1. The implementation of find provided in cs2set.h is recursive. Im- plement and test a non-recursive replacement for this function.
  2. The implementation of the copy constructor and the assignment op- erator is not yet complete because each depends on a private member function called copy_tree, the body of which has not yet been written. Write copy_tree and then test to see if it works by “uncommenting” the appropriate code from the main function.