ComputerScience 1A
ComputerScience 1A
PART 1: QUIZ
1. (0.200 Points)
In the function reverse the linked list, the right order for 4 statements
(1) p->next =t; (2) t=p; (3) q= p->next; (4) p=q ; is:
A. (2), (3), (4), (1) C. (1), (3), (4), (2)
B. (3), (1), (2), (4) D. (4), (2), (1), (3)
2. (0.200 Points)
In order for the pointer p to point to the last node in the linked list, the command must add into
space is:Node *p= head; while (________) p=p->next;
A. p!=NULL C. p->next->next!=NULL
B. p->next!=NULL D. None of above.
3. (0.200 Points)
The similarity between stack and queue is:
A. Both have the same working principle.
B. Stack and queue is linear data structures they both stores sequentially.
C. The Stack and Queue both are the primitive data structures.
D. None is correct.
4. (0.200 Points)
The similarity between double linked list and binary tree is:
A. Both have the same working C. Both have the same number of link.
principle. D. None is correct.
B. Both of them stores sequentially.
5. (0.200 Points)
Let LCS(Xi,Yj) represent the length of the longest common subsequence of string X and string
Y. The formula to calculate LCS(Xi,Yj) if X[i] <> Y[j] is:
A. LCS(Xi,Yj ) = LCS(Xi-1,Yj-1 )
B. LCS(Xi,Yj ) = LCS(Xi-1,Yj-1 ) +1
C. LCS(Xi,Yj ) = max(LCS(Xi,Yj-1 ), LCS(Xi-1,Yj )
D. LCS(Xi,Yj ) = max(LCS(Xi-1,Yj-1 ), LCS(Xi-2,Yj-2 )
1
Ghi chú: Sinh viên cần làm nháp cẩn thận và chỉ trình bày bài làm trong 1 tờ giấy bảng trả lời.
1A
6. (0.200 Points)
The best complexity of the Largest Sum Contiguous Subarray problem (dãy con liên tiếp có
tổng lớn nhất) is:
A. O(n) C. O(n3)
B. O(n2) D. O(nlgn)
7. (0.200 Points)
To search for an integer x in a sequence of ascending sorted integers, we can use the algorithm:
A. Linear Search. C. Interpolation (nội suy) Search.
B. Binary Search. D. All is correct.
8. (0.200 Points)
The Karatsuba algorithm (procedure) for multiplication of two n-digit numbers requires a
number of elementary operations proportional to:
A. O(n2) C. O(nlog3)
B. O(n3) D. O(nlgn)
9. (0.200 Points)
Which data structure is used for implementing recursion?
A. Queue. C. Arrays.
B. Stack. D. List.
10. (0.200 Points)
In binary search algorithm, the average number of comparison required for searching an
element in a list containing n numbers is:
A. log2 n C. n
B. n /2 D. n – 1
11. (0.200 Points)
What algorithmic paradigm that consists of systematically enumerating all possible candidates
for the solution and checking whether each candidate satisfies the problem's statement?
A. Divide and Conquer. C. Greedy.
B. Dynamic Programming. D. Brute Force.
12. (0.200 Points)
The appropriate algorithm to solve the Eight Queen problem is:
A. Divide and Conquer. C. Backtracking.
B. Dynamic Programming. D. Brute Force.
13. (0.200 Points)
The appropriate algorithm to solve the Graph coloring problem is:
A. Divide and Conquer. C. Backtracking.
B. Greedy. D. Brute Force.
2
1A
3
1A