TCS NQT - cap ability

Test Number 11/11

Q: How would you make the middle node of a doubly linked list to the top of the list?
Let assume "X" is the middle node
A. X->next->prev = x->prev x->prev->next = x->next x->next = head head->prev=x 47%
B. x->next = head head->prev=x 20%
C. X->next->prev=x->next x->prev->next = x->prev x->next = head head->prev=x 27%
D. None of these 7%
Solution: Here is no explanation for this answer
Q: Choose the correct option.
Time taken for addition of element in queue is
A. O(1) 34%
B. O(n) 29%
C. O(log n) 35%
D. None of these options 2%
Solution: Here is no explanation for this answer
Q: Choose the correct option.
To create a linked list, we can allocate space and make something point to it, by

writing:

struct-narne *pointer-variable;

Which of the following statement will correctly allocate the space
A. pointer-variable= malloc(sizeof(*struct-narne)); 55%
B. pointer-variable = malloc(sizeof(struct struct-name)); 24%
C. pointer-variable = a!loc(sizeof(struct struct-name)); 10%
D. pointer-variable = alloc(sizeof(*struct-name)); 10%
Solution: Here is no explanation for this answer
Q: Choose the correct option.
Assume single linked list pseudo code as follows?

struct Node {
data
next
}
record List {
Node firstNode
}

function1(List list) {
obsoleteNode = list.firstNode; list.firstNode = list.firstNode.next; free obsoleteNode;
}

function2(node node) {
obsoleteNode = node.next; node.next= node.next.next; free obsoleteNode; }

function3(Node node,Node newNode) {
newNode.next = node.next;node.next= newNode
}

function4(List list, Node newNode) {
newNode.next = list.firstNode; list.firstNode = newNode;
}
A. function1 removes the first node 36%
B. function2 removes node past this one 20%
C. function3 inserts newNode after node 30%
D. function4 inserts newNode after current first node 14%
Solution: Here is no explanation for this answer
Q: Choose the correct option.
A full binary tree with 2n+1 nodes contain
A. n leaf nodes 27%
B. n non-leaf nodes 35%
C. (n-1) leaf nodes 23%
D. (n-1) non-leaf nodes
Solution: Here is no explanation for this answer
Q: Choose the correct option.
What is the postfix form of the following prefix expression -A/B*C$DE
A. ABCDE$*/- 53%
B. A-BCDE$*/- 18%
C. ABC$ED*/- 17%
D. A-BCDE$*/ 13%
Solution: Here is no explanation for this answer
Q: Choose the correct option.
In a circular linked list
A. components are all linked together in some sequential manner. 31%
B. there is no beginning and no end. 42%
C. components are arranged hierarchically. 11%
D. forward and backward traversal within the list is permitted. 16%
Solution: Here is no explanation for this answer
Q: Choose the correct option.
The number of different directed trees with 3 nodes are
A. 2 28%
B. 4 17%
C. 3 38%
D. 5 17%
Solution: Here is no explanation for this answer
Q: Choose the correct option.
The data structure required to evaluate a postfix expression is
A. queue 12%
B. stack 78%
C. array 5%
D. linked-list 5%
Solution: Here is no explanation for this answer
Q: Choose the correct option.
The number of leaf nodes in a complete binary tree of depth d is
A. 2^d 35%
B. [2^(d-1)]+1 26%
C. [2^(d+1)]+1 21%
D. (2^d)+1 18%
Solution: Here is no explanation for this answer
Q: What will be the output of the following pseudo code?

Integer a
Integer p
Set a=8
p=a+5/7*4
print p*8
A. 0
B. 64
C. 7
D. 8
Solution: 64

You Have Score    /11