Binary Trees

Data Structures Library

A binary tree is made of nodes, where each node contains a “left” pointer, a “right” pointer, and a data element. The “root” pointer points to the topmost node in the tree. The left and right pointers recursively point to smaller “subtrees” on either side.

Stanford CS Education Library: introduces the basic concepts of binary trees, and works through a series of practice problems with solution code in C/C++ and Java. Binary trees have an elegant recursive pointer structure, so they are a good way to learn recursive pointer algorithms.

Basically the tutorial is divided into four basic sections. These sections include Binary Tree Structure, Binary Tree Problems, C Solutions and Java versions of Binary Tree. First section is the introduction of binary trees and the code that operates on them. Binary Tree Problems section contains practice problems in increasing order of difficulty. C Solutions section provides solution code to the problems for C and C++ programmers and Java versions shows how binary trees work in Java, with solution code.

You can find the complete tutorial here.

A pdf version is also available here.

  Binary Trees (49.7 KiB, 15,335 hits)

This is article #110 in the Stanford CS Education Library. This and other free CS materials are available at the library ( That people seeking education should have the opportunity to find it. This article may be used, reproduced, excerpted, or sold so long as this paragraph is clearly reproduced. Copyright 2000-2001, Nick Parlante,

M. Saqib: Saqib is Master-level Senior Software Engineer with over 14 years of experience in designing and developing large-scale software and web applications. He has more than eight years experience of leading software development teams. Saqib provides consultancy to develop software systems and web services for Fortune 500 companies. He has hands-on experience in C/C++ Java, JavaScript, PHP and .NET Technologies. Saqib owns and write contents on since 2004.
Related Post