Python Data Structures and Algorithms
Arrays and Linked lists
Arrays store elements in contiguous memory locations, resulting in easily calculable addresses for the elements stored and this allows faster access to an element at a specific index. Linked lists are less rigid in their storage structure and elements are usually not stored in contiguous locations, hence they need to be stored with additional tags giving a reference to the next element. This difference in the data storage scheme decides which data structure would be more suitable for a given situation.
Visit the following resources to learn more:
- Linked Lists vs Arrays
- Python Array Tutorial
- Python Arrays
- Arrays in Python
- Array Data Structure | Illustrated Data Structures
- Linked List Data Structure | Illustrated Data Structures
Heaps Stacks and Queues
Stacks: Operations are performed LIFO (last in, first out), which means that the last element added will be the first one removed. A stack can be implemented using an array or a linked list. If the stack runs out of memory, it’s called a stack overflow.
Queue: Operations are performed FIFO (first in, first out), which means that the first element added will be the first one removed. A queue can be implemented using an array.
Heap: A tree-based data structure in which the value of a parent node is ordered in a certain way with respect to the value of its child node(s). A heap can be either a min heap (the value of a parent node is less than or equal to the value of its children) or a max heap (the value of a parent node is greater than or equal to the value of its children).
Visit the following resources to learn more:
- Heaps, Stacks, Queues
- Stack Data Structure | Illustrated Data Structures
- Queue Data Structure | Illustrated Data Structures
- Stack in Python
- How to Implement Python Stack?
- Queue in Python
- Python Stacks, Queues, and Priority Queues in Practice
- Heap Implementation in Python
Hash Tables
Hash Table, Map, HashMap, Dictionary or Associative are all the names of the same data structure. It is a data structure that implements a set abstract data type, a structure that can map keys to values.
Visit the following resources to learn more:
- Hash Table Data Structure | Illustrated Data Structures
- Hash Tables and Hashmaps in Python
- Build a Hash Table in Python
Binary Search Trees
A binary search tree, also called an ordered or sorted binary tree, is a rooted binary tree data structure with the key of each internal node being greater than all the keys in the respective node's left subtree and less than the ones in its right subtree
Visit the following resources to learn more:
- Tree Data Structure | Illustrated Data Structures
- How to Implement Binary Search Tree in Python
- Problem Set
Recursion
Recursion is a method of solving a computational problem where the solution depends on solutions to smaller instances of the same problem. Recursion solves such recursive problems by using functions that call themselves from within their own code.
Visit the following resources to learn more:
Sorting Algorithms
Sorting refers to arranging data in a particular format. Sorting algorithm specifies the way to arrange data in a particular order. Most common orders are in numerical or lexicographical order.
The importance of sorting lies in the fact that data searching can be optimized to a very high level, if data is stored in a sorted manner.
Visit the following resources to learn more:
Data Structures and Algorithms
A data structure is a named location that can be used to store and organize data. And, an algorithm is a collection of steps to solve a particular problem. Learning data structures and algorithms allow us to write efficient and optimized computer programs.
Visit the following resources to learn more: