MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / compAndSwap

Function compAndSwap

sorts/BitonicSort.py:7–11  ·  view source on GitHub ↗
(a, i, j, dire)

Source from the content-addressed store, hash-verified

5# or DESCENDING; if (a[i] > a[j]) agrees with the direction,
6# then a[i] and a[j] are interchanged.*/
7def compAndSwap(a, i, j, dire):
8 if (dire == 1 and a[i] > a[j]) or (dire == 0 and a[i] < a[j]):
9 a[i], a[j] = a[j], a[i]
10
11 # It recursively sorts a bitonic sequence in ascending order,
12
13
14# if dir = 1, and in descending order otherwise (means dir=0).

Callers 1

bitonicMergeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected