From sedgewick course, I learnt that,
Symbol table
Symbol table is a
key
-value
pair abstractionwhere, given a
key
, search for the correspondingvalue
.
value
is not null
get()
returns null ifkey
not present
put()
overwrites old value with new value.
After introducing Symbol table abstraction, not sure, why the term Dictionary abstraction & Map abstraction is introduced? Stack overflow maintains these tags.
Symbol table representation using List
implementation,
typedef struct{
void **array;
int size;
}List;
typedef struct{
void *key;
void *value; // cannot be null
}Pair;
typedef struct ST{
List *keyValuePairList;
}ST;
From wiki, I learnt that,
A Set is an abstract data type that can store certain values, without any particular order, and no repeated values. It is a computer implementation of the mathematical concept of a finite set.
From wiki definition of Set, I would conclude,
Set is an abstraction that contains distinct items,
where, each item has a
key
,maintaining corresponding
value
does not violate Set property,
value
can be null,
get()
returns null ifkey
not present,
put()
overwrite old value with new value, ifvalue
is not null.
From operation & data aspect, Set and Symbol Table look similar. It is difficult to understand, when to use what?
Set representation using List
implementation,
typedef struct{
void **array;
int size;
}List;
typedef struct{
void *key;
void *value; // can be null
}Pair;
typedef struct{
List *keyValuePairList;
}Set;
Question:
Isput()
operation that differentiates Set and Symbol Table? I still see these two are same.