# Introduction to Insertion Sort

## Sorting algorithm 2

• Divide the array into two subarrays: sorted and unsorted subarray (similar to that of selection sort)
• In each iteration, remove the first element from the unsorted subarray and insert it in the proper position (depending on whether to be sorted in ascending or descending order) in the sorted subarray.
• Iterate until the last element of the unsorted array is removed

# Introduction to Selection Sort

## Sorting algorithm 01

• Divide the array into two subarrays: sorted and unsorted subarrays
• In each iteration, find the maximum/minimum element in the unsorted subarray and swap it with the first element of the unsorted subarray. After swapping, the first element of the unsorted subarray will be appended to the sorted subarray. Swapping the minimum value will sort the elements in ascending order while swapping the maximum value will sort the elements in descending order.
• Continue…

# 1. FILE HANDLING

`touch file_name`
`nano file_name`

# Optimization Rules related to Loops

## 1. Hoisting

`#include <math.h>void scale(double *x, double *y, int n){    for(int i=0; i< n; i++){        y[i] = x[i] * exp(sqrt(M_PI/2));    }}`

# Bentley Optimization Rules for Programming: Part 1

## Performance Engineering Series 01 