KEMBAR78
University of Kwazulu Natal: School of Mathematics, Statistics & Computer Science | PDF
0% found this document useful (0 votes)
36 views2 pages

University of Kwazulu Natal: School of Mathematics, Statistics & Computer Science

This document provides instructions for a practical exam on data structures. It contains 3 questions: 1. Add new methods like breadth-first traversal and height to a Binary Search Tree (BST) class. This includes using recursion to search for an element. 2. Implement inorder traversal of a BST using a loop and stack instead of recursion. 3. Implement preorder traversal of a BST using a loop and stack instead of recursion.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views2 pages

University of Kwazulu Natal: School of Mathematics, Statistics & Computer Science

This document provides instructions for a practical exam on data structures. It contains 3 questions: 1. Add new methods like breadth-first traversal and height to a Binary Search Tree (BST) class. This includes using recursion to search for an element. 2. Implement inorder traversal of a BST using a loop and stack instead of recursion. 3. Implement preorder traversal of a BST using a loop and stack instead of recursion.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SCHOOL OF MATHEMATICS, STATISTICS &

COMPUTER SCIENCE

UNIVERSITY OF KWAZULU NATAL

WESTIVILLE CAMPUS

Practical V

COURSE CODE: COMP201 Data Structures

Examiner: Mr E. Jembere
Duration: open
Marks: 40 marks

Instructions

1. Attempt all questions.


2. Your solutions will be marked/assessed during the practical session on Tuesday, 5 September
2017. Please note that no marking will be done before or after the practical session.
3. Assessment will be done NOT only on your code, but also on your ability to explain your code.
Inability to explain your code will cost you all your marks for that question.
4. You are advised to come for the practical session almost done with all questions on this paper.
5. The stars against the questions indicate the level of difficulty of a question. The level of difficulty
is rated easy (no star), moderate (*), hard (**), or challenging (***).

1. *(Add new methods in BST) Add the following new methods in BST.
/** Displays the nodes in a breadth-first traversal */
public void breadthFirstTraversal()

/** Returns the height of this binary tree, i.e., the


* number of the nodes in the longest path of the root to a leaf */
public int height()

/** Returns true if the element is in the tree */


* Use recursion to search for an element*/
Public Boolean recursiveSearch(E e)

[5, 10, 5]

1|Page
2. *(Implement inorder traversal without using recursion) Implement the inorder method in
BST using a loop and stack instead of recursion.
[10]
3. *(Implement preorder traversal without using recursion) Implement the preorder method
in BST using a loop and a stack instead of recursion.
[10]

----------------------------------------------------------------------------------------------------------------

WISHING YOU ALL THE BEST

2|Page

You might also like