The process of creating the “lego” databases (can be screenshot and/or SQL/non-SQL statements with text explanation) (8pts)
$ brew install postgresql@15
$ brew services start postgresql@15
$ createdb lego
$ psql lego
After creating the database, use the following SQL statement to define the schema of database.
create table part_categories (
id integer primary key,
Ben1102 changed 2 years agoView mode Like Bookmark
介紹
霍夫曼編碼是美國計算機科學家大衛.霍夫曼在1952年提出的一種無失真資料壓縮編碼(在保留完整資訊的前提下進行壓縮)。藉由根據字頻的大小選定不同編碼長度,來減少編碼總長的期望值,達到資料壓縮的目的。由於霍夫曼編碼是個二進制的編碼,所以字元集與編碼的對應可以用一個01-Trie來表達,也就是可以使用一個二元樹來表達。
本圖由此網站生成
上圖即是一個霍夫曼樹,基於文本"can you can a can with a cucumber"。首先,由觀察可以得知所有字元皆在樹的葉子上,這是因為要避免一個字元的編碼同時是另一個字元編碼的前綴,導致有多種解碼結果。此外,可以觀察到頻率較高的字元(如'空白'、'c')擁有更短的編碼,如此能夠有效地降低編碼的總長。
如何建立霍夫曼樹
以下將基於"to be or not to be"的文本進行建樹。
首先,統計各字元的出現頻率
Ben1102 changed 4 years agoView mode Like Bookmark