*What are data structures? *
Data structures are the fundamental constructs around which you build your programs. Each data structure provides a particular way of organizing data so it can be accessed efficiently, depending on your use case. Python ships with an extensive set of data structures in its standard library.
Algorithms are a set of instructions executed to get the solution of a given problem.
- Dictionaries
Dictionaries are data structures used to map arbitrary keys to values.
Dictionaries can be indexed in the same way as lists, using square brackets containing keys. A dictionary can store any types of data as values.
An empty dictionary is defined as {}.
2.Lists
Lists are used to store items.
A list is created using square brackets with commas separating items A certain item in the list can be accessed by using its index in square brackets[].
3.Tuples
Tuples are very similar to lists, except that they are immutable (they cannot be changed).
Also, they are created using parentheses, rather than square brackets .You can access the values in the tuple with their index, just as you did with lists.
An empty tuple is created using an empty parenthesis pair;tp()
4.Sets
Sets are data structures, similar to lists or dictionaries. They are created using curly braces, or the set function.
Sets differ from lists in several ways, but share several list operations such as len.
Due to the way they're stored, it's faster to check whether an item is part of a set, rather than part of a list.
Sets can be combined using mathematical operations.
set()
Array
An array is an index-based data structure, which means every element is referred by an index. An array holds same data type elem
Tree:
A tree is a collection of nodes connected by edges. Each node points to a number of nodes. A tree represents the hierarchical graphic form.
data structure tree diagram
Graph:
A graph contains a set of nodes and edges. The nodes are also called vertices. Edges are used to connect nodes. Nodes are used to store and retrieve data.
Hash table:
Hash table is a data structure that can map keys to values. A hash table uses a hash function to compute a key into an integer (hash value), which indicates the index of the butckets (aka array). From the key, the correct value can be stored and found. Hash table is one of the most used data structures.
Stack:
a stack is LIFO data structure in which only the top element can be accessed.
Queue:
A queue is FIFO data structure. In this structure, new elements are inserted at one end and existing elements are removed from the other end.
Top comments (1)
Keep the good work up @chagallah 👏👏