Introduction of Hu-Tucker algorithm
Last Updated :
29 Jun, 2021
Introduction of the Hu-Tucker algorithm :
The Hu-Tucker algorithm helps to compress some order of blocks, assuming that you have a certain natural order for the following, then if the strings and the notes are taken into account, then taking them into account, they are sorted in numbers.
The question now arises about how we can build the order so that the compression fits perfectly, and still pose the same code without altering the nature of the strings, i.e. the order of them.
Eg - "Geeks for Geeks" remains "Geeks for Geeks" not "for Geeks Geeks".
Hence, we need to conserve order too while compressing things, hence sorting strings as number is the way to go.
Well, to address all these issues, we have a simple algorithm called Hu-Tuker that helps to achieve accurate results even though being pretty old.
Understanding the Hu-Tucker :
This algorithm is classified into 3 different phases and the time complexity of each of the methods is then alternatively assessed. After that, the trials are taken and then justified for the amount which is charged for the complexity. Out of all the 3 phases, there are 2 independent methods, which take O(n2) and O(nlogn) complexity respectively.
Thus, the dividing property or the distinguishing line, as some might say, would be the abstract relationship derived from them.
And then, after numbering, the decoding and the encoding process is taken care of by the algorithm itself, just after keying in the values!
The Hu–Tucker Code is the alphabetical search tree's binary code.
Let's look at one tree to learn it better :
The hu-tucker tree.
As in the above figure, pass 1, we see from the trees, that certain strings (classified as Beta) store certain values with fixed length, something which we addressed above. Now, after running these transformations overtime, they get weak for the algorithm and thus get compressed eventually. Also, as we added the numbers, we can rest-assured that the order would be perfect!
After that comes pass 2, which takes the most commonly appearing characters and groups them accordingly, then compresses them and then decompresses them, so that the storage space utilized is less, as the frequent characters are now grouped!
Although this algorithm is quite old for working with, but the classical essence of compression is said to be derived from this. Moreover, there are still certain advantages of using this method over the other as the latency and compression drops in this method are really less. We will now see a short and crisp example of the Hu-Tucker algorithm to better understand the learning curve using certain nodes and alphabet symbols.
The Algorithm for implementing Hu Tucker follows below :
1. 'terminal' label node 0, ... n-1
2. Repeat repetitions (n - 1):
(a) find a pair I j) to be I I < j;
(ii) node I or j is not labelled "none" and
(iii) no node (i+1, etc.)
(iv) weight[i] + weight[j] is minimal,
(v) I is not unique after (iv) and (v)
3. j is minimal if not unique following the selection process.
(a) Mix node j and
(b)save node j as new node I
(c) Weight[i]+= Weight[j] Weight[i] Weight
(d) Node I 'interior'
(e) Node I 'not' Label node
Applications of Hu-Tucker :
Let us look at 2 applications of the Hu Tucker Algorithm for better understanding.
- Implementing Search :
As Hu Tucker is a compression and pattern finding algorithm, it can be used for searching patterns in databases as it uses tree structure and all the searching techniques use binary search as extensively as possible.
Example:
Let us denote the number of edges of the trees as 'i', which is a subset of another set of elements such that i ∈ {1, 2, . . . , n}, then using the Hu-Tucker algorithm, we can find the weight in the given set and can yield the search result. - Minimizing Cost Functions :
Trailing from above, the Hu-Tucker algorithm is also a compression technique and thus, helps find out the minimum cost function calculations.
The formula used for minimizing is:
La(w,l) , loga∑
Xn
i=1
w(i)a
l(i)
Drawbacks of Hu-Tucker :
Despite the fact that the Hu-Tucker algorithm is a neat and profound algorithm, still like with all other algorithms, it has drawbacks and places where it fails. The algorithm is somewhat strange as it depends upon a lot of other information which sometimes is not provided. Like in Application 2 above, the logarithmic function requires too much data, which is normally not a requirement with modern compression algorithms. Also, as this algorithm has aged, newer ones pose a better and less time complexity as compared to this, hence it feels a little outdated and inferior to them!
Conclusion :
This was all about a short introduction to the Hu-Tuckker algorithm. Hope this article helped you with grasping the brief intro to it and helps you in paving your way forward!
Similar Reads
Basics & Prerequisites
Data Structures
Array Data StructureIn this article, we introduce array, implementation in different popular languages, its basic operations and commonly seen problems / interview questions. An array stores items (in case of C/C++ and Java Primitive Arrays) or their references (in case of Python, JS, Java Non-Primitive) at contiguous
3 min read
String in Data StructureA string is a sequence of characters. The following facts make string an interesting data structure.Small set of elements. Unlike normal array, strings typically have smaller set of items. For example, lowercase English alphabet has only 26 characters. ASCII has only 256 characters.Strings are immut
2 min read
Hashing in Data StructureHashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access. Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function. It enables fast retrieval of information based on its key. The
2 min read
Linked List Data StructureA linked list is a fundamental data structure in computer science. It mainly allows efficient insertion and deletion operations compared to arrays. Like arrays, it is also used to implement other data structures like stack, queue and deque. Hereâs the comparison of Linked List vs Arrays Linked List:
2 min read
Stack Data StructureA Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). LIFO implies that the element that is inserted last, comes out first and FILO implies that the element that is inserted first
2 min read
Queue Data StructureA Queue Data Structure is a fundamental concept in computer science used for storing and managing data in a specific order. It follows the principle of "First in, First out" (FIFO), where the first element added to the queue is the first one to be removed. It is used as a buffer in computer systems
2 min read
Tree Data StructureTree Data Structure is a non-linear data structure in which a collection of elements known as nodes are connected to each other via edges such that there exists exactly one path between any two nodes. Types of TreeBinary Tree : Every node has at most two childrenTernary Tree : Every node has at most
4 min read
Graph Data StructureGraph Data Structure is a collection of nodes connected by edges. It's used to represent relationships between different entities. If you are looking for topic-wise list of problems on different topics like DFS, BFS, Topological Sort, Shortest Path, etc., please refer to Graph Algorithms. Basics of
3 min read
Trie Data StructureThe Trie data structure is a tree-like structure used for storing a dynamic set of strings. It allows for efficient retrieval and storage of keys, making it highly effective in handling large datasets. Trie supports operations such as insertion, search, deletion of keys, and prefix searches. In this
15+ min read
Algorithms
Searching AlgorithmsSearching algorithms are essential tools in computer science used to locate specific items within a collection of data. In this tutorial, we are mainly going to focus upon searching in an array. When we search an item in an array, there are two most common algorithms used based on the type of input
2 min read
Sorting AlgorithmsA Sorting Algorithm is used to rearrange a given array or list of elements in an order. For example, a given array [10, 20, 5, 2] becomes [2, 5, 10, 20] after sorting in increasing order and becomes [20, 10, 5, 2] after sorting in decreasing order. There exist different sorting algorithms for differ
3 min read
Introduction to RecursionThe process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. A recursive algorithm takes one step toward solution and then recursively call itself to further move. The algorithm stops once we reach the solution
14 min read
Greedy AlgorithmsGreedy algorithms are a class of algorithms that make locally optimal choices at each step with the hope of finding a global optimum solution. At every step of the algorithm, we make a choice that looks the best at the moment. To make the choice, we sometimes sort the array so that we can always get
3 min read
Graph AlgorithmsGraph is a non-linear data structure like tree data structure. The limitation of tree is, it can only represent hierarchical data. For situations where nodes or vertices are randomly connected with each other other, we use Graph. Example situations where we use graph data structure are, a social net
3 min read
Dynamic Programming or DPDynamic Programming is an algorithmic technique with the following properties.It is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for the same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of
3 min read
Bitwise AlgorithmsBitwise algorithms in Data Structures and Algorithms (DSA) involve manipulating individual bits of binary representations of numbers to perform operations efficiently. These algorithms utilize bitwise operators like AND, OR, XOR, NOT, Left Shift, and Right Shift.BasicsIntroduction to Bitwise Algorit
4 min read
Advanced
Segment TreeSegment Tree is a data structure that allows efficient querying and updating of intervals or segments of an array. It is particularly useful for problems involving range queries, such as finding the sum, minimum, maximum, or any other operation over a specific range of elements in an array. The tree
3 min read
Pattern SearchingPattern searching algorithms are essential tools in computer science and data processing. These algorithms are designed to efficiently find a particular pattern within a larger set of data. Patten SearchingImportant Pattern Searching Algorithms:Naive String Matching : A Simple Algorithm that works i
2 min read
GeometryGeometry is a branch of mathematics that studies the properties, measurements, and relationships of points, lines, angles, surfaces, and solids. From basic lines and angles to complex structures, it helps us understand the world around us.Geometry for Students and BeginnersThis section covers key br
2 min read
Interview Preparation
Practice Problem