Huffman encoding

Can you please send the file used in huffmanEncoding code video as it has not been done before in any videoi

@hemantkrjain2003_41a7cca4cdd1056f I am sending you my .java for Huffman Encoding you can use this. Download files from the below G-Drive link :

Brother i want the source code of the heap file used in this code to initialize the heap

@hemantkrjain2003_41a7cca4cdd1056f This file contains everything bro …Look for a comment : //Making min heap
That’s where the code for minheap starts.

In the video of huffman encoding ‘HeapminHeap=new Heap<>(true);’
this statement is used and i want the source code of this Heap working mentioned in the quoted line

@hemantkrjain2003_41a7cca4cdd1056f :

import java.util.ArrayList;

public class Heap<T extends Comparable<T>> {
ArrayList<T> data = new ArrayList<>();
	public void add(T item) {
		upheapify(data.size() - 1);
	private void upheapify(int ci) {
		//We dont need any basecase because whenever we are in top element of heap it will give pi = ci therefore condition will be false
		int pi = (ci - 1)/2;
		if(data.get(ci).compareTo(data.get(pi))<0) {
	private void swap(int i, int j) {
		T ith = data.get(i);
		T jth = data.get(j);
		data.set(i, jth);
		data.set(j, ith);
	public void display() {
	public int size() {
	public boolean isEmpty() {
		return this.size() == 0;
	public T remove() {
		//highest priority element will be deleted
		T ans = data.remove(size()-1);
		return ans;
	private void downHeapify(int pi) {
		//in add we used ci but here we have pi
		int rci = 2*pi + 2;
		int lci = 2*pi + 1;
		int mini = pi;
		//We are comparing value of rc and lc with parent because parent can also be less than rc or lc therefore at last
		//Both rc and lc are compared then if mini = pi this means parent is right in its position
		//no need to do anything else
		//otherwise make a recursive call
		//lci < size()is also a check for base case. since there will not be any code for pi = mini
		if(lci < && > 0) {
			mini = lci;
		if(rci < && > 0) {
			mini = rci;
		if(pi != mini) {
			//if mini != pi that means one of the if condition has updated the value of mini by any child
	public T get() {

Bro i want the source code of this file used in video

@hemantkrjain2003_41a7cca4cdd1056f Look at it carefully it the same code that I sent you.

1 Like