EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
We have discussed Huffman encoding for data compression in lecture and tutorial, now we can implement the Huffman decoding for data extraction to recover the original data.
To decode the encoded data, we require the Huffman tree. We iterate through the binary encoded data. To find character corresponding to current bits, we use following simple steps.
We start from root and do following until a leaf is found.
If current bit is 0, we move to left node of the tree.
If the bit is 1, we move to right node of the tree.
If during traversal, we encounter a leaf node, we print character of that particular leaf node and then again continue the iteration of the encoded data starting from step 1.
Your task is to implement the Huffman decoding algorithm from the above steps in a C++ program with Huffman decoding function and a main function to decode a
compressed string based on Huffman encoding and display the original string.
Question 2
Given a Huffman code as a binary tree, show that you can decode in O(n) time.
For the following list of letter frequencies, create a Huffman tree, and use it to determine the encoding for each of the letters. After you’ve written down the encoding for each letter, determine the average number of bits needed to encode ANY letter using this encoding.A: .33 B: .10 C: .08 D: .12 E: .37
Chapter 7 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
Similar questions
- Show the disjoint set after performing union(9,13) on the following disjoint set using union by rank and path compression. Also show the rank of the final root node. rank = 3 1 11 rank = 2 7 8. 3 12 4 5 6. 10 13 9.arrow_forwardGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA: "The lowest common ancestor is defined between two nodes p and q as the lowest node in t that has both p and q as descendants (where we allow a node to be a descendant of itself)." For example, in the figure from question 1, the LCA between nodes 5 and 46 is 21. You may use the following typedef structure. The function returns the reference of the node that is considered the LCA. typedef struct node_s{ int data; struct node_s * leftchild; struct node _s * rightchild; }node_t;arrow_forwardGenerate Huffman Encoding Tree for given frequencies and letters in the Figure. Demonstrate all child nodes. At step VIII display all of the tree.arrow_forward
- If a node is at distance i from s, then its neighbors are at distance either i − 1 or i or i + 1 from s. explain stetement using right algorithm.arrow_forwardlet’s examine FSAs whose transition functions are FULL BINARY TREES. We can call these objects FBTSAs to help you remember that they are full binary trees. The alphabet of an FBTSA is Σ = {0, 1}, the start state is at the root, transition arrows must go away from the root and toward the leaves, and all transitions out of the leaves are to a fail state (not drawn). Like a normal FSA, any state can be either accepting or rejecting, except the fail state, which always rejects. Using big-O notation, give an upper bound for the number of accepted words in the language of any FBTSA in terms of the number of states |S|. Please explain your answer.arrow_forwardGiven the following key sequence (6,22,9,14,13,1,8) build the dynamic binary search tree WITHOUT BALANCING IT. How many probes (i.e., comparisons) does it take to determine that key 100 is not in the tree? (In this study case, the root is 6; the next element 22 > 6, so it goes to the right, etc). DEPTH counting starts at 1 at the rootarrow_forward
- 1.Show the result of inserting 2, 1, 4, 5, 9, 3, 6, 7 into an initially empty AVL tree. 2. Write a nonrecursive function to insert into an AVL tree. 3.How many bits are required per node to store the height of a node in an N-node AVL tree? What is the smallest AVL tree that overflows an 8-bit height counter? 4. Show the result of accessing the keys 3, 9, 1, 5 in order in the splay tree in below tree 10 12 5.Show the result of accessing the keys 3, 9, 1, 5 in order in the splay tree in 13arrow_forwardYou are going to simulate the operation of an AVL tree on paper. For the purposes of this assignment, assume that new returns addresses in the following order: @1480 @1120 @1096 @1264 @1180 @1192 @1768 @1804 @1228 @1372 @1312 @1276 @1168 @1696 @1084 @1504 @1468 @1216 @1384 @1204 @1648 @1024 @1108 @1396 @1144 @1432 @1252 @1348 @1564 @1072 @1684 @1540 @1672 @1624 @1420 @1588 @1300 @1792 @1060 @1720 @1336 @1612 @1552 @1324 @1636 @1660 @1288 @1708 @1732 @1492 @1780 @1528 @1156 @1444 @1036 @1456 @1240 @1576 @1516 @1756 @1360 @1132 @1408 @1600 @1744 @1048 Also note that if you remove all references to an address (so it is garbage collected), it goes to the back of the queue (so would be after whatever is the last address in the AVL at that time). For delete() of a node with two children, I want you to assume that we replace the data (but not the node itself) with the successor value (and that the successor is removed and garbage collected). There are no duplicates allowed, so if there's a…arrow_forwardGenerate the shortest path tree using the Dijkstra Algorithm using the following format: Note: using link state (OSPF) Shortest path tree for node A1.Permanent list Tentative listempty A(0)2.Permanent list Tentative listA(0) B(5), C(2), D(3)3.Permanent list Tentative listA(0), C(2) B(5), D(3), E(6)4.Permanent list Tentative listA(0), C(2), D(3) B(5), D(3)5.Permanent list Tentative listA(0), C(2), D(3), B(5) D(3)6.Permanent list Tentative listA(0), C(2), D(3), B(5), D(3)…arrow_forward
- Given a string of digit characters including totally 21 digit characters (7 different character symbols). a) Determine and draw the Huffman Tree, based on different character symbols of the string "318159865358979383886" above, and their frequencies of occurrence as their weights. No steps required. b) List the prefix codes of different character symbols, based on this Huffman Tree. c) Find the weighted path length (WPL) of the prefix codes and its average bit length (ABL), with 3 decimal places. Show the steps of your calculation.arrow_forwardDraw a binary expression tree. (2a + 5b) ^ 3 * (x - 7y) ^ 4arrow_forwardWhat is need for finding minimum spanning tree?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education