Find Big O Notation: CS 2321 (Data Structures and Algorithms) Assignment 1 (Algorithm Analysis)
Find Big O Notation: CS 2321 (Data Structures and Algorithms) Assignment 1 (Algorithm Analysis)
1. 𝑷𝒓𝒐𝒗𝒆
𝟓𝒏 𝒍𝒐𝒈 𝟐 𝒏 + 𝟖𝒏 − 𝟐𝟎𝟎 = 𝑶(𝒏 𝒍𝒐𝒈 𝟐 𝒏)
𝒏𝟐 + 𝟒𝟐𝒏 + 𝟕 = 𝑶(𝒏𝟐 )
𝟐 𝒍𝒐𝒈 𝟐 𝒏 + 𝟐 = 𝑶…………….
𝒏 + 𝟐 = 𝑶…………….
𝟐𝒏 + 𝟏𝟓𝒏𝟏/𝟐 = 𝑶…………….
𝒏 𝒍𝒐𝒈 𝟐 𝒏 + 𝒏𝟐 = 𝑶…………….
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
How would the complexity change if the second loop went to N instead of M?
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
c) A nested loop in which the number of times the inner loop executes
depends on the value of the outer loop index:
for (i = 0; i < N; i++) {
for (j = N; j > i; j--) {
sequence of statements
}
}
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
……………………………………………………………………………………………………
Do your best
Wamda