binary-search-tree.tex 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. \documentclass{article}
  2. \usepackage[pdftex,active,tightpage]{preview}
  3. \setlength\PreviewBorder{2mm}
  4. \usepackage{tikz}
  5. \usetikzlibrary{arrows,positioning, calc}
  6. \tikzstyle{vertex}=[draw,fill=black!15,circle,minimum size=18pt,inner sep=0pt]
  7. \begin{document}
  8. \begin{preview}
  9. \begin{tikzpicture}[very thick,level/.style={sibling distance=70mm/#1}]
  10. \node [vertex] (r){$17$}
  11. child {
  12. node [vertex] (a) {$9$}
  13. child {
  14. node [vertex] {$3$}
  15. child {
  16. node [vertex] {$-3$}
  17. child {node [vertex] {$-4$}}
  18. child {
  19. node [vertex] {$2$}
  20. child {
  21. node [vertex] {$2$}
  22. }
  23. }
  24. }
  25. child {
  26. node [vertex] {$8$}
  27. child {
  28. node [vertex] {$6$}
  29. child {
  30. node [vertex] {$5$}
  31. }
  32. child {
  33. node [vertex] {$7$}
  34. }
  35. }
  36. }
  37. }
  38. child {
  39. node [vertex] {$11$}
  40. child {
  41. node [vertex] {$17$}
  42. child {
  43. node [vertex] {$17$}
  44. }
  45. }
  46. }
  47. }
  48. child {
  49. node [vertex] {$19$}
  50. child {
  51. node [vertex] {$20$}
  52. }
  53. };
  54. \end{tikzpicture}
  55. \end{preview}
  56. \end{document}