GATE Download Sample Question Papers GATE – Sample Questions - CSE2
· Added February 2011
1 Consider the following C function void swap (int a, int b) { int temp ; temp = a ; a = b ; b = temp ; } In order to exchange the values of two variables x and y. Options A) call swap (x, y) B) call swap (&x, &y) C) swap (x, y) cannot be used as it does not return any value D) swap (x, y) cannot be used as the parameters are passed by value Your Answer ( Not Answered ) Correct Answer B 2 A 5 stage pipelined CPU has the following sequence of stages: IF - Instruction fetch from instruction memory, RD - Instruction decode and register read, EX - Execute: ALU operation for data and address computation, MA - Data memory access - for write access, the register read at RD stage is used, WB - Register write back. Consider the following sequence of instructions: I 1 : L R0, 1oc1; R0 rightChild ! = NULL) value = max (value, 1 + DoSomething (ptr - > rightChild)) ; } return (value); } The value returned by the function DoSomething when a pointer to the root of a non-empty tree is passed as argument is Options A) The number of leaf nodes in the tree B) The number of nodes in the tree C) The number of internal nodes in the tree D) The height of the tree Your Answer ( Not Answered ) Correct Answer D