



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this past exam are: Dimensional Array, Image Processing, Computer Vision, Dynamic Data, Code Fragment, Function Definition, Function Prototype
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!




Name:
(1.1) T F An objective way to compare two algorithms is by comparing their execution (i.e., machine) times.
(1.2) T F The running time of InsertItem (unsorted lists) is O(N)
(1.3) T F Suppose A is declared as int A[5];. If the base address of the array is 100 and integers take up 4 bytes, the address of A[2] is 110.
(1.4) T F Given the declaration int x=5, *ptr; then the statement *ptr = &x; in main() will cause an error.
(1.5) T F Image processing and computer vision is the same thing.
(2.1) The order of adding 1 to each element in a one dimensional array of N integers.
(a) O (1) (b) O( logN ) (c) O ( N ) (d) O ( NlogN ) (e) O ( N^2 )
(2.2) Which of the following C++ class member functions should be provided if class objects point to dynamic data?
(a) a destructor (b) a constructor (c) a copy-constructor (d) a and b above (e) a, b, and c above
(2.3) To use the template construct, you must put which of the following expressions before the class definition?
(a) class template (b) <template, class, ItemType> (c) template
(2.4) Given the function definition
void Twist(int& a, int b) { int c;
c = a + 2; a = a * 3; b = c + a; }
what is the output of the following code fragment that invokes Twist?
r = 1; s = 2; t = 3; Twist(t, s); cout << r << ’ ’ << s << ’ ’ << t << endl;
(3.3) Demonstrate the binary search algorithm on the list (array-based) shown below. The ele- ment to be retrieved is 10 ( Note: I do not want the code).
6
5
4
3
2
1
0
31
44
54
96
30
220
101
6
5
4
3
2
1
0
31
44
54
96
30
220
101
6
5
4
3
2
1
0
31
44
54
96
30
220
101
6
5
4
3
2
1
0
31
44
54
96
30
220
101
6
5
4
3
2
1
0
31
44
54
96
30
220
101
INIT ITER 1 ITER 2 ITER 3 ITER 4
(3.4) In programming assignment 1, you implemented an algorithm to compute the negative of an image. Describe in simple words how this algorithm works. What is its complexity using big- O notation? Justify your answer.
(3.5) Is the linked-list implementation of a queue always more efficient (in terms of memory) than the array-based implementation? Why or why not?
template