所屬科目:中山◆電機◆電磁學
1. Suppose we have a byte-addressable machine, i.e., each byte is accessed via an address. Let the locations for an array be allocated in a row-major manner, and each element of an array takes 4 bytes. Assume that the address of the first byte of the array is 500 in all the following cases. Which of the following is true?(A) The address of the element A10 in an array declared as A100 is 24586;(B) The address of the element A1030] in an array declared as A[100[300] is 177899;(C) The address of the element A[10] in an array declared as A[100] is 536;(D) The address of the element A1030 in an array declared as A100300 is 76457217.
2. Let a, b and c are variables. Which of the following is a postfix expression?(A) a/(b + c);(B) xabc/+;(C) abc + /;(D) /a + bc.
3. Let a = 3, b = 8, c = 6 and d = 5. What is the value of the prefix expression × ba + dc?(A) 13;(B) 14;(C) 15;(D) 16.
4. The ADT stack can be defined by the following axioms:(aStack.createStack()).isEmpty() = true(aStack.push(item)).isEmpty() = false(aStack.createStack()).pop() = error(aStack.createStack()).getTop() = error(aStack.push(item)).getTop() = item(aStack.push(item)).pop() = aStackFor the following expression:(((((((aStack.createStack()).push(1)).push(2)).pop()).push(3)).pop()).pop()).isEmpty()what is the value returned?(A) an item;(B) a stack;(C) true;(D) false.
5. Suppose a stack is implemented by a variable top and an array B[4]. Note that top denotes the index of the last element pushed. Initially, the stack is empty. Then the following operations are performed in order:push(1), push(2), pop(), push(3), push(4), pop(), getTop(), push(5), pop(), push(6).Which of the following is true in the end?(A) B[0] = 3;(B) B contains 4 integers available;(C) An overflow occurred, so the operations could not be completely done;(D) top is 2.
6. Let the height of a tree be the number of nodes along the longest path from the root node to the leaf nodes. Consider the integers 30, 41, 25, 29, 94, 37, 70, 23, 65, 75, 68, 67 in order to create a binary search tree. Which of the following is true?(A) The node for 37 is a leaf node;(B) The root node is 41;(C) The node for 70 has only one child;(D) The height of the tree is 5.
7. Consider a complete binary tree with exactly 5000 nodes, implemented with an array starting from index 0. Suppose that a node has its value stored at index 999 in the array. What index is the value stored at for this node's left child?(A) 999;(B) 1999;(C) 998;(D)2998.
8. Consider a tree with A as the root node. The left and right child of A are B and C, respectively. The left and right child of B are D and E, respectively. The left and right child of E are F and G. What is the order of the nodes processed in the pre-order traversal?(A) A-B-E-D-F-G-C;(B) D-B-F-E-A-G-C;(C) A-B-D-G-F-E-C;(D) A-B-D-E-F-G-C.
9. Suppose we start with an empty max-heap of integers, and enter the numbers 20 through 30 into this heap in order. Let the resulting max-heap be stored in an array. What index is 28 stored at in the array?(A) 2;(B) 3;(C) 4;(D) 5.
10. Suppose we start with an empty max-heap of integers, and enter the numbers 20 through 30 into this heap in order. Let the resulting max-heap be stored in an array. Then remove the root node from the heap. What index is 28 stored at in the array?(A) 4;(B) 3;(C) 2;(D) 1.
11. An empty hash table has a capacity of 13, and you insert six entries with keys 21, 16, 8, 10, 22, 34, and 49. Using linear probing and the hash function 1%(13), what index 49 is stored at in the table? Note that % is the remainder operator, e.g., (100)%(13)=9.(A) 0;(B) 5;(C) 11;(D) 8.
12. Consider the integers 30, 41, 25, 29, 94, 37, 70, 23, 65, 75, 68, 67 in order to create an AVL tree. Which of the following about the tree is false?(A) The node for 37 is a leaf node.(B) The root node is 41.(C) The node for 70 has only one child.(D) The height of the tree is 4.
13. Consider the integers 30, 41, 25, 29, 94, 37, 70, 23, 65, 75, 68, 67 in order to create a 2-3 tree. Which of the following about the tree is true?(A) The node for 37 is not a leaf node.(B) The root node is 41.(C) The node for 70 has only one child.(D) The height of the tree is 3.
14. Consider the following recursive definition for a language:Which of the following strings are in this language?(A) + ++(B) + − −(C) – + +(D) + .
15. Consider an array A containing 10 integers 42, 3, 17, 22, 32, 7, 12, 74, 47, 8. We use quicksort to sort the integers in ascending order. The first element of the underlying sequence is used as the pivot. Which of the following are false after the first partition?(A) A[5] = 7(B) A[4] = 42(C) A[8] = 47(D) A[0] = 3
16. Which of the following are true?(A) The worst-case running time for quicksort is O(nlogn).(B) No additional memory for array is required for quicksort.(C) The best-case running time for bubble-sort is O(nlogn).(D) The best-case running time for insertion-sort is O(n).
17. Consider an array A containing, initially, 12 integers 30, 41, 25, 29, 94, 37, 70, 23, 65, 75, 68, 67. We convert A into a maxheap. Which of the following are false?(A) A[2] = 70(B) A[5] = 68(C) A[8] = 23(D) A[11] = 30
18. Consider the integers 30, 41, 25, 29, 94, 37, 70, 23, 65, 75, 68, 67 in order to create a binary search tree. Now delete 70 from the tree. Note that the replacement should be the least of the numbers equal to or greater than the deleted element. Which of the following about the resulting tree are true?(A) The node for 75 has only one child.(B) The node for 65 has a left child.(C) The node for 41 has two children.(D) The node for 65 is a child of the node for 94.
19. Which of the following are true?(A) The minimum height of a binary tree with 100 nodes is 6; (B) The minimum height of a tree with 15 nodes is 2; (C) The maximum height of a tree with 20 nodes is 20; (D) The maximum height of a complete binary tree with 200 nodes is 8.