/Data-Structure-Aglorithm-in-php

Leetcode and codility in php and Javascript

Primary LanguagePHP

Data Structures and Algorithms in PHP

This repository contains examples and implementations of common data structures and algorithms using PHP. The goal of this project is to provide clear and concise explanations of each data structure and algorithm, as well as example code that demonstrates how to use them.

Data Structures

  • The following data structures are currently included in this repository:

  • Stack: A last-in, first-out (LIFO) data structure where elements are added and removed from the top of the stack.

  • Queue: A first-in, first-out (FIFO) data structure where elements are added to the back of the queue and removed from the front.

  • Linked List: A data structure consisting of a sequence of nodes, where each node contains a value and a reference to the next node in the sequence.

  • Binary Search Tree: A binary tree where the value of each node is greater than or equal to the values in its left subtree and less than or equal to the values in its right subtree.

Algorithms

Algorithms The following algorithms are currently included in this repository:

  • Bubble Sort: A simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order.

  • Selection Sort: An in-place comparison sort that divides the input list into two parts: the sublist of items already sorted and the sublist of items remaining to be sorted, and iteratively shrinks the latter until it is empty.

  • Insertion Sort: A simple sorting algorithm that builds the final sorted array one item at a time. Merge Sort: A divide-and-conquer algorithm that recursively divides the input list into two halves, sorts each half, and then merges the sorted halves.

  • Quick Sort: A divide-and-conquer algorithm that selects a pivot element and partitions the array around the pivot, then recursively sorts the sub-arrays.

👤 Author1

🤝 Contributing

If you would like to contribute to this project, please feel free to submit a pull request. All contributions are welcome, including bug fixes, new data structures and algorithms, and improvements to existing code. Please make sure to follow the existing coding style and conventions, and include clear comments and explanations of your changes.