(CYCLOMATIC/MCCABE COMPLEXITY) Consider the following bubblesort sorting algorit
ID: 3767548 • Letter: #
Question
(CYCLOMATIC/MCCABE COMPLEXITY)
Consider the following bubblesort sorting algorithm:
procedure bubbleSort( A : list of sortable items )
repeat
swapped = false
for i = 1 to length(A) - 1 inclusive do:
/* if this pair is out of order */
if A[i-1] > A[i] then
/* swap them and remember something changed */
swap( A[i-1], A[i] )
swapped = true
end if
end for
until not swapped
end procedure
(a) Draw the flowchart of the above algorithm.
(b) Draw the corresponding graph and label the nodes as n1, n2, … and edges as e1, e2, …
(c) Calculate the cyclomatic complexity of the above algorithm.
procedure bubbleSort( A : list of sortable items )
repeat
swapped = false
for i = 1 to length(A) - 1 inclusive do:
/* if this pair is out of order */
if A[i-1] > A[i] then
/* swap them and remember something changed */
swap( A[i-1], A[i] )
swapped = true
end if
end for
until not swapped
end procedure
Explanation / Answer
(CYCLOMATIC/MCCABE COMPLEXITY) Consider the following bubblesort sorting algorit
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.