Category Archives: Tree

Array Representation Of Binary Heap

A Binary Heap is a Complete Binary Tree. A binary heap is typically represented as array. The representation is done as: The root element will be at Arr[0]. Below table shows indexes of other nodes for the ith node, i.e., Arr[i]: Arr[i/2] Returns the parent node Arr[(2*i)+1] Returns the left child node Arr[(2*i)+2] Returns the… Read More »



See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

Enumeration of Binary Trees

A Binary Tree is labeled if every node is assigned a label and a Binary Tree is unlabeled if nodes are not assigned any label. Below two are considered same unlabeled trees o o / \ / \ o o o o Below two are considered different labeled trees A C / \ / \… Read More »



See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

How to implement decrease key or change key in Binary Search Tree?

Given a Binary Search Tree, write a function that takes following three as arguments: 1) Root of tree 2) Old key value 3) New Key Value The function should change old key value to new key value. The function may assume that old key value always exists in Binary Search Tree. Example: Input: Root of… Read More »



See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.

Second largest element in BST

Given a Binary Search Tree(BST), find the second largest element. Examples: Input: Root of below BST 10 / 5 Output: 5 Input: Root of below BST 10 / \ 5 20 \ 30 Output: 20 Source: Microsoft Interview We strongly recommend you to minimize your browser and try this yourself first. The idea is similar… Read More »



See Placement Course for placement preparation, GATE Corner for GATE CS Preparation and Quiz Corner for all Quizzes on GeeksQuiz.