CSD201 full ko bt
Select the statement that is most correct. Suppose we are considering a singly linked list and p is some node in the list which has successor node. What does the java code snippet below do? Node q = p.next; p.next = q.next; A. It deletes the node p. B. It deletes the node after p. C. It deletes the node before p. D. It does not make any change on the list.
B
A recursive method may be eliminated by using ................. Choose one answer. a. Iteration statements b. Stacks c. All of the others.
a
Binary search algorithm cannot be applied to [A] sorted linear array [B] Binary search tree [C] sorted singly linked list
a
In a singly-linked list, there is no efficient way to insert a node before a given node in the middle or at the end of the list, but we can insert a node after a given node or at the beginning of the list with time complexity 0(1) A. False B. True
a
In run-length encoding algorithm, a run is defined as ... Choose one answer. a. number of different characters in the input. b. size of the result of encoding input data. c. amount of time required to the compression algorithm. d. a sequence of identical characters.
a
In the array implementation of the queue, which operations require constant time? Choose one answer. a. isEmpty b. enqueue c. dequeue d. All of the others.
a
Select the most correct statement about the complexity of heapsort [A] Best case is O(nlogn). the worst case is O(n^2) [B] The best case is O(n), and the worst case is O(n^2) [B] Both best and worst cases are O(nlogn) [D] The best case is O(n), and the worst case is O(nlogn)
a
In a linked list, the tail node is introduced for performance purpose only. A. True B. False
a
The height of a complete binary tree with n nodes is A. nlog₂n B. nlog₂(n+1) C. log₂(n) D. log₂(n+1)
D
8. The elements of an array are stored successively in memory cells because A. by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated B. the architecture of computer memory does not allow arrays to store other than serially C. both of above D.none of above
a
(Choose 1 answer) Consider the following function: void fun(int n) {if(n > 0) {System out print" " +n % 5): fun(n): } } whatwi happen if the statement fun(33); is run? A. The runtime stack overflows, halting the program B. The results are nondeterministic C. The operating system detects the infinite recursion because of the "repeated state" D. The program keeps running until you press Ctrl-C
a
11. Which of the following data structures are indexed structures? A. linear arrays B. linked lists C.both of above D. none of above
a
15. A variable P is called pointer if A. P contains the address of an element in DATA B.P points to the address of first element in DATA C.P can store only memory addresses D. P contain the DATA and the address of DATA
a
23. The situation when in a linked list START=NULL is A. underflow B. overflow C.housefull D. saturated
a
29. Identify the data structure which allows deletions at both ends of the list but insertion at only one en A. Input-restricted deque B.Output-restricted deque C. Priority queues D. None of above
a
5. Arrays are best data structures A. for relatively permanent <bền vững> collections of data B.for the size of the structure and the data in the structure are constantly changing C. for both of above situation D. for none of above situation
a
Select the most correct statement about the complexity of insertion sort . Choose one answer. a. The best case is O( n ), and the worst case is O( n^2 ) b. The best case is O( n ), and the worst case is O( nlogn ) c. The best case is O( nlogn ), and the worst case is O( n^2 ) d. Both best and worst cases are O( n^2 )
a
Select the most correct statement: A. In all cases the selection sort is O(n^2) B. In the average case the selection sort is O(n^2), in the best case it is O(nlog n) C. In the worst case the selection sort is O(n^2), in the best case it is O(n) D. In the worst case the selection sortis O(n^2). in the best case itis O(nlog n)
a
Select the statement that is most correct. A. A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more base cases, B. For a recursive method to terminate there must be one or more steps C. For a recursive method to terminate there must be one or more limit conditions, D. There is no difference between a recursive method and a non-recursive method.
a
Select the statement that is most correct. Suppose we are considering a doubly linked list which is not empty. What does the java code snippet below do? Node q = new Node(x); q.prev=null; q.next = head; head.prev = q; head = q; [A] It inserts new node with value x at the head of the list. [B] It inserts new node with value x after the head of the list.
a
Select the statement that is most correct. Which of the following applications may use a stack? [A] Undo sequence in a text editor. [B] Multi-programming [C] Store all variables in a program, [D] Store a waiting list of printing jobs|
a
Select the statementthatis most correct. [A] Tail recursion is a special case of recursion in which the last operation of the function, the tail call, is a recursive call. [B] Tail recursion is a special case of recursion in which the first operation of the function, is a recursive call.
a
Specify the correct statement about chainina method for handling collision A. In chaining, the linked-listis used instead of array for a hash table B. In chaining, some positions of the table is associated with a linked list or chain of structures whose info fields store keys or references to keys C. In this method, the table can never overflow if free memory is available, because the linked listis extendible. D. None of others
a
Specify the correct statement about chaining method for handling collision [A] In chaining, each position of the table is associated with a linked list or chain of structures whose info fields store keys or references to keys [B] In chaining, the linked-list is used instead of array for a hash table [C] In chaining, only some positions ofthe table is associated with a linked list or chain of structures whose info fields store keys or references to keys: [D] None of others
a
State True or False: Definition of a balanced tree: "A balanced tree is one whose root has many more left descendents than right descendants, or vice versa." A. False B. True
a
Study the following statements: (1) A drawback of a balanced tree is the search-time may be out of control. (2) The DSW algorithm can be used to rebalance a binary tree. (3) An AVL tree is one in which the height of the left and the right subtrees of the every node must be same. The statement (1) is ....., the statement (2) is ...... and the statement (3) is ...... Choose one answer. a. False, true, false b. True, false, true c. True, true, true d. False, false, false
a
Suppose we are considering a doubly linked list and p is some node in the list which has predecessor node. Select the most correct java code snippet that inserts new node with value x before the node p. (previs a link to predecessor node), A. Node f = p.prev; Node q = new Node(x); q.prev = f; q.next=p; f.next=q; p.prev=q; B. Node f =p.prev; Node q = new Node(x); q.prev = f; q.next = p; f.next = q; C. Node f = p.prev; Node q = new Node(x); q.prev = f; q.next = p; f.next = q; D. Node f = p.prev; Node q = new Node(x)' q.prev = f; f.next = q; p.prev= q;
a
Suppose we are considering a singly linked list which has at least 2 nodes. Select the most correct java code snippet that deletes the last node [A] Node f= head; while(f.next != tail) f= f.next; f.next = null; tail = f; [B] Node f = head; while(f != tail) f = f.next; f.next = null; tail = f; [C] Node f = head; while(f.next != tail) f = f.next; tail =f; [D] Node f= head; while(f.next != tail) f = f.next; f.next = null;
a
The operation for removing and returning the end element of the queue is traditionally called: A. dequeue B. remove C. peek D. delete
a
What is the number of comparisons and swaps in the best case for creating a heap using top down method (William's method)? Choose one answer. a. The number of comparisons is n - 1 and swaps is zero. b. The number of comparisons is 2.[n/2] and swaps is zero. c. The number of comparisons is n and swaps is zero. d. The number of comparisons is lgn and swaps is zero.
a
What is the worst-case time for finding an element in a Binary tree? Choose one answer. a. O( n ) b. O( n² ) c. O(lgn) d. O( 1 )
a
What type of the hash functions that can be used in an English - Vietnamese dictionary? Choose one answer. a. Radix transformation b. Extraction c. Mid-square function d. Folding
a
When a method call is executed, which information does its activation record contain? Choose one answer. a. None of the others. b. Current depth of recursion. c. Global variables. d. Name of the method. e. Code of the method.
a
When representing any algebraic expression E which uses only binary operations in a 2-tree (every node other than the leaves has two children), [A] the variable in E will appear as external nodes and operations in internal nodes t [B] the variables and operations in E will appear only in internal nodes [C] the variables and operations in E will appear only in external nodes [D] the operations in E will appear as external nodes (leaves) and variables in internal nodes
a
Which of the following Sorting algorithms have complexity of O( n ) in best case ? Choose one answer. a. Insertion sort b. Selection sort c. Buble sort d. All of the others.
a
Which of these operations are likely to have a constant time for worst-case in the singly linked lists? Choose one answer. a. None of the others. b. removeLastOccurrence (): Removes the last occurrence of the specified element in list. c. get(int index):Returns the element at the specified position in this list. d. InsertAfter (int index) : insert a new element into after an element in the list.
a
Which traversal method is used in Adaptive Huffman tree? Choose one answer. a. Breadth First traversal b. Inorder traversal c. Postorder traversal d. Preorder traversal
a
In the circular array version of the Queue class, which operations require O ( n ) linear time for their worst-case behavior Choose at least one answer. a. clear() b. dequeue() c. enqueue() when the capacity has been reached d. firstEl()
ac
14. Two dimensional arrays (mảng 2 chiều) are also called A. tables arrays B. matrix arrays C.both of above D. none of above
b
22. When new data are to be inserted into a data structure, but there is no available space; this situation is usually called A. underflow B.overflow C.housefull D. saturated
b
28. Which data structure allows deleting data elements from front and inserting at rear? A.Stacks B. Queues C. Deques D. Binary search tree
b
4. Finding the location of the element with a given value is: A. Traversal B. Search C. Sort D.None of above
b
6. Linked lists are best suited A. for relatively permanent collections of data B.for the size of the structure and the data in the structure are constantly changing C. for both of above situation D. for none of above situation
b
A graph can be used to show relationships. From the following list of people belonging to the same club (vertices) and their friendships (edges): Peope = {George, Jim, Jean, Frank, Fred, John, Susan} Friendship = {(George, Jean), (Frank, Fred), (George, John), (Jim, Fred), (Jim, Frank), (Jim, Susan), (Susan, Frank)} Find all friends of friends of Jean. Choose one answer. a. Jim and George b. John and Jean c. Nobody d. Fred, Frank and Susan
b
A queue is implemented using a doubly linked list, which of the following operations require O( n ) time? Choose one answer. a. enqueue b. clear (remove all elements from the queue). c. None of the others. d. dequeue
b
Arrays are the best data structures [A] for the size ofthe structure and the data in the structure are constantly changing [B] for relatively permanent collections of data
b
Fill in blank to form a correct statement: "A recursive method is a method that invokes itself directly or indirectly. For a recursive method to terminate there must be one or more_____ A. steps B. base cases C. conditions D. limit conditions
b
Fill in the blank of the statement to form the most correct one: A _____ node contains some data and one link to its successor and one link to its predecessor in the list. [A] binary search tree [B] doubly linked list [C] skip list [D] singly linked list
b
Imagine we have the singly linked list, the head reference allows to manage this list. Show what would happen if we applied the following statements to this list? for (temp = head; temp.next != null; temp = temp.next) { } temp.next = head; Choose one answer. a. Insert the temp node successfully. b. This will create a circularly linked list. c. Nothing happens, the temp reference points at the end of the list. d. We have lost control this list, the head is overwritten by the other reference.
b
In Huffman coding, both the sender and receiver must have a copy of the same code in order for the decoded file to match the encoded file. A. False B. True
b
Select the statement that is most correct. Suppose we are considering a doubly linked list and p is a node in the list which has both predecessor and successor nodes. What does the java code snippet below do? Node p1,p2; p1 = p.prev; // prev is a link to previous node p2=p.next; p2.prev = p1; p1.next = p2; Choose one answer. a. It deletes the node after p. b. It deletes the node p. c. It deletes the node before p. d. It does not make any change on the list.
b
Selectthe statement that is most correct. Basically, the complexity of counting the number of items in a doubly-linked list is A. O(1) B. O(n) C. O(nlogn) D. O(n^2)
b
Selectthe statement that is most correct. Basically, the complexity of inserting a node before a given node in a doubly linked lists is A. O(n^2) B. O(n) C. O(1) D. O(log n)
b
Specify the correct implementation of pop() method ofa stack of Integers. This stack uses java.util.LinkedList for storing data and the end of the listis treated as the top of the stack. (Choose the most suitable one) A. Integer pop() { if (isEmpty()) return(null); return((Integer) pool.removeLast(); } B. Integer pop() { if (isEmpty()) return; return((Integer) pool.remove(pool.size()-1)); } C. Integer pop() { if (isEmpty()) return(null); return((Integer) pool.remove(pool size())); } D. void pop(Integer x) { if (isEmpty()) return(null); pool.remove(pool size()-1); }
b
Specify the correct statement about hashing algorithm (Select the best answer). [A] If the coalesced method is used for colision resolution, insertion and searching (and sometimes deletion) always take constant time: O(1) [B] The expected complexity of hashing algorithm is O(1). However by the collision resolution, sometimes it may take O(n) [C] If the chaining method is used for collision resolution, insertion and searching (and sometimes deletion) can take constant time: O(1) [D] No matter how many data items there are, insertion and searching (and sometimes deletion) always take constant time: O(1)
b
There are two approaches to writing repetitive algorithms: Choose one answer. a. direct recursion and indirect recursion. b. iteration and recursion. c. tail recusion and nontail recursion. d. nested recursion and excessive recursion.
b
Whatis the correct definition of a hash function? (Select the best answer) [A] Hash function h(x) is a function which transforms a particular key (string, or number) into an index i= h(x) in the table T. where T[i] is used for storing an item having key x or its address. [B] Hash function h(x) is a function which transforms a particular key x, be it a string, number, record, or the like. into an index i= h(x) in the table T. where T[i] is used for storing an item having key x or its address. [C] Hash function h(x) is a function which transforms a particular key x, be it a string, number, record, or the like. into a positive integer. [D] Hash function h(x) is a function which transforms a particular key x, be it a string, number, record, or the like. into non-negative integer.
b
When the compiler compiles your program, how is a recursive call treated differently than a non-recursive method call? Choose one answer. a. Primitive values are all treated as reference variables. b. None of the others c. There is no duplication of local variables. d. Reference variables are all treated as primitive values.
b
Which of the following queue operations could result in queue underflow (become empty)? [A] enqueue [B] dequeue [C] isEmpty
b
Which of the following statements about graph coloring is true: Choose one answer. a. The complexity of sequential Coloring algorithm is O ( |V| ) , where |V| is number of vertices. b. Sequential Coloring algorithm establishes the sequence of vertices and a sequence of color before coloring them. c. In sequential coloring algorithm, vertices must be ordered according to indices already to the vertices. d. In sequential coloring algorithm, vertices must be ordered according to degree of vertices.
b
Selectionsort and quicksort both fall into the same category of sorting algorithms. What is this category? Choose at least one answer. a. Divide-and-conquer sorts b. Interchange sorts c. O(n log n) sorts d. Worst time is quadratic
bd
Which statements are true (select two): A. In a singly-linked list there is no efficient way to iffsert a node before a given node in the middle of the list (the action is considered efficient fis complexity is O(1)). B. In a singly-linked list we can insert a node after a given node with time complexity O(n) C. In a singly-linked list we can insert a node before a given node in the middle ofthe listwith time complexity O(1) D. In a singly-linked listwe can insert a node after a given node with time complexity O(1)
bd
1. Which of the following data structure is non linear data structure? A.Arrays B. Linked lists C.Trees D.None of above
c
12. Which of the following is not the required condition for binary search algorithm? A.The list must be sorted B.there should be the direct access to the middle element in any sublist C. There must be mechanism to delete and/or insert elements in list D. none of above
c
2. Which of the following data structure is linear data structure? A.Trees B. Graphs C. Arrays D.none of the above
c
25. The term "push" and "pop" is related to the A.array B. lists C. stacks D. all of above
c
Fill in the blank of the statement to form the most correct one: In a ____ every element contains some data and a link to the next element, which allows to keep the structure. [A] doubly linked list [B] skip list [C] singly linked list [D] binary search tree
c
If every node u in G is adjacent to every other node v in G, a graphs said to be A finite B. isolated C. complete D. strongly connected
c
Select the best choice about a linked structure. Choose one answer. a. Deleting an element from it is efficiently. b. Inserting a new element to it is efficiently. c. All of the others d. It needs more memory spaces for linking elements.
c
Select the statement that is most correct. Basically, the complexity of finding the position of the minimum value in a doubly-linked list of integer numbers is A. O(1) B. O(n^2) C. O(n) D. O(log n)
c
Select the statement that is most correct. Which of the following applications may not use a stack? A. Keeping track of local variables a trun time B. Undo sequence in a text editor. C. Multi-programming D. Evaluating arithmetic expressions.
c
Select the statement that is most correct. Which of the following applications may use a queue? [A] Store all variables in a program. [B] Store a waiting list of printing jobs. [C] Keeping track of local variables at run time. [D] Undo sequence in a text editor.
c
Specify the correct implementation of pop() method ofa stack. This stack uses java.util.ArrayList for storing data and the end of the listis treated as the top of the stack. (Choose the most suitable one) [A] Object pop() {if (isEmpty()) return(null); return(pool.remove(pool.size())); } [B] void pop(Object x) { if (isEmpty()) return(null); pool.remove(pool.size()-1); } [C] Object pop() {if isEmpty()) return(null); return(pool.remove(pool.size()-1)); } [D] Object pop() { if isEmpty()) retum, retum(pool.remove(pool-size(-1)); }
c
Specify the correct statement about bucket addressing method for handling collision (select the best answer). [A] Bucketis a linked list which holds items in the hash table. [B] A bucket is a block of space which is large enough to store all colliding items [C] Colliding elements in the same position in the hash table are placed on a bucket assosiated with that position [D] All of the statements are incorrect.
c
Specify the correct statement about coalesced chaining method for handling collision (select the best answer). [A] Because in coalesced hashing, the linked list is created inside the hash table, thus the searching raust be carried out sequentially [B] In coalesced hashing, the linked list is created inside the hash table and a colliding key is put in the first available position of the table. [C] In coalesced hashing, the linked list is created inside the hash table. Each position pos in the table contains 2 fields: info and next. The next field contains the index of the next key that is hashed to pos [D] In coalesced hashing, the linked list is created outside the hash table and a colliding keys are put in the list connected to the colliding position of the table.
c
Specify the statement that is most correct about a circular linked list. A. In circular linked-list, it is required to define both head and tail nodes B. Circular linked list is a normal doubly-linked list C. Circular linked list is a linked list in which the last node of he list points to the first node in the list D. Circular linked list is a normal singly linked list
c
Suppose temp refers to some node in a doubly linked list. What boolean expression can be used to check whether temp refers to the first node of the list? Choose one answer. a. temp.previous.next.previous == null b. temp == null c. temp.previous == null d. All of the others.
c
The operation for adding an entry to a stack is traditionally called: A. insert B. append C. push D. add
c
We implement the stack as a singly linked list and use AddtoHead() method of the linked list to implement push() method. A top pointer of the stack is ... Choose one answer. a. Any one reference. Depending on the node that is accessed. b. Nothing. We need a doubly linked list. c. The head reference of the singly linked list. d. The tail reference of the singly linked list.
c
Which of the following algorithms in graphs can be implemented by extending Depth First Search algorithm? Choose one answer. a. The Chinese Postman Tour b. All of the others. c. Cycle detection. d. Finding the shortest path (Dijkstra algorithm)
c
Which of the following applications may use a stack? [Al Store all variables in a program. [B] Multi-programming. [C] Auxiliary data structure for algorithms [D] Store a waiting lst of printing jobs.
c
Which of the following stack operations could result in stack underflow? A. isEmpty B. push C. pop D. None of these
c
Which of the following statements is true: Choose one answer. a. All the sorting methods implemented in java is applied to any basic data type except bool type. b. For objects comparison, a comparison criterion must be implemented by user. c. All of the others.
c
13. Which of the following is not a limitation of binary search algorithm? A. must use a sorted array B.requirement of sorted array is expensive when a lot of insertion and deletions are needed C.there must be a mechanism to access middle element directly D. binary search algorithm is not efficient when the data elements are more than 1000.
d
19. The difference between linear array and a record is A. An array is suitable for homogeneous data but hte data items in a record may have different data type B. In a record, there may not be a natural ordering in opposed to linear array. C. A record form a hierarchical structure but a lienear array does not D. All of above
d
24. Which of the following is two way list? A.grounded header list B.circular header list C. linked list with header and trailer nodes D.doubly linked list
d
26. A data structure where elements can be added or removed at either end but not in the middle A.Linked lists B.Stacks C.Queues D.Deque
d
3. The operation of processing each element in the list is known as A.Sorting B. Merging C. Inserting D.Traversal
d
30. Which of the following data structure is non-linear type? A. Strings B. Lists C. Stacks D. None of above
d
9. The memory address of the first element of an array is called A. floor address B.foundation address C. first address D. base address
d
Consider the binary tree below. Which statement is correct? (full binary tree = proper binary tree = 2-tree) [A] The tree is neither complete nor full. [B] The tree is both full and complete. [C] The tree is complete but not full. [D] The tree is full but not complete.
d
Consider the following pseudocode: declare a queue of characters, which is implemented by circular array of size 6. while(there are more characters in the word to read) {read a character if characteris '*' then dequeue the queue else enqueue the character into the queue } How the queue looks like after processing the input "Hello****Wor''*'*'ld*"? A. (1) B. (4) C. (3) D. (2)
d
In a circular singly linked list, we can use only one permanent reference, the tail. The familiar reference, the head, is: Choose one answer. a. The null reference. b. The predecessor of the tail. c. The implicit reference. d. The successor of the tail.
d
Select incorrect statement: Choose one answer. a. The characteristic feature of extendible hashing is the organization of the index, which is expandable table. b. A reorganization of the file is avoided by using extendible hashing if the directory overflows. c. Extendible hashing is faster than and requires less space than Linear hashing. d. Linear hashing is a directoryless technique.
d
Select the most correct statement about the complexity of quicksort A. Both best and worst cases are O(n^2) B. The best case is O(n). and the worst case is O(n^2) C. The best case is O(n). the average case is O(nlogn), and the worst case is O(n^2) D. Both best and average cases are O(nlogn). the worst case is O(n^2)
d
Select the statement that is most correct. Basically, the complexity of inserting new element before a given node in the middle of a singly linked lists is [A] O(1) [B] O(log n) [C] O(n^2) [D] O(n)
d
The Java Collections Framework contains a Map interface. An implementation of this interface is ... Choose one answer. a. Singly Linked List b. Connected Graph c. Priority Queue d. HashTable
d
The complexity of heap sort is A. O(n) B. O(log n) C. O(n^2) D. O(nlog n)
d
Which of the following Sorting algorithms use Divide and Conquer strategy? Choose one answer. a. Heap sort b. Radix sort c. Bubble sort d. Quick sort
d
With respect to the execution of recursive function (method), ....... Choose one answer. a. The run-time stack does not contain dynamic link to caller's activation record. b. All parameters will be shared in all running activation records of the called methods. c. The run-time stack contains an information that marks that this is a recursive call. d. None of the others.
d