C++ Programming Forum

Ask Question   UnAnswered
Home » Forum » C++ Programming       RSS Feeds

Replacement Selection

  Asked By: Bara    Date: Nov 22    Category: C++ Programming    Views: 4866

(Replacement Selection)
Program input:
* An unordered file containing N enumerable data (such as int, double, string etc.).
* B memory regions that can hold data, representing the buffer pool.
Program Output:
* N / 2D RUN files each containing "Approximately" 2B pieces of data.
The program should end correctly with different N and B values. In the buffer zone, you need to construct a HEAP scaffold like EXT-SORT.
I have been started with this code :::
using namespace std;
template<typename T>
void heapify(T H[],T N,T i) {
T largest = i;
T left = 2 * i + 1;
T right = 2 * i + 2;

if (left < N && H[left] > H[largest])
largest = left;

if (right < N && H[right] > H[largest])
largest = right;

if (largest != i) {
swap(&H[i], &H[largest]);
heapify(H, N, largest); }
template<typename T>
void swap(T& x, T& y) {
T temp = x;
x = y;
y = temp;

so anyone can continue it with me please.