Dictionary Data Structure
Dictionary Data Structure
Definition : A dictionary is defined as a general-purpose
data structure for storing a group of objects. A dictionary is
associated with a set of keys and each key has a single
associated value. When presented with a key, the dictionary
will simply return the associated value.
Dictionary Example
For example, the students list in the classroom could be represented as dictionary with
Student’s rollno and name. rollno is key and name is value.
Students = {501: “Kiran”,
502: “Raju”,
503: “Praveen”};
Dictionary ADT
Data:
• Set of (key, value) pairs
• keys are mapped to values
• keys must be comparable
• keys must be unique
Standard Operations:
• insert(key, value)
• find(key)
• delete(key)
Dictionary Implementation using Linear List
struct DictNode{
int key;
char value[20];
struct DictNode *link;
};
Value link
Key
Dictionary Implementation using Linear List
501 Raju
Value link
Key
502 Kumar 503 Pravee
n
NULL
start
Dictionary Time complexity
• Unordered
• search : O(n) , insert : O(1), delete : O(n)
• Ordered Array
• search : O(logn) , insert : O(n), delete : O(n)
• Ordered Linked List
• search : O(n) , insert : O(n), delete : O(n)
Thank You

Dictionary Data Structures by Computer.pptx

  • 1.
  • 2.
    Dictionary Data Structure Definition: A dictionary is defined as a general-purpose data structure for storing a group of objects. A dictionary is associated with a set of keys and each key has a single associated value. When presented with a key, the dictionary will simply return the associated value.
  • 3.
    Dictionary Example For example,the students list in the classroom could be represented as dictionary with Student’s rollno and name. rollno is key and name is value. Students = {501: “Kiran”, 502: “Raju”, 503: “Praveen”};
  • 4.
    Dictionary ADT Data: • Setof (key, value) pairs • keys are mapped to values • keys must be comparable • keys must be unique Standard Operations: • insert(key, value) • find(key) • delete(key)
  • 5.
    Dictionary Implementation usingLinear List struct DictNode{ int key; char value[20]; struct DictNode *link; }; Value link Key
  • 6.
    Dictionary Implementation usingLinear List 501 Raju Value link Key 502 Kumar 503 Pravee n NULL start
  • 7.
    Dictionary Time complexity •Unordered • search : O(n) , insert : O(1), delete : O(n) • Ordered Array • search : O(logn) , insert : O(n), delete : O(n) • Ordered Linked List • search : O(n) , insert : O(n), delete : O(n)
  • 8.