style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@ -35,11 +35,7 @@ public class Huffman {
// base case; if the left and right are null
// then its a leaf node and we print
// the code s generated by traversing the tree.
if (
root.left == null &&
root.right == null &&
Character.isLetter(root.c)
) {
if (root.left == null && root.right == null && Character.isLetter(root.c)) {
// c is the character in the node
System.out.println(root.c + ":" + s);
@ -60,15 +56,12 @@ public class Huffman {
// number of characters.
int n = 6;
char[] charArray = { 'a', 'b', 'c', 'd', 'e', 'f' };
int[] charfreq = { 5, 9, 12, 13, 16, 45 };
char[] charArray = {'a', 'b', 'c', 'd', 'e', 'f'};
int[] charfreq = {5, 9, 12, 13, 16, 45};
// creating a priority queue q.
// makes a min-priority queue(min-heap).
PriorityQueue<HuffmanNode> q = new PriorityQueue<HuffmanNode>(
n,
new MyComparator()
);
PriorityQueue<HuffmanNode> q = new PriorityQueue<HuffmanNode>(n, new MyComparator());
for (int i = 0; i < n; i++) {
// creating a Huffman node object