Lập trình C nâng cao - Fit Lec 2 (HUST) GV.AnhTT
- Seiten
- 7
- Định dạng
- Dung lượng
- 145 KB
- Trường
- Đại học Bách khoa Hà Nội
- Aufrufe
- 0
- Kommentare
- 0
- Lượt tải
- 0
Vorschau wird generiert...
Bài giảng về Symbol Tables và các cấu trúc dữ liệu lưu trữ cặp khóa-giá trị trong C, bao gồm các cách cài đặt từ mảng đơn giản, danh sách liên kết cho đến bảng ký hiệu tổng quát với con trỏ hàm. Tài liệu cung cấp ví dụ thực tế về ứng dụng trong điện thoại và bài tập liên quan.
- Dokumentenname
- Lập trình C nâng cao - Fit Lec 2 (HUST) GV.AnhTT
- Schule / Kurs
- Đại học Bách khoa Hà Nội · Lập trình C
- Autor (im Dokument)
- AnhTT
- Inhalt
- Tài liệu này mô tả cấu trúc dữ liệu bảng ký hiệu, các phương pháp cài đặt khác nhau (mảng, danh sách liên kết, cây nhị phân), và cách xây dựng bảng ký hiệu tổng quát trong lập trình C. Nó cung cấp ví dụ về danh bạ điện thoại và các bài tập thực hành.
- Inhaltsverzeichnis
- ADT
- Symbol Tables
- Example applications
- Elementary implementations
- Implementation
- API
- Quiz 1
- Using dynamic memory
- API
- Quiz 2
- Homework K53
- Generic symbol tables
- API
- Example
- Guide - creatSymbolTable function
- Seiten
- 7 Seiten
- Hochgeladen von
- lienhejb
Beschreibung
Trích nội dung tài liệu
ADT Symbol Tables Key-value pair abstraction. Insert a value with specified key. Given a key, search for the corresponding value. Example: DNS lookup. Insert URL with specified IP address. Given URL, find corresponding IP address anhtt-fit@mail.hut.edu.vn dungct@it-hut.edu.vn http://www.mediafire.com/?n2yzyjnnn10 Example applications Can interchange roles: given IP address find corresponding URL Elementary implementations Binary search implementation: maintaining two parallel arrays of keys and values, keeping them in key-sorted order. It uses binary search for get. Linked list implementation. Both put and get take linear time per operation: to search for a key, we need to traverse its links; to put a key-value pair, we need to search for the given key. Binary search trees. Performance depend on the shape of tree. 1 Implementation Define a structure to store key-value pairs Example: phonebook typedef struct { long number; char name[80] } PhoneEntry; Using array for implementation Key-value pairs are stored in an ordered array Example: #define MAX_PHONE_NUMBER 1000 typedef struct { PhoneEntry entries[MAX_PHONE_NUMBER]; int total; } PhoneBook; The key is phone number and the value is person name API Quiz 1 Add an entry in the phone book void addPhoneNumber(long number, char * name, PhoneBook* book); NB: If the entry exists, the value should be overwritten. Write a program to add and search phone numbers in a phone book using an array for implementation Find an entry in the phone book char * getPhoneNumber(long number, const PhoneBook* book); returns null if the entry does not exist 2 Using dynamic memory API The memory to store the entries should be allocated dynamically according to the size of the phone book. typedef struct { PhoneEn
Häufig gestellte Fragen
Ist dieses Dokument kostenlos?
Ja. „Lập trình C nâng cao - Fit Lec 2 (HUST) GV.AnhTT“ ist kostenlos — melden Sie sich einfach an und klicken Sie auf Herunterladen, um die Originaldatei zu erhalten.
Wie viele Seiten hat dieses Dokument?
Das Dokument hat 7 Seiten, für den Kurs Lập trình C. Sie können es vor dem Herunterladen online in der Vorschau ansehen.
Kann ich vor dem Herunterladen eine Vorschau ansehen?
Ja. Sie können sich dieses Dokument direkt auf dieser Seite im Online-Reader ansehen und dann entscheiden, ob Sie es herunterladen möchten.
Lập trình C nâng cao - Fit Lec 2 (HUST) GV.AnhTT
Vorschau wird generiert...
Trích nội dung tài liệu
ADT Symbol Tables Key-value pair abstraction. Insert a value with specified key. Given a key, search for the corresponding value. Example: DNS lookup. Insert URL with specified IP address. Given URL, find corresponding IP address anhtt-fit@mail.hut.edu.vn dungct@it-hut.edu.vn http://www.mediafire.com/?n2yzyjnnn10 Example applications Can interchange roles: given IP address find corresponding URL Elementary implementations Binary search implementation: maintaining two parallel arrays of keys and values, keeping them in key-sorted order. It uses binary search for get. Linked list implementation. Both put and get take linear time per operation: to search for a key, we need to traverse its links; to put a key-value pair, we need to search for the given key. Binary search trees. Performance depend on the shape of tree. 1 Implementation Define a structure to store key-value pairs Example: phonebook typedef struct { long number; char name[80] } PhoneEntry; Using array for implementation Key-value pairs are stored in an ordered array Example: #define MAX_PHONE_NUMBER 1000 typedef struct { PhoneEntry entries[MAX_PHONE_NUMBER]; int total; } PhoneBook; The key is phone number and the value is person name API Quiz 1 Add an entry in the phone book void addPhoneNumber(long number, char * name, PhoneBook* book); NB: If the entry exists, the value should be overwritten. Write a program to add and search phone numbers in a phone book using an array for implementation Find an entry in the phone book char * getPhoneNumber(long number, const PhoneBook* book); returns null if the entry does not exist 2 Using dynamic memory API The memory to store the entries should be allocated dynamically according to the size of the phone book. typedef struct { PhoneEn
- Dokumentenname
- Lập trình C nâng cao - Fit Lec 2 (HUST) GV.AnhTT
- Schule / Kurs
- Đại học Bách khoa Hà Nội · Lập trình C
- Autor (im Dokument)
- AnhTT
- Inhalt
- Tài liệu này mô tả cấu trúc dữ liệu bảng ký hiệu, các phương pháp cài đặt khác nhau (mảng, danh sách liên kết, cây nhị phân), và cách xây dựng bảng ký hiệu tổng quát trong lập trình C. Nó cung cấp ví dụ về danh bạ điện thoại và các bài tập thực hành.
- Inhaltsverzeichnis
- ADT
- Symbol Tables
- Example applications
- Elementary implementations
- Implementation
- API
- Quiz 1
- Using dynamic memory
- API
- Quiz 2
- Homework K53
- Generic symbol tables
- API
- Example
- Guide - creatSymbolTable function
- Seiten
- 7 Seiten
- Hochgeladen von
- lienhejb
Kommentare (0)
Noch keine Kommentare. Seien Sie der Erste!
Lập trình C nâng cao - Fit Lec 8 (HUST) GV.AnhTT
Lập trình C nâng cao - Fit Lec 5 (HUST) GV.AnhTT
Lập trình C nâng cao - Fit Lec 3 (HUST) GV.AnhTT
Lập trình C nâng cao - Fit Lec 6 (HUST) GV.AnhTT
Lập trình C nâng cao - Fit Lec 10 (HUST) GV.AnhTT
K5 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)
K2 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)
K3 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)
K4 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)
K1 Bộ đề luyện thi Trạng Nguyên Tiếng Việt (NXB DHQG)

Kommentare (0)
Noch keine Kommentare. Seien Sie der Erste!