array-algorithms-library

1.0.0 • Public • Published

Array Algorithms Library

This is a JavaScript library containing various array manipulation algorithms implemented as functions. These algorithms are useful for sorting, searching, and manipulating arrays efficiently.

Installation

You can install this library via npm:

npm install array-algorithms-library

Usage

// Import the library
const arrayAlgorithms = require('array-algorithms-library');

// Example usage of functions
const arr = [3, 1, 4, 1, 5, 9, 2, 6, 5];
console.log(arrayAlgorithms.bubbleSort(arr)); // [1, 1, 2, 3, 4, 5, 5, 6, 9]

Functions

bubbleSort(arr)

Sorts an array in ascending order using the bubble sort algorithm.

selectionSort(arr)

Sorts an array in ascending order using the selection sort algorithm.

insertionSort(arr)

Sorts an array in ascending order using the insertion sort algorithm.

kthSmallestElem(arr, k)

Finds the kth smallest element in an array.

maxSumSubArr(arr)

Finds the maximum sum of a contiguous subarray within the given array.

maxProduct(arr)

Finds the maximum product of a contiguous subarray within the given array.

reverseArr(arr)

Reverses the elements of the given array.

interleavingArray(arr)

Interleaves the elements of the given array.

sortZeroOneTwo(arr)

Sorts an array containing only 0s, 1s, and 2s in ascending order.

duplicateZero(arr)

Duplicates each occurrence of 0 in the array.

Readme

Keywords

Package Sidebar

Install

npm i array-algorithms-library

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

10.1 kB

Total Files

3

Last publish

Collaborators

  • jinu_vijayan