**hello , friends .....**

recently a question is came over my mind ..and i couldn't get any answer my self .....will you please help me about this ?

as we know a splay tree always rotate its children accordingly whenever any insertion is performed i.e. zig-zig,zag-zag,zig-zag,zag-zig . and main cause of this rotation is to keep its recently inserted child to place always in root node , so in this case insertion is very efficient.

and splay tree also not a height balanced tree. but its time complexity is o(log n), similar to all balanced tree. hence its called a balanced tree .

now , problem is that , if we insert our data like following in a binary search tree; then also we can get our recently inserted node at root place .... then why we need a splay tree ?? remember , splay tree not a height balanced tree ... i eagerly wait for your replies .. thanks

recently a question is came over my mind ..and i couldn't get any answer my self .....will you please help me about this ?

as we know a splay tree always rotate its children accordingly whenever any insertion is performed i.e. zig-zig,zag-zag,zig-zag,zag-zig . and main cause of this rotation is to keep its recently inserted child to place always in root node , so in this case insertion is very efficient.

and splay tree also not a height balanced tree. but its time complexity is o(log n), similar to all balanced tree. hence its called a balanced tree .

now , problem is that , if we insert our data like following in a binary search tree; then also we can get our recently inserted node at root place .... then why we need a splay tree ?? remember , splay tree not a height balanced tree ... i eagerly wait for your replies .. thanks

void insert_node(int x) { node *temp = create_node(x); if (root==NULL) {root=temp; return;} if(root->data<x) {temp->left = root; root = temp;} else {temp->right = root; root = temp;} }

This post has been edited by **andrewsw**: 19 November 2018 - 01:51 AM

Reason for edit:: removed ALL CAPS