phjung1 Blog

「😅」

Insertion Sort

Insertion Sort Insertion sort is a simple sorting algorithm that works similar to the way you sort playing cards in your hands. The array is virtually split into a sorted and an unsorted part. Val...

Selection Sort

Selection Sort The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning. The algorithm...

Exponential Search

Exponential Search The name of this searching algorithm may be misleading as it works in O(Log n) time. The name comes from the way it searches an element. 1 2 3 4 5 6 7 8 9 10 Given a sorted arr...

Interpolation Search

Interpolation Search Given a sorted array of n uniformly distributed values arr[], write a function to search for a particular element x in the array.d Linear Search finds the element in O(n) tim...

Jump Search

Jump Search LikeBinary Search, Jump Search is a searching algorithm for sorted arrays. The basic idea is to check fewer elements than Linear Search by jumping ahead by fixed steps or skipping som...

Bubble Sort

Bubble Sort Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. Example: First Pass: ( 5 1 4 2 8 ) –> ( 1 5 4 2 ...

Binary Search

Binary Search Given1 a sorted array arr[] of n elements, write a function to search a given element x in arr[]. A simple approach is to do a linear search. The time complexity of the above algori...

Linear Search

Linear Search Problem: Given an array arr[] of n elements, write a function to search a given element x in arr[]. 1 2 3 4 5 6 7 8 9 10 11 Input : arr[] = {10, 20, 80, 30, 60, 50, ...

Performance of loops (A caching question)

Performance of loops (A caching question) Consider below two C language functions to compute sum of elements in a 2D array. Ignoring the compiler optimizations, which of the two is better implemen...