84.
Which of the following is/are advantages suffix array one suffix tree?
I. Lesser space requirement
II. Improved cache locality
III. Easy construction in linear time

86.
What will be the time complexity of the following code?
#include <bits/stdc++.h> 
using namespace std; 
void func(int arr[], int left, int right) 
{ 
    if (left >= right) 
    return; 
 
    int temp = arr[left];  
    arr[left] = arr[right]; 
    arr[right] = temp; 
 
    func(arr, left + 1, right - 1);  
}      
 
void printArray(int arr[], int size) 
{ 
    for (int i = 0; i < size; i++) 
    cout << arr[i] << " "; 
} 
 
int main() 
{ 
	int arr[] = {1,2,3,4}; 
	int n = sizeof(arr) / sizeof(arr[0]); 
	func(arr, 0, n-1); 
	printArray(arr, n); 
	return 0; 
}

87.
Choose the appropriate code that counts the number of non-zero(non-null) elements in the sparse array.

public int count()
{
        int count = 0;
        for (List cur = this.next; (cur != null); cur = cur.next)
        {
            count++;
        }
        return count;
}

public int count()
{
        int count = 0;
        for (List cur = this; (cur != null); cur = cur.next)
        {
            count++;
        }
        return count;
}

public int count()
{
        int count = 1;
        for (List cur = this.next; (cur != null); cur = cur.next)
        {
            count++;
        }
        return count;
}

public int count()
{
    int count = 1;
    for (List cur = this.next; (cur != null); cur = cur.next.next)
    {
        count++;
    }
    return count;
}

89.
What will be the auxiliary space requirement of the following code?
#include <bits/stdc++.h> 
using namespace std; 
void func(int arr[], int left, int right) 
{     
	while (left < right) 
	{ 
		int temp = arr[left]; 
		arr[left] = arr[right]; 
		arr[right] = temp; 
		left++; 
		right--; 
	} 
 
}	
 
void printArray(int arr[], int size) 
{ 
    for (int i = 0; i < size; i++) 
    cout << arr[i] << " "; 
} 
 
int main() 
{ 
	int arr[] = {1,4,3,5}; 
	int n = sizeof(arr) / sizeof(arr[0]); 
	func(arr, 0, n-1); 
	printArray(arr, n); 
	return 0; 
}

Read More Section(Arrays in Data Structures)

Each Section contains maximum 100 MCQs question on Arrays in Data Structures. To get more questions visit other sections.