I need a clear-cut understanding. We know a constant-time method is O(1) and a linear-time method is O(N). Please briefly explain type-1 and type-2, and what is the difference. And why type-1, and type-2 will go O(1), and O(N) respectively. Thanks in advance.
Type-1:
func printLoop() {
for p in 0..<100 {
print(p)
}
}
printLoop()
Type-2:
func printLoop(n: Int) {
for p in 0..<n {
print(p)
}
}
printLoop(100)