0% found this document useful (0 votes)
63 views4 pages

ComputerScience 1A

Uploaded by

Duy Vo Dai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
63 views4 pages

ComputerScience 1A

Uploaded by

Duy Vo Dai
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

1A

DUY TAN UNIVERSITY FINAL EXAM


INTERNATIONAL SCHOOL COURSE: Computer Science for Practicing Engineers CODE: CMU-SE252
CLASS: BIS, DIS, LIS, JIS, PIS, NIS, HIS, FIS DURATION: 90 minutes

Student Name: ___________________________________________ ID: __________________________

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

14. (0.200 Points)


The Merge Sort algorithm is an example for:
A. Divide and Conquer technique. C. Backtracking technique.
B. Dynamic Programming technique. D. Brute Force technique.
15. (0.200 Points)
For the Travelling salesman problem, if the Brute Force technique is used and the number of
the city is 20, the number of tests to find the result is:
A. 20! C. 202
B. 19! D. 192
16. (0.200 Points)
What is correct for the greedy algorithm:
A. Always produce an optimal solution.
B. Solve problem by making the locally optimal choice at each stage with the intent of finding
a global optimum.
C. Make decisions based on the overall problem.
D. All is incorrect.
17. (0.200 Points)
To find the two numbers with the largest product (có tích lớn nhất) in an array of n integers,
using Brute Force technique, the number of pairs to test is:
A. n*n C. n*(n-1)/2
B. n*(n-1) D. n*n/2
18. (0.200 Points)
In order to get the information stored in a Binary Search Tree in the descending order, one
should traverse it in which of the following order?
A. left, root, right. C. right, root, left.
B. root, left, right. D. right, left, root.
19. (0.200 Points)
The time required to delete a node x from a doubly linked list having n nodes is:
A. O (n) C. O (1)
B. O (log n) D. O (n log n)

20. (0.200 Points)


The post order traversal of a binary tree is DEBFCA. Find out the pre-order traversal.
A. ABFCDE C. ABDECF
B. ADBFEC D. ABDCEF

3
1A

PART 2: SHORT ANSWER


21. (0.5 Points)
For the Josephus problem, if n = 13 and k = 4, the order in which the items are excluded (thứ tự
các phần tử bị loại ra khỏi vòng) is:
22. (0.5 Points)
Write function qLR in AVL Tree?
23. (0.5 Points)
Calculate the least number of reading operations when merging 5 files containing 9, 7, 18, 2,
33 elements into a file (trộn 5 file thành 1 file), using greedy algorithm.
24. (0.5 Points)
What is the minimum number of multiplications when calculating X57? Show off your
calculations?
25. (0.5 Points)
Implement the function removing a node from the queue.
26. (0.5 Points)
Implement the function adding a node to the end of the linked list.
PART 3: ESSAY
27.1 (1 point) Draw a table showing process calculating the length of the longest palindromic
substring (chuỗi con đối xứng dài nhất) of the string S=ZXMAXMZ.
27.2 (1 point) Write function calculating the length of the longest palindromic substring of the
string S, using Dynamic Programming technique.
2.7.3 (1 point) Draw the tree after sequentially inserting (chèn tuần tự) the following values into
the AVL tree T: 10, 6, 11, 18, 20, 16, 13, 17, 22, 14.

Bộ môn xét duyệt Giảng viên ra đề

TS. Nguyễn Đức Mận TS. Huỳnh Bá Diệu

You might also like