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 />

Likewise, the following is NOT an AVL tree. Note that negative values arise<br />

when the left sub‐tree is taller than the right sub‐tree.<br />

B<br />

A C<br />

F (1 – 3 = ‐2)<br />

D G<br />

F<br />

On the other hand, although not perfectly balanced the following is an AVL tree.<br />

Balances of 0 are not shown.<br />

10 (‐1)<br />

5 (‐1) 15 (‐1)<br />

3 (‐1) 6 (1) 13 (‐1) 20<br />

2 (‐1) 4 8 12<br />

1<br />

C. Node rotation.<br />

In order to maintain an AVL tree as an AVL tree, the normal insertion and<br />

deletion algorithms have to be supplemented with “node rotation” procedures.<br />

There are right rotations, left rotations and double rotations.<br />

<strong>1.</strong> A left rotation.<br />

Prepared By :­<br />

Er. Harvinder Singh<br />

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

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

Saved successfully!

Ooh no, something went wrong!