Insertion sort is a sorting algorithm like bubble sort and selection sort. In practical life we can use insertion sort, beside that we are not use bubble sort and selection sort at all in practical life. It’s worst-case complexity O(n^2). Check the complete code below:
Read More »Implementation of bubble sort in PHP
The simplest sorting algorithm bubble sort which bubbles up the element to the correct position each time compares with the adjacent items. Check the complete code below:
Read More »Implement Selection Sort in PHP
To accomplish selection sort algorithm we need to use two loop. Complexity of this algorithm is O(n^2). Check the complete code below:
Read More »Binary Search in PHP
In order to do binary search the array items need to be sorted by default. Check the complete code below:
Read More »Linear Search in PHP
Search a item from an array by going through each item of the array. Check the code below:
Read More »Create Pyramid Using asterisks in PHP
To create a pyramid using asterisks in php, first we need to specify the height of the pyramid using a variable like $height = 5;. Then we need to add two for loop and one while loop like below:
Read More »How Can I Implement Stack in PHP?
Stack is a linear data structure which follows a particular order in which the operations are performed. The order is LIFO(Last In First Out). We can implement it in both procedural or object oriented approach. Here i follow the procedural approach.
Read More »