Posts

Showing posts with the label HeapSort

Managing the conference rooms with balancing the occupancy percentage

Problem Given the list of conference rooms with the capacity and the target occupancy percentages, write the program that maintains the balanced occupancy percentage across the rooms. Input: list of rooms { [30, 0.6], [50, 0.7], [90, 0.4]}, number of guests Output: list of rooms with balanced occupancy percentages across the rooms

Reordering the values in the binary tree.

Problem Given the tree as below, write the code that fixes the order of the tree such that the value of the parent is always larger than the value of the children (left, right) struct node {     int value;     node *left;     node *right;     node(int v):value(v),right(0),left(0){) } Input: root node                2             /    \            5       10           / \     /  \          4   3   8    9                    / \      /  \                 12  6  1   11 The expected result will be:            12       ...