Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Lecture Data Structures: Lesson 38 provide students with knowledge about tables and dictionaries; tables: rows & columns of information; the table ADT: operations; how should we implement a table; tablenode: a key and its entry; implementation 1: unsorted sequential array; . | Tables and Dictionaries Tables rows amp columns of information A table has several fields types of information A telephone book may have fields name address phone number A user account table may have fields user id password home folder Name Address Phone Sohail Aslam 50 Zahoor Elahi Rd Gulberg-4 Lahore 576-3205 Imran Ahmad 30-T Phase-IV LCCHS Lahore 572-4409 Salman Akhtar 131-D Model Town Lahore 784-3753 Tables rows amp columns of information To find an entry in the table you only need know the contents of one of the fields not all of them . This field is the key In a telephone book the key is usually name In a user account table the key is usually user id Tables rows amp columns of information Ideally a key uniquely identifies an entry If the key is name and no two entries in the telephone book have the same name the key uniquely identifies the entries Name Address Phone Sohail Aslam 50 Zahoor Elahi Rd Gulberg-4 Lahore 576-3205 Imran Ahmad 30-T Phase-IV LCCHS Lahore 572-4409 Salman Akhtar 131-D Model Town Lahore 784-3753 The Table ADT operations insert given a key and an entry inserts the entry into the table find given a key finds the entry associated with the key remove given a key finds the entry associated with the key and removes it How should we implement a table Our choice of representation for the Table ADT depends on the answers to the following How often are entries inserted and removed How many of the possible key values are likely to be used What is the likely pattern of searching for keys E.g. Will most of the accesses be to just one or two key values Is the table small enough to fit into memory How long will the table exist TableNode a key and its entry For searching purposes it is best to store the key and the entry separately even though the key s value may be inside the entry key entry Saleem Saleem 124 Hawkers Lane 9675846 TableNode Yunus Yunus 1 Apple Crescent 0044 1970 622455 Implementation 1 unsorted sequential array An array in which .