AVL tree/C: Difference between revisions

m
Fixed syntax highlighting.
m (Fixed syntax highlighting.)
 
Line 1:
===Code===
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Line 182:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>
Line 238:
 
<tt>AvlTree.h</tt>
<langsyntaxhighlight lang="c">#ifndef AVLTREE_INCLUDED
#define AVLTREE_INCLUDED
 
Line 260:
void *Node_GetData (Node n);
 
#endif</langsyntaxhighlight>
 
<tt>AvlTree.c</tt>
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include "AvlTree.h"
Line 860:
 
return n;
}</langsyntaxhighlight>
 
And here's the example which shows how to use the package. It creates in an endless loop random numbers between 0..999 and stores the number (the key) together with its square root (the value) in the tree. If an element with the given key is already in tree, it will be deleted.
 
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Line 924:
 
return 0;
}</langsyntaxhighlight>
 
After a number of iterations, the tree will look similar to this:
9,482

edits