Skip to main content

app-ads.txt

 google.com, pub-2203413632152319, DIRECT, f08c47fec0942fa0

Ios Algorithm Interview Questions and Answers

 

1. What is Big O Notation, What Time and Space Complexity 

Answer:- Big O Notation is a mathematical notation describe the limiting behavior of a function when the argument tends towards a particular value or infinity.

बिग ओ नोटेशन एक गणितीय संकेतन है जो किसी फ़ंक्शन के सीमित व्यवहार का वर्णन करता है जब तर्क किसी विशेष मान या अनंत की ओर जाता है।

"Big O Notation is key in Algorithms and Data Structure,  Big O Notation describe the complexity of your code using algebraic terms."

"बिग ओ नोटेशन एल्गोरिदम और डेटा संरचना में महत्वपूर्ण है, बिग ओ नोटेशन बीजगणितीय शब्दों का उपयोग करके आपके कोड की जटिलता का वर्णन करता है।"


Big O Notation describe the worst-case scenarios with the complexity

1. O(1) :-  Constant Complexity -> Execution time does not depend on data size.

For Example -  0(1) operations

let array = [1, 2, 3, 4, 5, 6]

Accessing an element in an array by index.

print(array[0])

print(array[2])

Here is an example of an O(1) constant time complexity function in Swift:

func getFirstElement<T>(of array: [T])->T?{

    return array.first

}


let number = [10,20,30,40,50,60]


if let firstElement = getFirstElement(of: number){

    print("The first element is \(firstElement)")

}else{

    print("array is Empty")

}


Comments