dr inż. Maciej Kraszewski

inżynier

menedżer R&D

nauczyciel akademicki

dr inż. Maciej Kraszewski

inżynier

menedżer R&D

nauczyciel akademicki

Methods of programming. Recursion – part 2

The following tasks should be solved in any programming language. Of course, the condition is that the language supports recursion and object oriented programming.

Tasks to accomplish

Task 1 – Binary search tree

Implement the class for a binary search tree. Keys of tree nodes should be simple integer numbers. Your class should provide the following public operations (the prototypes are written in C# but you may transfer them to any language):

  1. void Add(int key) – adds element to the tree.
  2. void Print() – prints all elements in the tree in a sorted order.
  3. Boolean Search(int key) – returns true if the given key is inside the tree and false otherwise.