What is the output of the following C program?
#include <studio.h>
int main() {
double a[2]={20.0, 25.0}, *p, *q;
p = a;
q = p + 1;
printf("%d,%d", (int)(q - p), (int)(*q - *p));
return 0;}
Consider an array X that contains n positive integers. A subarray of X is defined to be a sequence of array locations with consecutive indices.
The C code snippet given below has been written to compute the length of the longest subarray of X that contains at most two distinct integers. The code has two missing expressions labelled (P) and (Q).
int first=0, second=0, len1=0, len2=0, maxlen=0; for (int i=0; i < n; i++) { if (X[i] == first) { len2++; len1++; } else if (X[i] == second) { len2++; len1 = (P); second = first; } else { len2 = (Q); len1 = 1; second = first; } if (len2 > maxlen) { maxlen = len2; } first = X[i]; }
Which one of the following options gives the CORRECT missing expressions?
(Hint: At the end of the i-th iteration, the value of len1 is the length of the longest subarray ending with X[i] that contains all equal values, and len2 is the length of the longest subarray ending with X[i] that contains at most two distinct values.)
Which one of the following regular expressions is equivalent to the language accepted by the DFA given below?
Let M be the 5-state NFA with ε-transitions shown in the diagram below.
![GATE CSE 2024 Set 2 Theory of Computation - Finite Automata and Regular Language Question 2 English](https://app-content.cdn.examgoal.net/fly/@width/image/6y3zli1lwug14iu/097d303e-8a05-4f40-a6d1-704bb307186d/beef5c60-1f2a-11ef-b236-4f75b99a7f02/file-6y3zli1lwug14iv.png?format=png)
Which one of the following regular expressions represents the language accepted by M?