Analysis Of Algorithms University of Bridgeport Analysis of Algorithms



Download 3.4 Mb.
Page2/33
Date28.05.2018
Size3.4 Mb.
#51061
1   2   3   4   5   6   7   8   9   ...   33

if X[j] > X[j+1] -----line 3


temp := X[j] -----line 4

X[j] := X[j+1] -----line 5



X[j+1] := temp -----line 6


Statement #

# of executions

1

n

2

(n-1)n

3

(n-1)(n-1)

4, 5, 6




T(n) = n + (n2 – n) + (n2 – 2n + 1) +

= 2n2 – 2n + 1 +

Download 3.4 Mb.

Share with your friends:
1   2   3   4   5   6   7   8   9   ...   33




The database is protected by copyright ©ininet.org 2024
send message

    Main page