10.09.2013 Views

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

1. Advanced Data Structure using C++

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

LECTURE NOTES OF ADVANCED DATA STRUCTURE (MT-CSE 110)<br />

(Van Wyk, Christopher J. <strong>Data</strong> <strong>Structure</strong>s and C Programs, Addison‐Wesley,<br />

1988, p. 175. ISBN 978‐0‐201‐16116‐8.)<br />

A threaded binary tree makes it possible to traverse the values in the binary<br />

tree via a linear traversal that is more rapid than a recursive in‐order traversal.<br />

It is also possible to discover the parent of a node from a threaded binary tree,<br />

without explicit use of parent pointers or a stack, albeit slowly. This can be<br />

useful where stack space is limited, or where a stack of parent pointers is<br />

unavailable (for finding the parent pointer via DFS).<br />

This is possible, because if a node (k) has a right child (m) then m's left pointer<br />

must be either a child, or a thread back to k. In the case of a left child, that left<br />

child must also have a left child or a thread back to k, and so we can follow m's<br />

left children until we find a thread, pointing back to k. The situation is similar for<br />

when m is the left child of k<br />

Multiway Search Trees<br />

A multiway search tree is one with nodes that have two or more children.<br />

Within each node is stored a given key, which is associated to an item we wish<br />

to access through the structure.<br />

Given this definition, a binary search tree is a multiway search tree.<br />

More Formal Definition<br />

Let T be a multiway search tree, then T has the following properties:<br />

• T is ordered, meaning that the all the elements in subtrees to the left of<br />

an item are less than the item itself, and all the elements in subtrees to<br />

the right of an item are greater.<br />

• Each internal node of T has at least 2 children.<br />

• Each d‐node (node with d children) v of T, with children v1,...,vd stores d‐1<br />

items (k1, x1),...,(kd‐1, xd‐1). Where the ki's are keys and xi is the element<br />

associated with key number i.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

Assist Prof., CSE, H.C.T.M (Kaithal) Page ‐ 207 ‐

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!