Vidyalelo
Data Structure · all questions

Miscellaneous on Data Structures
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

1,171

Questions

58/59

Page

Pick an option on a question to see the right answer and solution.

Let A={1, 2, 3} B={2, 3, 4} C={1, 3, 5} D={2, 3}. Find the cardinality of sum of all the sets.

Select an option to see the answer and solution.

What is the output of the following code?
#include<stdio.h>
int get_max_element(int *arr,int n)
{
      int i, max_element = arr[0];
      for(i = 1; i < n; i++)
        if(arr[i] > max_element)
          max_element = arr[i];
      return max_element;
}
int get_min_element(int *arr, int n)
{
      int i, min_element = arr[0];
      for(i = 1; i < n; i++)
        if(arr[i] < min_element)
          min_element = arr[i];
      return min_element;
}
int main()
{
     int n = 7, arr[7] = {5,2,4,7,8,1,3};
     int max_element = get_max_element(arr,n);
     int min_element = get_min_element(arr,n);
     printf("%d %d",max_element,min_element);
     return 0;
}

Select an option to see the answer and solution.

Beaufort cipher and variant beaufort cipher are same ciphers.

Select an option to see the answer and solution.

What is the time complexity of the above recursive implementation of binary search?

Select an option to see the answer and solution.

How many 2*2 matrices are used in this problem?

Select an option to see the answer and solution.

The sum and composition of two polynomials are always polynomials.

Select an option to see the answer and solution.

Consider the following number of activities with their start and finish time given below. In which sequence will the activity be selected in order to maximize the number of activities, without any conflicts?
Activity Starting time Finish time
A1 1 2
A2 2 5
A3 1 5
A4 3 6
A5 6 8
A6 4 9

Select an option to see the answer and solution.

Cross product of two vectors can be used to find?

Select an option to see the answer and solution.

Consider the following recursive implementation of linear search:
#include<stdio.h>
int recursive_search_num(int *arr, int num, int idx, int len)
{
     if(idx == len)
     return -1;
     if(arr[idx] == num)
       return idx;
     return __________;
}
int main()
{
      int arr[5] ={1,3,3,3,5},num=2,len = 5;
      int indx = recursive_search_num(arr,num,0,len);
      printf("Index of %d is %d",num,indx);
      return 0;
}
Which of the following recursive calls should be added to complete the above code?

Select an option to see the answer and solution.

What will be the plain text corresponding to ciphered text "MAO" if atbash cipher is used for encryption?

Select an option to see the answer and solution.

What is the time complexity of the following code used to find the length of the string?
#include<stdio.h>
int get_len(char *s)
{
      int len = 0;
      while(s[len] != '\0')
        len++;
      return len;
}
int main()
{
      char *s = "lengthofstring";
      int len = get_len(s);
      printf("%d",len);
      return 0;
}

Select an option to see the answer and solution.

What is the alternative name of playfair cipher?

Select an option to see the answer and solution.

What will be the cost of the code if character ci is at depth di and occurs at frequency fi?

Select an option to see the answer and solution.

Who invented Hamming codes?

Select an option to see the answer and solution.

The running time of Chan's algorithm is obtained from combining two algorithms.

Select an option to see the answer and solution.

What is the rule for encryption in playfair cipher if the letters in a pair does not appear in same row or column?

Select an option to see the answer and solution.

What will be the plain text corresponding to cipher text "ACCFYX" if trithemius cipher is used?

Select an option to see the answer and solution.

Who was the first person to solve the maximum matching problem?

Select an option to see the answer and solution.

Which of the following statement is not true regarding columnar transposition cipher?

Select an option to see the answer and solution.

What is the time complexity of the recursive implementation used to find the largest and smallest element in a linked list?
#include<stdio.h>
#include<stdlib.h>
struct Node
{
     int val;
     struct Node* next;
}*head;
int max_of_two(int a, int b)
{
      if(a > b)
        return a;
      return b;
}
int recursive_get_max(struct Node* temp)
{
      if(temp->next == 0)
        return  temp->val;
      return max_of_two(temp->val,recursive_get_max(temp->next));
}
int min_of_two(int a, int b)
{
      if(a < b)
        return a;
      return b;
}
int recursive_get_min(struct Node* temp)
{
      if(temp->next == 0)
        return  temp->val;
      return min_of_two(temp->val,recursive_get_min(temp->next));
}
int main()
{
     int n = 9, arr[9] ={1,3,2,4,5,0,5,6,7},i;
     struct Node *temp, *newNode;
     head = (struct Node*)malloc(sizeof(struct Node));
     head -> next =0;
     temp = head;
     for(i=0;i<n;i++)
     {
           newNode =(struct Node*)malloc(sizeof(struct Node));
           newNode->next = 0;
           newNode->val = arr[i];
           temp->next =newNode;
           temp = temp->next;
     }
     int max_num = recursive_get_max(head->next);
     int min_num = recursive_get_min(head->next);
     printf("%d %d",max_num,min_num);
     return 0;
}

Select an option to see the answer and solution.