Câu hỏi: CSD201 Cấu trúc dữ liệu và giải thuật – Bộ ôn tập thi lại số 3
50 câu trắc nghiệm kèm lời giải của môn CSD201 - Cấu trúc dữ liệu và giải thuật, xếp đúng thứ tự trong đề.
Danh sách câu hỏi
void fun(int n)
{if(n > 0)
{System.out.print(" " + n );
fun(n-2);
}
}What is the output when the statement fun(9); is run?
void fun(int n)
{int m = n/2;
int k = n%2;
if (m > 0)
{fun(m);
}
System.out.print(k + " ");
}What is the output when the statement fun(11); is run?
Node p1,p2; p1 = p.next;
p2 = p1.next;
p.next = p2;
if(p2!=null) p2.prev=p;int fun(int n)
{if (n < 0)
return(fun(-n));
else if(n<5)
return(2);
else
return(n*fun(n/2));
}What is the value of fun(-3)?
void fun(int n)
{System.out.print(" " + n % 5);
fun(n/3);
}What will happen if the statement fun(21); is run?
while(S is not empty){ch = top element of the stack S if ch is isolated then remove it from the stack and put it to E
elseselect the first vertex Y (by alphabet order), which is adjacent to ch,push Y to S and remove the edge (ch,Y) from the graph
}the last array E obtained is an Euler cycle of the graph Suppose a multigraph G is given below (view picture). Which of the followings is the Euler cycle from the vertex B, created by above algorithm?
int x = 17;
Node q = new Node(x);
q.prev=null;
q.next = head;
head.prev = q;
head = q;void fun(int n)
{if (n < 0)
{System.out.println(“-“);
fun(-n);
}
else if(n<10)
System.out.println(n);
else
{fun(n/10);
System.out.println(n%10);
}
}What values of n are directly handled by the stopping (base) case?
O(n^2)O(n)O(log n)O(1)while(there are more characters in the word to read){read a character if a character is '*' then pop the stack
else
push the character into the stack
}
while(the stack is not empty)pop and write the poped character to the screen What is written to the screen for the input "Good**Morn**in***g" ?
gMoGgMooGoMggMorvoid fun(int n)
{int m = n/2;
int k = n%2;
System.out.print(k + " ");
if (m > 0)
{fun(m);
}
}What is the output when the statement fun(12); is run?