Помоги в чём у меня ошибка: #include <iostream>
using namespace std;
struct dataFreq {
	char data;
	int freq;
};
struct minHeapNode {
	dataFreq *df;
	minHeapNode* left, * right;
};
struct minHeap {
	int size;
	int capacity;
	minHeapNode** arr;
};
minHeapNode* newNode(dataFreq *df) {
	minHeapNode* temp = new minHeapNode;
	temp->left = temp->right = nullptr;
	temp->df = df;
	return temp;
}
minHeap* createMinHeap(int capacity) {
	minHeap* mh = new minHeap;
	mh->size = 0;
	mh->capacity = capacity;
	mh->arr = new minHeapNode*[capacity];
	return mh;
}
void swapMinHeapNode(minHeapNode** a, minHeapNode** b) {
	minHeapNode* t = *a;
	*a = *b;
	*b = t;
}
void minHeapify(minHeap* mh, int idx) {
	int smallest = idx;
	int left = 2 * idx + 1;
	int right = 2 * idx + 2;
	if (left < mh->size && mh->arr[left]->df->freq < mh->arr[smallest]->df->freq) {
		smallest = left;
	}
	if (right < mh->size && mh->arr[right]->df->freq < mh->arr[smallest]->df->freq) {
		smallest = right;
	}
	if (smallest != idx) {
		swapMinHeapNode(&mh->arr[smallest], &mh->arr[idx]);
		minHeapify(mh, smallest);
	}
}
minHeapNode* extractMin(minHeap* mh) {
	minHeapNode* temp = mh->arr[0];
	mh->arr[0] = mh->arr[mh->size - 1];
	--mh->size;
	minHeapify(mh, 0);
	return temp;
}
void insertMinHeap(minHeap* mh, minHeapNode* mhNode) {
	++mh->size;
	int i = mh->size - 1;
	while (i && mhNode->df->freq < mh->arr[(i - 1) / 2]->df->freq) {
		mh->arr[i] = mh->arr[(i - 1) / 2];
		i = (i - 1) / 2;
	}
	mh->arr[i] = mhNode;
}
void buildMinHeap(minHeap* mh) {
	int n = mh->size - 1;
	for (int i = (n - 1) / 2; i >= 0; i--) {
		minHeapify(mh, i);
	}
}
void printArr(int* arr, int n) {
	for (int i = 0; i < n; i++) {
		cout << arr[i];
	}
	cout << "\n";
}
minHeap* createAndBuildMinHeap(dataFreq *df, int size) {
	minHeap* mh = createMinHeap(size);
	for (int i = 0; i < size; i++) {
		mh->arr[i] = newNode(df);
	}
	mh->size = size;
	buildMinHeap(mh);
	return mh;
}
minHeapNode* buildHuffmanTree(dataFreq *df,int size) {
	minHeapNode *left, *right, *top;
	minHeap* mh = createAndBuildMinHeap(df, size);
	while (mh) {
		left = extractMin(mh);
		right = extractMin(mh);
		dataFreq* ndf = new dataFreq;
		ndf->data = '$'; // $ специальное значение для внутренних нод
		ndf->freq = left->df->freq + right->df->freq;
		top = newNode(ndf);
		top->left = left;
		top->right = right;
		insertMinHeap(mh, top);
	}
	return extractMin(mh);
}
void printCodes(minHeapNode* root, int* arr, int top) {
	if (root->left) {
		arr[top] = 0;
		printCodes(root->left, arr, top + 1);
	}
	if (root->right) {
		arr[top] = 1;
		printCodes(root->right, arr, top + 1);
	}
	if (!(root->left) && !(root->right)) { // если это нода листья тогда она содержит вводимый символ
		cout << root->df->data << ": ";
		printArr(arr, top);
	}
}
void huffmanCodes(dataFreq *df, int size) {
	minHeapNode* root = buildHuffmanTree(df, size);
	int arr[256], top = 0;
	printCodes(root, arr, top);
}
int main() {
	const char* str = "beep boop beer!";
	dataFreq freqTable[256]; // в ASCII 256 символов
	int count = 0;
	for (int i = 0; str[i] != '\0'; i++) {
		bool found = false;
		for (int j = 0; j < count; j++) {
			if (str[i] == freqTable[j].data) {
				freqTable[j].freq++;
				found = true;
				break;
			}
		}
		if (!found) {
			freqTable[count].data = str[i];
			freqTable[count].freq = 1;
			count++;
		}
	}
	for (int i = 0; i < count; i++) {
		cout << freqTable[i].data << ' ' << freqTable[i].freq << '\n';
	}
    huffmanCodes(freqTable,count);
	return 0;
}