mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-20 00:48:17 +02:00
Update measure-SelectionSort.ps1
This commit is contained in:
parent
9c5a7849f2
commit
14b028e1ce
@ -1,4 +1,27 @@
|
|||||||
class SelectionSort {
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Measures the speed of SelectionSort
|
||||||
|
.DESCRIPTION
|
||||||
|
This PowerShell script measures the speed of the SelectionSort algorithm.
|
||||||
|
SelectionSort is an in-place comparison sorting algorithm. It has an O(n2) time complexity,
|
||||||
|
which makes it inefficient on large lists, and generally performs worse than the similar
|
||||||
|
insertion sort. Selection sort is noted for its simplicity and has performance advantages
|
||||||
|
over more complicated algorithms in certain situations, particularly where auxiliary memory
|
||||||
|
is limited.
|
||||||
|
.PARAMETER numIntegers
|
||||||
|
Specifies the number of integers to sort
|
||||||
|
.EXAMPLE
|
||||||
|
PS> ./measure-SelectionSort.ps1
|
||||||
|
🕒 SelectionSort of 1000 integers took 0.3351773 sec
|
||||||
|
.LINK
|
||||||
|
https://github.com/fleschutz/PowerShell
|
||||||
|
.NOTES
|
||||||
|
Author: Markus Fleschutz | License: CC0
|
||||||
|
#>
|
||||||
|
|
||||||
|
param([int]$numIntegers = 1000)
|
||||||
|
|
||||||
|
class SelectionSort {
|
||||||
static Sort($targetList) {
|
static Sort($targetList) {
|
||||||
$n = $targetList.count
|
$n = $targetList.count
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user