Syntax The power function in Python can be easily computed by importing the math module as follows: import math # This will print 8 which is 2 to the power 3 print pow(2, 3) You can alternatively use the ** …

# Tag Archives: Loop Invariant

## Python for loop

Introduction Any computer algorithm requires two control flow structures: iteration and selection. Our topic today is mainly about iteration using the Python for loop. The goal of this post is to achieve three objectives: Provide a beginner introduction to the …

## Loop Invariant Insertion Sort

Insertion Sort Welcome to part 8 on loop invariants. Please refer to the first part (introduction) here. Today, we are going to discuss insertion sort algorithm. Let us get started. Problem definition Given an array (A) of (n) numbers. Assume …

## Loop Invariant Bubble Sort

Bubble Sort Hello! This is part 7 in a series of short articles on loop invariants. You can refer to the first part (introduction) here. Today, we are going to discuss bubble sort algorithm in the context of loop invariants. …

## Loop Invariant Linear Search

Linear Search Hello! This is part 6 in a series of short articles on loop invariants. You can refer to the first part (introduction) here. Today, we are going to develop an algorithm for linear search using loop invariants. Let …

## Loop Invariant Integer Division

Integer Division This is the 5th part in a series of short articles on loop invariants. You can refer to the first part (introduction) here. Our example for today is a little bit harder than the previous examples. We are …

## Loop Invariant Factorial

Factorial Hello everyone! This is the 4th part in a series of short articles on loop invariants. You can refer to the first part (introduction) here. We are going to continue talking about loop invariants. Let us see how to …