IT@KMITL Forums
IT@KMITL Knowledge => ไอทีนอกกะลา => Topic started by: MapleTree on November 25, 2009, 04:55:20 PM
-
วันศุกร์ 27 นี้ ช่วงสี่โมงเย็นถึงห้าโมงเย็น ช่วงนี้มีใครมีช่วงว่างไหมคะ
จะขอความช่วยเหลือด้วยค่ะ ช่วยอธิบายโค๊ดภาษา C ให้หน่อยค่ะ
โดยส่วนตัว ไม่เคยทำ C ยากๆซับซ้อน อ่านแค่ผิวเผิน
อยากจะพัฒนาเป็นภาษาอื่น เลยมาศึกษาให้เข้าใจก่อน
ปล. โค๊ดมี7 หน้ากระดาษ จะแปะในนี้ดีไหม หรือเจอกันที่ห้องสมุดดีคะ
เลื่อน อ. มาหลายรอบแล้ว ...:t31:......
-
แปะในนี้ก่อนก็ดีครับ
^_^
-
attach จ้า
-
หลังจากได้ดูโค้ดอยากอุทานออกมาว่า
what the code!!
เข้าใจว่าโค้ดนั้นเป็นโค้ดที่เขียนมาจากอัลคอฯ ซักอันนึง
ถ้าศึกษาจากต้นฉบับอัลคอฯ จะง่ายกว่ามั้ย.....
-
ใช่แล้วจ้า อัลกอลิทึม Dynamic Huffman
ศึกษาทฤษฎีเป็นที่เข้าใจดีแล้ว
แต่ อ่านโค๊ด C นี้แล้วไม่เข้าใจน่ะค่ะ ว่า เขาเรียกใช้ในลูบยังงัย ตัวแปรเยอะเหลือเกิน
ได้โปรด แนะนำด้วยน๊าคะ :46:
-
พรุ่งนี้วันศุกร์แล้ว
...
:t31:
-
ทุกๆคน อ่านแล้วเข้าใจกันไหมคะ ช่วยอธิบายด้วยนะคะ นะ นะ :t05:
-
ไม่เข้าใจ syntax หรือไม่เข้าใจ algorithm ของ code ครับ
ถ้าไม่เข้าใจ syntax ผมว่าพี่ๆหลายคนในที่นี้สามารถช่วยได้แน่นอนครับ :t18:
ถ้าอย่างไร ลองให้รายละเอียดมากกว่านี้อีกสักนิดนึง ว่าต้องการให้ช่วยในรูปแบบไหน, อธิบายอะไร หากมีรายละเอียดความต้องการแล้ว ผมคิดว่าพี่ๆเขาจะสามารถช่วยได้ถูกจุดครับ
ปล. ผมก็อยากช่วย แต่ผมลองอ่าน code ดูแล้วมึนตึ้บครับ ขี้เกียจไล่มากๆ เพราะไม่มีทั้ง usage และ input, output example และความสามารถผมคงไม่ถึงจริงๆครับ - -"
-
อิอิอิอิ แล้วไปเอา Code มาจากละครับจะส่งวันนี้แล้วด้วย อาจารย์อยู่ในนี้รึเปล่าครับ เดี่ยวผมอธิบาย จะเข้าใจใหมครับนี่ ผมเองก็งง
-
ไล่ที่ละส่วน guide line ที่เหลือไปหาความหมายเองนะครับ
#ifdef HUFFSTANDALONE
#include <stdlib.h>
#include <memory.h>
#include <string.h>
#include <fcntl.h>
#else
#include "xlink.h"
#endif
#ifdef unix
#define __cdecl
#else
#include <io.h>
#endifส่วนนี้เป็นส่วนหัวประกาศไว้เพื่อจะได้ดึงฟังก์ชั่นมาใช้งานได้
-
ส่วนนี้เค้ากำลังจะบอกว่า ต่อไปนี้เค้ากำลังจะทำอะไรต่อ
// please address any bugs discovered in this code
// to the author: karl malbrain, karl_m@acm.org <<<<<< ถ้าเจอบักปรึกษาได้ที่ E mail นี้เลย
// link bit-level I/O
void arc_put1 (unsigned bit); การประกาศตัวแปร arc_put1 ชนิด unsigned bit
unsigned arc_get1 ();
// This code is adapted from Professor Vitter's
// article, Design and Analysis of Dynamic Huffman Codes,
// which appeared in JACM October 1987
// A design trade-off has been made to simplify the
// code: a node's block is determined dynamically,
// and the implicit tree structure is maintained,
// e.g. explicit node numbers are also implicit.
// Dynamic huffman table weight ranking
// is maintained per Professor Vitter's
// invariant (*) for algorithm FGK:
// leaves preceed internal nodes of the
// same weight in a non-decreasing ranking
// of weights using implicit node numbers:
// 1) leaves slide over internal nodes, internal nodes
// swap over groups of leaves, leaves are swapped
// into group leader position, but two internal
// nodes never change positions relative
// to one another.
// 2) weights are incremented by 2:
// leaves always have even weight values;
// internal nodes always have odd values.
// 3) even node numbers are always right children;
// odd numbers are left children in the tree.
// node 2 * HuffSize - 1 is always the tree root;
// node HuffEsc is the escape node;
// the tree is initialized by creating an
// escape node as the root.
// each new leaf symbol is paired with a new escape
// node into the previous escape node in the tree,
// until the last symbol which takes over the
// tree position of the escape node, and
// HuffEsc is left at zero.
// overall table size: 2 * HuffSize
// huff_init(alphabet_size, potential symbols used)
// huff_encode(next_symbol)
// next_symbol = huff_decode()
// huff_scale(by_bits) -- scale weights and rebalance tree