Unsorted Arrays vs Binary Search
1. How do you describe an array?
2. What is the time complexity of traversing through all the elements in an array of size ?
3. Let us consider the following code:
int a = 0, b[N];
for (i = 0; i < M; i++) {
a += i;
}
for (i = 0; i < N; i++) {
scanf("%d", &b[i]);
a += b[i];
}What are the space and time complexities of the above code?
4. Let us consider the following four arrays:
A = [9, 5, 11, 25, 7, 35]
B = [1, 2, 9, 15, 27]
C = [29, 27, 27, 18, 4, 2]
D = [1, 8, 2, 5, 6, 7, 8, 9]
Which of the arrays are sorted in either ascending or descending order?
A = [9, 5, 11, 25, 7, 35]
B = [1, 2, 9, 15, 27]
C = [29, 27, 27, 18, 4, 2]
D = [1, 8, 2, 5, 6, 7, 8, 9]
Which of the arrays are sorted in either ascending or descending order?
5. If, for large inputs, algorithm X is a better choice than algorithm Y, then which statement best describes their asymptotic efficiency?
6. In an unsorted array, which search technique can be used without first rearranging the elements?
7. What is the worst-case time complexity of searching for a particular value in an unsorted array of size using linear search?
8. Which property of an array allows direct access to an element using its index?
9. An unsorted array contains elements. Which statement about finding whether a particular value exists in the array is correct when no additional information about the data is available?