1) The algoritm adds 1..2n to a stack, then pops n elements. Meaning that 1..n is left in the stack and the last popped element remains in X.
2) You are correct. The algoritm has complexity: 2 + (2n * 1) + (n * 1) = 3n + 2 = O(3n) = O(n).
3) The algoritm as storing the last popped element in X and then returning X and the last popped element is n + 1, so the answer should be d) n+1.
EDIT
Explanation on 3:
if n > 0:
X := -1
push 2n to the stack
stack = {1, 2, .. n, n + 1, ..., 2n}
pop n elements from the stack and store the popped element in X
first iteration:
X := stack.pop()
stack = {1, 2, .. n, n + 1, ..., 2n - 1}
X = 2n
... until we have popen n numbers.
stack = {1, 2, .. n}
X = n + 1
if n < 1
X := -1
because n < 1 we won't do any iterations in the loops
so X will not change and still be -1