# Software Design Archive

## Priority Queue and Heapq in Python

In this post we learn how to create priority queues using Python. There are 3 main ways to implement and use a priority queue in Python: Create a list and keep it manually sorted Use a binary heap on the basis of Python’s heapq module Use the priority queue implementation from Python’s Queue package

## The Queue in Python

In this post, we learn how to implement a queue in Python using Python’s list data structure, the collections module, and a custom wrapper class What is a Queue in Python? A queue is a data structure that is based on the first-in, first-out principle when adding and removing items. Elements are added to

## The Stack in Python

In this post, we will discuss how to implement the stack, a common data structure, in Python. To build the stack we are going to rely on Python’s built-in list data structure and the collections package. What is a Stack in Python? A stack is a data structure that is based on the last-in,

## Matrix and Array in Python NumPy

In this post, we discuss single- and multidimensional arrays and matrices in Python. Since Python does not offer in-built support for arrays, we use NumPy, Python’s library for matrix and array computations. The NumPy array is one of the most versatile data structures in Python and it is the foundation of most Python-based data

## Dictionaries, Tuples, and Sets in Python

In this post, we introduce three foundational data structures in Python: the dictionary, the tuple, and the set. What is a Dictionary in Python? A dictionary is a data structure that stores items using key-value pairs. Each entry needs to have a unique key. Entries are ordered and can be changed. Dictionaries come inbuilt

## The List in Python

In this post we introduce Python lists and operations you can perform on lists in Python. What is a List in Python? The Python list is the most basic built-in data type that enables you to store sequences of items in a single variable. For example, we can create a list of letters ‘a’,

## What is Encapsulation: An Introduction with Examples in Java and Python

In this post, we are going to introduce the concept of encapsulation in object-oriented programming. We will first look at encapsulation in Java followed by encapsulation in Python. If you are only interested in how to implement encapsulation in one of those languages, feel free to skip to the relevant section. What is Encapsulation?

## Abstraction in OOPS: An Introduction With Examples in Java and Python

In this post we will develop an understanding of abstraction in object oriented programming and learn how to apply abstraction in Java and Python. What is Abstraction (in Computer Science)? Abstraction in everyday language refers to the practice of removing concrete details and dealing only with ideas that are relevant to the problem at

## What is Polymorphism: An Introduction with Examples in Java and Python

In this post, we will introduce the object-oriented programming concept of polymorphism using examples in Java and Python. What is Polymorphism? Polymorphism is the ability of an object to assume multiple forms. For example, a motorbike is some type of bike. It is also some type of motorized vehicle. The motorbike is polymorphic because

## What is Inheritance: An Explanation with Examples in Java and Python

In this post, we introduce inheritance, a foundational concept in object-oriented programming, with examples in Java and Python. What is inheritance? In a software engineering context, inheritance describes a relationship between classes that facilitates the sharing of code. A class becomes a subclass of another class known as the superclass. The subclass can inherit