Pages

Showing posts with label Algorithm. Show all posts
Showing posts with label Algorithm. Show all posts

Sunday, February 12, 2012

Binary Search Tree


In computer science, a binary search tree (BST), which may sometimes also be called an ordered or sorted binary tree, is a node-based binary tree data structure which has the following properties:
  • The left subtree of a node contains only nodes with keys less than the node's key.
  • The right subtree of a node contains only nodes with keys greater than the node's key.
  • Both the left and right subtrees must also be binary search trees.


A basic and a quick video, might be messed up too in some places, explaining the basics of a Binary Search Tree.



Monday, January 24, 2011

Codechef Puzzle: NUMGAME


So I encounter this interesting problem NUMGAME at Codechef. This is in the list of easy problems.
At first I was lost after looking the problem and could not think of how to solve it but when I came to thinking about it, it seems that it is quite easy.

Hints: (Obvious but important)

1) An odd number is always formed by the multiplication of two odd numbers.
2) If you substract an odd number from an odd number then it gives you an even number.