Q: Which of the following is NOT a type of linked list?
Solution: We just have 3 types of linked list among the given options b, c, and d. A double-ended linked list does not exist. We just have 3 types of linked list among the given options b, c, and d. A double-ended linked list does not exist.
Q: Each node of the graph is represented as a _______?
Solution: Every node cannot be a root node and path, the edge is related to the directions of the graph.
Q: Recursion uses more memory space than iteration. Which of the following is/are the valid reason for the same? A. It uses the stack instead of a queue B. Every recursion call has to be stored Choose the correct answer from the options given below.
Solution: Recursive functions use the stack as the memory space technique. And also as rightly pointed out the call has to be present to store the returned values.
Q: To which of the following domain problem does the knapsack problem belong?
Solution: knapsack algorithm is used to find the maximum profit out of the least weight combination possible, therefore it definitely belongs to an optimization domain.
Q: Which of the following is not a valid declaration in C? 1.short int x; 2.signed short x; 3.short x; 4.unsigned short x;
Solution: All are valid. First 3 mean the same thing. 4th means unsigned. Expression Evaluation is the favorite question to test your knowledge about combinations of different mathematical operators.
Q: What will be the output of the following code snippet? #includeint foo(int* a, int* b) { int sum = *a + *b; *b = *a; return *a = sum - *b; } int main() { int i = 0, j = 1, k = 2, l; l = i++ || foo(&j, &k); printf("%d %d %d %d", i, j, k, l); return 0; }
Solution: The control in the logical OR goes to the second expression only if the first expression results in FALSE. The function foo() is called because i++ returns 0(post-increment) after incrementing the value of i to 1. The foo() function actually swaps the values of two variables and returns the value of the second parameter. So, values of variables j and k get exchanged and OR expression evaluates to be TRUE.1 2 1 1
Q: What is correct about the below program? #includeint i; int main() { if (i); else printf("Ëlse"); return 0; }
Solution: Since i is defined globally, it is initialized with default value 0. The else block is executed as the expression within if evaluates to FALSE. An empty block is equivalent to a semi-colon(;). So the statements if (i);andif (i) {} are equivalent.
We can divide a large program into the basic building blocks known as a function. The function contains the set of programming statements enclosed by {}. A function can be called multiple times to provide reusability and modularity to a program. In other words, we can say that the collection of functions creates a program.
You can be given a function and ask you the functionality of the functionQ: Consider the following C function
1
2
3
4
5
6
7
void swap ( int x, int y )
{
int tmp;
tmp = x;
x = y;
y = tmp;
}
In order to exchange the values of two variables a and b:Solution: The code will not work because the parameters are passed by value. In order to swap the values of x and y the parameters should be passed with reference. The correct code is:
Q:
Solution:
| You Have Score    | /9 |