Dictionary vs Set

This lesson will discuss the key difference between Dictionary and Set in python.

Introduction

Before solving any challenges regarding Hash Tables, it is necessary to look at the implementations of dict, and set and see how they are different. Both are implemented in Python. It is also a common misconception that these two structures are the same, but they are very different from each other.

🔍 dict

dict or dictionary is a Mapping Type object which maps hashable values to arbitrary objects. It stores an element in the form of key-value pairs.

It provides the basic functionality of hashing along with some helper functions that help in the process of insertion, deletion, and search.

Some of the key features of dict are given below:

  • An dict stores key-value pairs (examples given below) to map a key to the value:

abc>123abc->123

xyz>456 ...