GATE 2018
65 questions
MCQ 41 · NAT 241-mark 30 · 2-mark 35
Questions 11–15 of 65
Which one of the following is a closed form expression for the generating function of the sequence , where for all n = 0, 1, 2,...?
Answer: (D)
Generating function:
Final result:
Final result:
Consider the following C program.
#include <stdio.h>
struct Ournode{
char x,y,z;
};
int main(){
struct Ournode p = {'1', '0','a'+2};
struct Ournode *q = &p;
printf("%c,%c",*((char*)q+1),*((char*)q+2));
return 0;
} The output of this program is:Answer: (A)
The struct stores the characters '1', '0' and 'a' + 2 = 'c' one after another in memory. (char*)q + 1 points to the 2nd byte, which is '0'. (char*)q + 2 points to the 3rd byte, which is 'c'. The %c format prints a character with no quotes.
Answer: 0, c
Answer: 0, c
A queue is implemented using a non-circular singly linked list. The queue has a head pointer and a tail pointer, as shown in the figure. Let n denote the number of nodes in the queue. Let enqueue be implemented by inserting a new node at the head, and dequeue be implemented by deletion of a node from the tail.
Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure?
Which one of the following is the time complexity of the most time-efficient implementation of enqueue and dequeue, respectively, for this data structure?
Answer: (B)
Let us check each operation:
- Enqueue at the head: make a new node and link it to the old head .
- Dequeue at the tail: to delete the tail, we need the node just before it. A singly linked list has no back link, so we must travel from the head .
Answer:
- Enqueue at the head: make a new node and link it to the old head .
- Dequeue at the tail: to delete the tail, we need the node just before it. A singly linked list has no back link, so we must travel from the head .
Answer:
Let and denote the Exclusive OR and Exclusive NOR operations, respectively. Which one of the following is NOT CORRECT?
Answer: (D)
(A) XNOR is the complement of XOR, so . Correct.
(B) Complementing one input of an XOR flips its output, so . Correct.
(C) Complementing both inputs of an XOR leaves the output unchanged, so . Correct.
(D) , so the left side is . Also , so the right side is . Since , this one is not correct.
Answer: (D)
(B) Complementing one input of an XOR flips its output, so . Correct.
(C) Complementing both inputs of an XOR leaves the output unchanged, so . Correct.
(D) , so the left side is . Also , so the right side is . Since , this one is not correct.
Answer: (D)
Consider the following processor design characteristics.
I. Register-to-register arithmetic operations only
II. Fixed-length instruction format
III. Hardwired control unit
Which of the characteristics above are used in the design of a RISC processor?
I. Register-to-register arithmetic operations only
II. Fixed-length instruction format
III. Hardwired control unit
Which of the characteristics above are used in the design of a RISC processor?
Answer: (D)
A RISC processor follows a load/store design, so arithmetic works only between registers. Its instructions have a fixed length, which makes decoding easy. It also uses a fast hardwired control unit. So all three points are true.
Answer: I, II and III
Answer: I, II and III