TCS Placement: Sample Questions 12 - 13 of 502
Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.
Question 12
Explanation
- Assignment Operator (=)
- = is an Assignment Operator in c, c ++ and other programming languages, it is Binary Operator which operates on two operands.
- = assigns the value of right side expression՚s or variable՚s value to the left side variable
- Example:
x = (a + b) ;
y = x;
- Here, when first expression evaluates value of (a + b) . It will be assigned into x and in second expression y = x; value of variable x will be assigned into y.
- Equal To Operator (==)
- It is binary operator which operates on two operands.
- == compares value on left and right side expressions- return 1 if they are equal otherwise return will be 0;
- Example:
int x, y;
x=10;
y=10;
if(x==y)
printf(“True”);
else
printf(“False”);
- When expression x == y evaluates, it will return 1 and “TRUE” will be printed.
Question 13
Describe in Detail Essay▾
In tree construction which is the suitable efficient data structure? (Array, Linked list, stack, Queue)
EditExplanation
- In tree construction linked list is efficient data structure
- Linear data structure where each element is a separate object.
- Each element of a list comprises of two items - the data and a reference to the next node.
- The last node has a reference to null. The entry point into a linked list is called the head of the list- head is not a separate node, but the reference to the first node. If the list is empty then the head is a null reference.
- A linked list is a dynamic data structure- number of nodes in a list is not fixed and can grow and shrink on demand.
- Any application dealing with unknown number of objects like in a tree should use a linked list.
- Diagram shows the linked list implementation of a binary tree.