1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which of the following statements about multi-dimensional arrays is true?
What is the default value assigned to uninitialized elements in an array?
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[5] = {1, 2, 3, 4, 5};
cout << arr[3] << endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[] = {1, 2, 3, 4, 5};
cout << arr[10] << endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[5];
cout << arr[0] << endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[5] = {1, 2, 3, 4, 5};
cout << arr << endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[5] = {1, 2, 3, 4, 5};
cout << arr << endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[5] = {1, 2, 3, 4, 5};
cout << sizeof(arr) << endl;
return 0;
}
What is the output of the following code snippet?
#include <iostream>
using namespace std;
int main() {
int arr[5] = {1, 2, 3, 4, 5};
cout << sizeof(arr) / sizeof(arr[0]) << endl;
return 0;
}
Which sorting algorithm has the worst-case time complexity of O(n^2)?
Which sorting algorithm can be implemented using a recursive approach?
What is the output of the following code snippet?
#include <iostream>
using namespace std;
void swap(int& a, int& b) {
int temp = a;
a = b;
b = temp;
}
void bubbleSort(int arr[], int n) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
swap(arr[j], arr[j + 1]);
}
}
}
}
int main() {
int arr[] = {5, 2, 4, 6, 1, 3};
int n = sizeof(arr) / sizeof(arr[0]);
bubbleSort(arr, n);
cout << arr[3] << endl;
return 0;
}
Which sorting algorithm has the best average-case time complexity?
Which sorting algorithm is known for its simplicity and suitability for small input sizes?