| | |
splaying algorithm
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
hi, i recently heard about splay trees
and i am searching for a splaying algorithm...,i ve found one
but it isn't very easy to understand....so if anyone has to share an implementation followed by a short explanation it would be great!
PS: i 've undestand the basic concepts like zig, zig-zig, zig-zag but still the implementations out on the web utilize things that don't make much sense...
here is an alogorithm i found that i don't understand
if anyone can shed some light, i would be gratefull!
and i am searching for a splaying algorithm...,i ve found one
but it isn't very easy to understand....so if anyone has to share an implementation followed by a short explanation it would be great!
PS: i 've undestand the basic concepts like zig, zig-zig, zig-zag but still the implementations out on the web utilize things that don't make much sense...
here is an alogorithm i found that i don't understand
c++ Syntax (Toggle Plain Text)
void SplayTree::splay( const int & x, BinaryNode* t ) { BinaryNode *leftTreeMax, *rightTreeMin; static BinaryNode header; header.left = header.right = nullNode; leftTreeMax = rightTreeMin = &header; nullNode->element = x; // Guarantee a match for( ; ; ) if( x < t->element ) { if( x < t->left->element ) rotateWithLeftChild( t ); if( t->left == nullNode ) break; // Link Right rightTreeMin->left = t; rightTreeMin = t; t = t->left; } else if( t->element < x ) { if( t->right->element < x ) rotateWithRightChild( t ); if( t->right == nullNode ) //to neo t pou irthe apo to rotate.... break; // Link Left leftTreeMax->right = t; leftTreeMax = t; t = t->right; } else break; leftTreeMax->right = t->left; rightTreeMin->left = t->right; t->left = header.right; t->right = header.left; }
if anyone can shed some light, i would be gratefull!
![]() |
Similar Threads
- Help with LR parser algorithm (Java)
- round robin algorithm (Computer Science)
- Round Robin Algorithm Simulation (C++)
- Eigenface Algorithm (Computer Science)
- Algorithm for checking contiguous blocks (C)
Other Threads in the C++ Forum
- Previous Thread: How to sort alphabet
- Next Thread: Plz Solve this problem...
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count database delete deploy developer dll download dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph gui homeworkhelp iamthwee ifstream image input int java lib library linker list loop looping loops map math matrix memory multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





