跳到主要內容

發表文章

目前顯示的是 2019的文章

huffman coding 實作

Github link huffman 實作我使用了幾個 data structure 1. map 2. min heap 3. tree 主要分3個階段完成huffman coding 所需要的 data structure,對於之後的encode 跟decode是很重要的 Phase 1 : read file and record the frequency of each character (unordered_map) Phase 2 : using map to construct min heap (min heap) Phase 3 : using min-heap to create huffman coding tree (tree) 在講 encode 前,先說明huffman的概念 Concept : wiki link 1. 無失真壓縮 2. 常出現的字,用最少的bit來描述 3. 應用在檔案壓縮 encode algorithm : 1. construct huffman coding tree     if there are more than 2 in min heap, we dequeue two item.     add these two frequency and create a new node as virtual item.     make these two item be new node's left/right child. then push back to min-heap     go repeat until there are no more than 2 illustrated : https://www.google.com/search?q=huffman+coding&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiQ4tKOlO7iAhXIw7wKHfESDUAQ_AUIECgB&biw=1024&bih=462#imgrc=QMXyN8ycoMLfrM: 2...

安裝QT可能會發生的問題,跟解決辦法

參考的官方文件 https://wiki.qt.io/Install_Qt_5_on_Ubuntu 安裝完後,執行QT creator,可能會發生的問題是 garygu@garygu-UX330UA:~/Qt/Tools/QtCreator/bin$ ./qtcreator qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb. Aborted (core dumped) 看起來是在run的過程中有缺少shared library,以下網站也有提到。 https://stackoverflow.com/questions/17106315/failed-to-load-platform-plugin-xcb-while-launching-qt5-app-on-linux-without 所以透過ldd 可以知道有哪些shared library是有缺少的。從not found的library下手安裝就行了。 garygu@garygu-UX330UA:~/Qt/Tools/QtCreator/lib/Qt/plugins/platforms$ ldd libqxcb.so  linux-vdso.so.1 (0x00007fff229e2000) libQt5XcbQpa.so.5 => /home/garygu/Qt/Tools/QtCreator/lib/Qt/plugins/platforms/./../../lib/libQt5XcbQpa.so.5 (0x00007ffb4854...