sleep sort

 
############################## 
####     sleep sort       #### 
############################## 
 
sleep for the duration of the quantified size of each element concurrently and print them when done. 
a bit non-sensical to talk about its complexity but in essence it is O(N) from the standpoint of accessing each element once. 
but for the sort to work, we assume the parallelization. 
 
 
--------------------------// sleep_sort.ksh 
#!/bin/ksh 
 
array=(3 2 5 1 7 3) 
 
for i in "${array[@]}" 
do 
    (sleep $i; echo $i) & 
done 
wait 
-------------------------- 
 

  1. 2015-04-28 00:09:18 |
  2. Category : algo
  3. Page View:

Google Ads