3.1 SYMBOL TABLES - Princeton University
Algorithms
ROBERT SEDGEWICK | KEVIN WAYNE
Algorithms FOURTH EDITION
ROBERT SEDGEWICK | KEVIN WAYNE
3.1 SYMBOL TABLES
API elementary implementations ordered operations
Algorithms
ROBERT SEDGEWICK | KEVIN WAYNE
3.1 SYMBOL TABLES
API elementary implementations ordered operations
Symbol tables
Key-value pair abstraction.
Insert a value with specified key. Given a key, search for the corresponding value.
Ex. DNS lookup.
Insert domain name with specified IP address. Given domain name, find corresponding IP address.
domain name cs.princeton.edu
princeton.edu yale.edu
harvard.edu
IP address 128.112.136.11 128.112.128.15 130.132.143.21 128.103.060.55 209.052.165.60
key
value
3
Symbol table applications
application
purpose of search
key
value
dictionary book index file share financial account web search
compiler routing table
DNS reverse DNS
genomics file system
find definition find relevant pages find song to download process transactions find relevant web pages find properties of variables route Internet packets
find IP address find domain name
find markers find file on disk
word term name of song account number keyword variable name destination domain name IP address DNA string filename
definition list of page numbers
computer ID transaction details list of page names
type and value best route IP address
domain name known positions location on disk
4
Symbol tables: context
Also known as: maps, dictionaries, associative arrays.
Generalizes arrays. Keys need not be between 0 and N ? 1.
Language support.
External libraries: C, VisualBasic, Standard ML, bash, ... Built-in libraries: Java, C#, C++, Scala, ... Built-in to language: Awk, Perl, PHP, Tcl, JavaScript, Python, Ruby, Lua.
every array is an associative array
every object is an associative array
table is the only primitive data structure
hasNiceSyntaxForAssociativeArrays["Python"] = true hasNiceSyntaxForAssociativeArrays["Java"] = false
legal Python code
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.