ExamVeda
Login
Home
1
What will be the time complexity of the following code?
#include <bits/stdc++.h> 
using namespace std; 
 
void func(int a[], int n, int k) 
{ 
	if (k <= n) 
	{ 
		for (int i = 0; i < k/2; i++) 
		swap(a[i], a[k-i-1]); 
	} 
 
} 
int main() 
{ 
	int a[] = {1, 2, 3, 4, 5}; 
	int n = sizeof(a) / sizeof(int), k = 3; 
	func(a, n, k); 
	for (int i = 0; i < n; ++i) 
		cout << a[i]<<" ";
	return 0; 
}
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
2
Predefined function rotate() in C++ is available under which header file?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
3
Which among the following is the worst-case time complexity for appending an element in a variable-length array?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
4
Which of the following is not an advantage of bit array?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
5
Suffix array can be created in O(nlogn) time.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
6
What is the time required to locate the occurrences of a pattern P of length m in a string of length n using suffix array?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
7
What is the functionality of the following piece of code?
public Object function(int row_index, int col_index)
{
        if (row_index < 0 || col_index > N)
	{
            System.out.println("column index out of bounds");
			return;
	}
        return (sparse_array[row_index].fetch(col_index));
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
8
How many inversions are there in the array arr = {1,5,4,2,3}?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
9
What will be the time complexity of the following code?
#include <bits/stdc++.h> 
using namespace std; 
 
int min(int x, int y) 
{ return (x < y)? x: y; } 
 
int func(int arr[], int n) 
{ 
 
	int *jump = new int[n]; 
	int i, j; 
 
	if (n == 0 || arr[0] == 0) 
		return INT_MAX; 
 
	jump[0] = 0; 
 
	for (i = 1; i < n; i++) 
	{ 
		jump[i] = INT_MAX; 
		for (j = 0; j < i; j++) 
		{ 
			if (i <= j + arr[j] && jumps[j] != INT_MAX) 
			{ 
				jump[i] = min(jump[i], jump[j] + 1); 
				break; 
			} 
		} 
	} 
	return jump[n-1]; 
} 
 
int main() 
{ 
	int arr[] = {1, 3, 6, 1, 9,7}; 
	int size = sizeof(arr)/sizeof(int); 
	cout<< func(arr,size); 
	return 0; 
}
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
10
Bit fields and Bit arrays are same.
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board