******** fig6.4a ********** PRIORITY_QUEUE create_pq( unsigned int max_elements ) { PRIORITY_QUEUE H; /*1*/ if( max_elements < MIN_PQ_SIZE ) /*2*/ error("Priority queue size is too small"); /*3*/ H = (PRIORITY_QUEUE) malloc( sizeof( struct heap_struct ) ); /*4*/ if( H == NULL ) /*5*/ fatal_error("Out of space!!!"); /* Allocate the array + one extra for sentinel */ /*6*/ H->elements=(element_type *)malloc((max_elements+1)*sizeof(element_type)); /*7*/ if( H->elements == NULL ) /*8*/ fatal_error("Out of space!!!"); /*9*/ H->max_heap_size = max_elements; /*10*/ H->size = 0; /*11*/ H->elements[0] = MIN_DATA; /*12*/ return H; }