Podcast
Questions and Answers
In the given program to find the sum and average of N numbers, what will be the output if the input is: 'Enter the value of N 4' and then the numbers '10 20 30 40'?
In the given program to find the sum and average of N numbers, what will be the output if the input is: 'Enter the value of N 4' and then the numbers '10 20 30 40'?
- Sum of all numbers = 90.00 Average of all input numbers = 22.50
- Sum of all numbers = 110.00 Average of all input numbers = 27.50
- Sum of all numbers = 100.00 Average of all input numbers = 25.00 (correct)
- Sum of all numbers = 100.00 Average of all input numbers = 20.00
What is the time complexity of the linear search algorithm?
What is the time complexity of the linear search algorithm?
- O(n) (correct)
- O(log n)
- O(1)
- O(n^2)
In the binary search algorithm, if the key is not found in the sorted array, what is the final value of the low
and high
indices?
In the binary search algorithm, if the key is not found in the sorted array, what is the final value of the low
and high
indices?
- low = n-1, high = 0
- low = 0, high = n-1
- low = mid, high = mid
- low = mid+1, high = mid-1 (correct)
In the program to reverse the elements of an array, what is the time complexity of the algorithm?
In the program to reverse the elements of an array, what is the time complexity of the algorithm?
If the input array for the binary search algorithm is [10, 20, 30, 40, 50, 60, 70]
and the key to be searched is 80
, what will be the final values of low
and high
?
If the input array for the binary search algorithm is [10, 20, 30, 40, 50, 60, 70]
and the key to be searched is 80
, what will be the final values of low
and high
?
In the given program to find the sum and average of N numbers, what modification would you make to calculate the product of the N numbers instead of the sum?
In the given program to find the sum and average of N numbers, what modification would you make to calculate the product of the N numbers instead of the sum?
What is the time complexity of the binary search algorithm for a sorted array of size n?
What is the time complexity of the binary search algorithm for a sorted array of size n?
In the binary search algorithm, if the key is not found in the array, which of the following statements is true?
In the binary search algorithm, if the key is not found in the array, which of the following statements is true?
Given an array arr = [5, 2, 8, 1, 9]
, what will be the output of the following code?
int n = sizeof(arr) / sizeof(arr[0]);
for (int i = 0; i < n/2; i++) {
int temp = arr[i];
arr[i] = arr[n-i-1];
arr[n-i-1] = temp;
}
for (int i = 0; i < n; i++) {
printf("%d ", arr[i]);
}```
Given an array arr = [5, 2, 8, 1, 9]
, what will be the output of the following code?
int n = sizeof(arr) / sizeof(arr[0]);
for (int i = 0; i < n/2; i++) {
int temp = arr[i];
arr[i] = arr[n-i-1];
arr[n-i-1] = temp;
}
for (int i = 0; i < n; i++) {
printf("%d ", arr[i]);
}```
What is the best-case time complexity of the linear search algorithm for an array of size n?
What is the best-case time complexity of the linear search algorithm for an array of size n?
What is the sum of all the elements in the array arr = [24, 35, 41, 56, 61, 72, 89]
?
What is the sum of all the elements in the array arr = [24, 35, 41, 56, 61, 72, 89]
?
What is the average of all the elements in the array arr = [24, 35, 41, 56, 61, 72, 89]
?
What is the average of all the elements in the array arr = [24, 35, 41, 56, 61, 72, 89]
?
What is the correct formula to calculate the sum of elements in a one-dimensional array?
What is the correct formula to calculate the sum of elements in a one-dimensional array?
To calculate the average of elements in a one-dimensional array of size n, which expression should be used?
To calculate the average of elements in a one-dimensional array of size n, which expression should be used?
Which code correctly reverses the elements of a one-dimensional array arr of size n?
Which code correctly reverses the elements of a one-dimensional array arr of size n?
What is the time complexity of the linear search algorithm for an unsorted array of n elements?
What is the time complexity of the linear search algorithm for an unsorted array of n elements?
What is the worst-case time complexity of the binary search algorithm for a sorted array of n elements?
What is the worst-case time complexity of the binary search algorithm for a sorted array of n elements?
Which condition is used to terminate the binary search algorithm for a sorted array?
Which condition is used to terminate the binary search algorithm for a sorted array?