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

46/59

Page

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

How many times is the function recursive_dec_to_bin() called when the following code is executed?
#include<stdio.h>
int arr[31], len = 0;
void recursive_dec_to_bin(int n)
{
      if(n == 0 && len == 0)
      {
          arr[len++] = 0;
          return;
      }
      if(n == 0)
         return;
      arr[len++] = n % 2;
      recursive_dec_to_bin(n/2);
}
int main()
{
    int n = 111,i;
    recursive_dec_to_bin(n);
    for(i=len-1; i>=0; i--)
    printf("%d",arr[i]);
    return 0;
}

Select an option to see the answer and solution.

Consider a reference string:
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 of frame size 3. Using FIFO algorithm, determine the number of page faults.

Select an option to see the answer and solution.

Which of the following is NOT a rule of tower of hanoi puzzle?

Select an option to see the answer and solution.

Given that a graph contains no odd cycle. Is it enough to tell that it is bipartite?

Select an option to see the answer and solution.

From the following given tree, what is the code word for the character 'a'?
Miscellaneous on Data Structures mcq question image

Select an option to see the answer and solution.

What does the following code do?
#include<stdio.h>
int search_num(int *arr, int num, int len)
{
     int i;
     for(i = 0; i < len; i++)
     if(arr[i] == num)
      return i;
     return -1;
}
int main()
{
      int arr[5] ={1,2,3,4,5},num=3,len = 5;
      int indx = search_num(arr,num,len);
      printf("Index of %d is %d",num,indx);
      return 0;
}

Select an option to see the answer and solution.

The number of colors used by a proper edge coloring graph is called?

Select an option to see the answer and solution.

Given items as {value,weight} pairs {{60, 20},{50, 25},{20, 5}}. The capacity of knapsack=40. Find the maximum value output assuming items to be divisible and nondivisible respectively.

Select an option to see the answer and solution.

Which of the following is not true about atbash cipher?

Select an option to see the answer and solution.

In what time can an augmented path be found?

Select an option to see the answer and solution.

Compute the product matrix using Strassen's matrix multiplication algorithm.
Given a11=1; a12=3;a21=5;a22=7
b11=8;b12=4;b21=6;b22=2

Select an option to see the answer and solution.

What is the GCD of a and b?

Select an option to see the answer and solution.

What is the total running time of the binary GCD algorithm?

Select an option to see the answer and solution.

What will be the output of the following code in java?
import java.util.ArrayList;
public class LRU {	
    public static void main(String[] args) {
        int page_frame = 3;
        int page_ref_string[] = {1, 2, 4, 1, 0, 3, 2, 0, 5, 4};
	ArrayList<Integer> s=new ArrayList<>(page_frame);
	int count=0;
	int page_faults=0;
	for(int i:page_ref_string)
	{
	    if(!s.contains(i))
	    {
	    if(s.size()==page_frame)
	    {
	        s.remove(0);
		s.add(page_frame-1,i);
	    }
	    else
		s.add(count,i);
		page_faults++;
		++count;
	    }
	    else
	    {
		s.remove((Object)i);
		s.add(s.size(),i);		
	    }
	}
		System.out.println(page_faults);
    }
}

Select an option to see the answer and solution.

Running key cipher is a variation of?

Select an option to see the answer and solution.

Which of the following is made possible by the use of Polybius square?

Select an option to see the answer and solution.

What is the minimal Hamming distance between any two correct codewords?

Select an option to see the answer and solution.

To which class does the Euler's circuit problem belong?

Select an option to see the answer and solution.

Consider the following iterative solution to find the sum of first n natural numbers:
#include<stdio.h>
int get_sum(int n)
{
      int sm = 0, i;
      for(i = 1; i <= n; i++)
        ________;
      return sm;
}
int main()
{
    int n = 10;
    int ans = get_sum(n);
    printf("%d",ans);
    return 0;
}
Which of the following lines completes the above code?

Select an option to see the answer and solution.

What is the minimum number of cuts that a graph with 'n' vertices can have?

Select an option to see the answer and solution.