I don't have the rep to comment, but i think the mistake is in heapify():
if(a[i]<largest)
{
should be:
if(a[i]<a[largest])
{
as others commented, please explain in more detail what doesn't work according to you next time you ask a question.