I am new to Data Structures and Algorithms.
for (int i=0; i<p; i++) {
// Statement
}
This loop have 3 steps. Initializing, comparing and incrementing. Will this be 3n?
I am new to Data Structures and Algorithms.
for (int i=0; i<p; i++) {
// Statement
}
This loop have 3 steps. Initializing, comparing and incrementing. Will this be 3n?
Initialization is performed only once at the start of loop. Comparison and increment is performed in each iteration. In this case there will be p iterations so complexity will be constant ie p or in other words O(n)