chap file processing and external sorting input memory output figure replacement selection example after building the heaproot value is output and incoming value replaces it value is output nextreplaced with incoming value the heap is reorderedwith rising to the root value is output next incoming value is too small for this run and is placed at end of the arraymoving value to the root reordering the heap results in rising to the rootwhich is output next