0% found this document useful (0 votes)
34 views3 pages

Binary Seach Tree Question

The document contains two questions about binary search trees. Question 1 asks the reader to (a) draw a diagram showing how certain data items would be stored in a binary search tree in a given order, (b) circle the root node, and (c) list the data items that would need to be accessed to search for a specific item. Question 2 (a) asks the reader to draw a diagram showing how a different set of data items would be stored in a binary search tree in a given order, and (b) asks the reader to complete a trace table showing the steps taken to search for an item in a binary search tree represented by arrays.

Uploaded by

User.9463820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views3 pages

Binary Seach Tree Question

The document contains two questions about binary search trees. Question 1 asks the reader to (a) draw a diagram showing how certain data items would be stored in a binary search tree in a given order, (b) circle the root node, and (c) list the data items that would need to be accessed to search for a specific item. Question 2 (a) asks the reader to draw a diagram showing how a different set of data items would be stored in a binary search tree in a given order, and (b) asks the reader to complete a trace table showing the steps taken to search for an item in a binary search tree represented by arrays.

Uploaded by

User.9463820
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Question 1.

A binary search tree is a data structure where items of data are stored such that they can
be searched for quickly and easily.

The following data items are to be entered into a binary search tree in the order given:

Louise, Peter, Robert, Christine, Alan, Leslie, Maria

(a) Draw a diagram to show how these values will be stored in the tree.

(4)

(b) Circle the root node in your diagram.


(1)

(c) If Maria is being searched for in this binary tree, list the data items which have to be
accessed.

___________________________________________________________________
(1)
(Total 6 marks)

Question 2.

(a) The series of characters J, F, H, U, S, X, T are to be entered into a binary search


tree in the order given. Draw a diagram to show how these values will be stored.

(4)

(b) The following data are held in arrays Data, L and R:


Using the arrays above, dry-run the following pseudo-code by completing the trace
table opposite:

Item ← ‘T’
Ptr ←1
WHILE Data[Ptr] < > Item DO
PRINT Data[Ptr]
IF Data[Ptr] > Item
THEN Ptr ← L[Ptr]

ELSE Ptr ← R[Ptr]


ENDIF
ENDWHILE
PRINT Data[Ptr]

Trace Table:

Item Ptr Printed Output

‘T’ 1 ‘J’

(6)
(Total 10 marks

You might also like