Lecture 02 - Time Complexity
Lecture 02 - Time Complexity
Lecture # 02
August 28, 2023 Dr. Rabia Maqsood
Fall 2023 [email protected]
FAST – NUCES, CFD Campus
TODAY’S TOPICS
q Time Complexity
q Big-O notation
Option 1: we could implement both algorithms, run them both & compute
execution time
How?
Any issue with this approach?
Expensive and error prone, machine & compiler dependent
(N * time-to-write-one-element) + time-to-open-the-file
(N * time-to-write-one-element) + time-to-open-the-file
O(N log2N) -
if (condition) {
sequence of statements 1
}
else {
sequence of statements 2
}
return max;
}