Q64: Annihilator and identity operators

Question 64: An annihilator for an operator is a value such that when the operator is applied to the annihilator and some other value, the result is the annihilator. For example in arithmetic 0 is the annihilator for multiplication (0*x = 0). An identity for an operator is a value such that when the operator is applied to the identity and some other value, the result is the other value. Similarly, 0 is the identity for addition and 1 for multiplication (0+x = x and 1*x = x).

Which of the following is true for regular expressions?

  1. ∅ + L = L
  2. ∅L = ∅
  3. ∈L = L
  4. All of the above

 

Solution: ∈ is the identity for concatenation operation, and ∅ is the annihilator for concatenation and identity for union. The correct answer is option 4

Q36: Parallel vs Serial Interfaces

Question #36: PCI (peripheral component interface) is one of the most used interface in computer systems. PCI is used for network cards, GPU, and so many peripherals. PCI is a parallel interface and its next version is PCIe (PCI express) which is in fact serial. Why do you think we are moving back to serial interface from parallel?

Options:

A)     Parallel buses have limited speed because of timing skew (time difference of different bus lines of signal reaching at the receiver).

B)     Parallel buses are too much complexity.

C)     We don’t need high bandwidth as provided by parallel buses.

D)    None of these.

 

Solution:

If the skew becomes greater than the clock cycle time, then it becomes impossible to recreate the correct data at the receiver. Hence, the correct answer is option A.

Q35: fork() || fork() && fork()

Question #35: How many total processes will be spawned after executing following program?

int main()

{

fork() || fork() && fork() ;

}

 

Options:

A)     4

B)      8

C)      6

D)     7

 

Solution:

As we have OR after the first fork(), hence both child and parent process will be executed further. After second fork(), we have 4 processes. In one of the case, where in we have child process in each of the fork calls, we have 0 || 0 = 0 till now, hence the next fork() won’t be executed and will return from here. For all other cases, another child will be forked, hence 4+3 = 7 processes. Hence, the correct answer is option D.