Consider the following two statements:
S1 – {02n| n ≥ 1|} is regular language.
S2– {0m1n0m+n|m≥1 and n≥1|} is a regular language Which of the following statements is correct?
-
Solution
Let’s consider both the statements separately to find the correct option.
S1: {02n|n≥1|}
Applying the values of n,
→ S1= 00, 0000, 000000, ............The behaviour shown by the output is regular and hence, the language is a regular language.
S2 : {0m1n0m + n| m≥1 and n≥1|}
Applying the values of m and n,S2= 0100, 00110000, 000111000000, .........
Here the values of m and n are kept same so they are showing the output in symmetry but if we use the different values of m and n, then the output will display a behaviour which is not regular.Therefore, confirmed is that S1 is a regular language.
Consider the machine M:
The language recognized by M is
-
Solution
a is followed by two or more than 2b’s so the language recognized by M is {W ∈{a,b}*
An undirected graph G has n nodes. Its adjacency matrix is given by an n × n square matrix whose (i) diagonal elements are 0’s and (ii) non-diagonal elements are 1’s. Which one of the following is true?
Let G be an undirected graph. Consider a depth-first traversal of G,and let T be the resulting depth-first search tree. Let u be a vertex in G and let v be the first new(unvisited) vertex visited after visiting u in the traversal.Which of the following statements is always true?
-
Solution
G is an undirected graph. Now, when G is traversed via depth first. The resultant obtained is T(depth first tree). V is the first vertex visited after visiting u.Now, if u and v are not connected, then no cycle is formed and u is a leaf in T.However, if u and v are connected, then a cycle will be formed.
The elements 32, 15, 20, 30, 12, 25, 16, are inserted one by one in the given order into a max-heap. The resultant max-heap is
Consider the following C program :
main ()
{ int x, y, m, n;
scanf (%d %d, &x, &y);
/ *Assume x> 0 and y> 0 */
m= x; n = y;while (m!= n)
{ if (m > n)
m = m – n;
else
n =n –m;
}
printf (“%d”, n);
}
The program computes
-
Solution
This is an implementation of Euclid's algorithm to find GCD
Here if m> n, then m = m –n
m < n, then n = n – m
Let take X = 24, Y= 9
Then m = 24, n =9iteration m n
1 24 – 9 = 15 9
2 15 – 9 = 6 9
3 6 9 – 6 = 3
4 6– 3 = 3 3Here m = n,so n returned
which is GCD (Greatest common divisor) of X & Y
Hence (c) is correct option.
What is printed by the print statements in the program P1 assuming call by reference parameter passing?
Program P1()
{
x= 10;y= 3;
func1(y, x, x);
print x;
print y;
}
func 1 (x, y, z)
{
y = y + 4;
z = x + y + z;
}
-
Solution
Note the order in which parameters are passed. Inside func1(),x will actually refer to y of main (); and y and z will refer to x of main (). The statement y = y + 4; will result in 14 and statement z = x + y + z will make z = 3 + 14+ 14 = 31(because y and z point to same variable x of main). Since z refers to x of main(), main will print 31.
Consider the following C declaration:
struct {
short s [ 5 ]
union {
float y ;
long z ;
} u;
} t;
Assume that objects of the type short, float and long occupy 2 byte, 4 byte and 8 byte, respectively. The memory requirement for variable t, ignoring alignment considerations, is
-
Solution
The amount of memory required to store a structure variable is the sum of the sizes of all its members. But in the case of union, the amount of memory required is the amount required by its largest member. Therefore u, which is a union member of the struct, occupies only 8 bytes of memory, because the largest memory is 8 bytes consumed by long z;. An other member in the struct is short s [5], this will occupy 10 bytes of memory(2 bytes × 5). Hence total 10 +8 =18 bytes.
A CPU has two modes – privileged and non-privileged. In order to change the mode from privileged to non-privileged
-
Solution
A software interrupt is initiated by some program module which need some CPU services, at that time the two modes can be interchanged. Hence (b) is correct option.
More than one words are put in one cache block to
-
Solution
Cache is the small memory which has a very less access time. So it is used for temporal locality of reference where as virtual memory is for spatial locality of reference.Hence (a) is correct option.