code for heap structure