11111, 2222, 3333, 4444, 5555, 7777, 8888
Suppose you are using the LZW algorithm to encode the message AABABDACA contents of the dictionary at the beginning of encoding are: (1)A (2)B (3)C (4)D What are the first 4 code words in the output when encoding the above string?
(1) (1) (2) (6)
Suppose you are using the LZW algorithm to encode the message AABABDACA contents of the dictionary at the beginning of encoding are: (1) A (2) B (3) C (4) D What are the first 4 code words in the output when encoding the above string?
(1) (1) (2) (6)
Given below is an implementation of insertion sort. void insertSort(int [] a, int n){ int i, j, x for(i=1; i<n; i++){ x=a[i]; j=i; // Missing statements } } There are some statements missing. Which of the blocks below can be used to get the correct implementation of insertion sort? (1) while (j>=0 && x<a[j-1] ) { a[j] = a[j-1]); j-- }; a[j]=x; (2) while (j>0 && x<a[j-1] ) { a[j] = a[j-1]); j-- }; a[j]=x; (3) while (j>0 && x<a[j-1] ) { a[j] = a[j-1]); a[j] = x, j-- }; (4) while (j>0 && x<a[j] ) { a[j] = a[j-1]); a[j] = x, j-- };;
(2)
Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is linear probing. How the hash table looks like after inserting the following keys sequentially? 25, 41, 14, 32, 191, 51
(3)
Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is Linear probing. How the hash table looks like after inserting the following keys sequentially? 25, 41, 14, 32, 191, 51
(3)
Given the division hash function h(x) = x%M, where M1 = 10 and Collision Resolution is linear probing. How the hash table looks like after inserting the following keys sequentially? 25, 41, 14, 32, 194, 51
(3)
Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution is quadratic probing, i.e. when inserting a key x, the collision is resolved by finding an available position at (h(x) + i^2)%M), i=1, 2, ... How the hash table looks like after inserting the following keys sequentially? 95, 76, 96, 205
(4)
Given the division hash function h(x) = x%M, where M = 10 and Collision Resolution when inserting a key x, the collision is resolved by finding an available position at (h(x) + i*2)%M), i=1, 2, ... How the hash table Looks like after inserting the following keys sequentially? 95, 76, 96, 205
(4)
To implement an AVL tree, a concept balance factor is introduced (bal = height(right)-height(left). An AVL tree is created using data :{10,90,5,1,8,0,2,9}. What is the balance factor of the node 10?
-1
Consider the following pseudocode: declare a queue of characters, which is implemeted by circular array of size 6. while(there are more characters in the word to read) {read a character if a character is '*' then dequeue the queue else enqueue the character into the queue } How the queue looks like after processing the input "How***AreYou***"?
0, 1, 2
The following is the main part of selection sort pseudocode: For i = 0 to n-2 // large loop find a[k], where a[k] = min {afi], a[i+1],...,a[n-1]} if k # i then swap a[i] with a[k] end for Consider the list of ten integers below: 5, 3, 9, 10, 1, 7, 0, 2, 6,4 What is the list after the FIRST TWO iterations of the large Loop in a selection sort? (sorting from smallest to Largest).
0, 1, 9, 10, 3, 7, 5, 2, 6, 4
The following is the main part of selection sort pseudocode: for i := 0 to n-2 // large loop find a[k], where a[k] = min {a[i], a[i+1],...,a[n-1]} if k # i then swap a[i] with a[k] end for Consider the list of ten integers below: 5, 3, 9, 10, 1, 7, 0, 2, 6, 4 What is the list after the FIRST TWO iterations of the large loop in a selection sort? (sorting from smallest to largest).
0, 1, 9, 10, 3, 7, 5, 2, 6, 4
The following is the main part of selection sort pseudocode: for i := 0 to n-2 // large loop find a[k], where a[k] = min {a[i], a[i+1],...,a[n-1]} if k # i then swap a[i] with a[k] end for Consider the list of ten integers below: 5, 3, 9, 10, 1, 7, 0, 2, 6, 4What is the list after the FIRST TWO iterations of the large loop in a selection sort? (sorting from smallest to largest).
0, 1, 9, 10, 3, 7, 5, 2, 6, 4
Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex 1 to the vertex 5. What are the correct order of vertices selected into the set S until the vertex 5 is selected? (Each step a vertex with minimal current distance is selected into S).
1,2,3,4,5
Given the character frequencies A : 36% B : 25% C : 19% D : 15% E : 5% Using Huffman encoding, what is the code for character D? (Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left; and the left branch of a node gets value 0, the right one gets value 1)
100
Given the character frequencies A : 36% B : 25% C : 19% D : 15% E : 5% Using Huffman encoding, what is the code for character D? (Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left and the left branch of a node gets value 0, the right one gets value 1)
100
Given the character frequencies A : 36% B : 25% C : 19% D : 15% E : 5% Using Huffman encoding, what is the code for character D? (Suppose that when constructing a sub tree from 2 nodes we always place node with higher frequency on the left and the left branch of a node gets value 0, the right one gets value 1)
100
The following is the main part of insertion sort pseudocode: for i := 1 to n-1 insert a[i] into sorted sublist {a[0],...,a[i-1]} so that the sortedness is still kept. end foR Consider the list of ten integers below: 15, 4, 2, 11, 9, 7, 12, 3, 7, 5 What is the list after the FIRST TWO steps of insertion sort? (sorting from smallest to largest).
2, 4, 15, 11, 9, 7, 12, 3, 7, 5
The following is the main part of insertion sort pseudocode: for i := 1 to n-1 insert a[i] into sorted sublist {a[0],...,a[i-1]} so that the sortedness is still kept. end for Select the most correct solution: Consider the list of ten integers below: 15, 4, 2, 11, 9, 7, 12, 3, 7, 5 What is the list after the FIRST TWO steps of insertion sort? (sorting from smallest to largest).
2, 4, 15, 11, 9, 7, 12, 3, 7, 5
The following is the main part of insertion sort pseudocode: for i =1 to n-1: insert a[i] into sorted sublist {a[0],...,a[i-1]} so that the sortedness is still kept. end for Select the most correct solution: Consider the List of ten integers below: 15, 4, 2, 11, 9, 7, 12, 3, 7,5 What is the list after the FIRST TWO steps of insertion sort? (sorting from smallest to largest).
2,4, 15, 11, 9, 7, 12, 3, 7,5
The following is the main part of insertion sort pseudocode: For i 1 to n-1 insert a[i] into sorted sublist {a[0],...,a[i-1]} so that the sortedness is still kept. end for Select the most correct solution: Consider the list of ten integers below: 15, 4, 2, 11, 9, 7, 12, 3,7,5 What is the list after the FIRST TWO steps of insertion sort? (sorting from smallest to largest).
2,4, 15, 11,9, 7, 12, 3, 7,5
Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex A to the vertex G. By this algorithm, at each step the label of a vertex is set to the current distance from A to it. What is the label of the vertex F when the shortest path from A to G is determined?
24
Consider the binarySearch() function below: int binarySearch(int [] a, int x, int low, int high) { int t, k; if(low > high) return( -1); k = (low + high) / 2; if(a[k] == x) return(k); if(x<a[k]) return(binarySearch(a,x,low,high-1); else return(binarySearch(a,x,low+1,high); } Suppose the array a is given by the statement: int [] a = {2,4,6,8,10,12,14, 16}; For the call binarySearch(a,7,2, 5), how many calls to this function will be made, including the original call?
3
Consider the binarySearch() function below: int binarySearch(int [] a, int x, int low, int high){ int t, k; if(low > high) return( -1); k = (low + high) / 2; if(a[k] == x) return(k); if(x<a[k]) return(binarySearch(a,x,low,high-1); else return(binarySearch(a,x,low+1,high); } Suppose the array a is given by the statement: int [] a = {2,4,6,8,10,12,14, 16}; For the call binarySearch(a,7,2, 5), how many calls to this function will be made, including the original call?
3
Consider the following function: int fun(int a, int n) { if(n == 0) return(1); int t =fun(a,n/2); if(n%2==0) return(t*t); else return(t*t*a); } For the call fun(3, 3), how many calls to fun will be made, including the original call?
3
Consider the following function: int fun(int a, int n){ if(n == 0) return(1); int t =fun(a,n/2); if(n%2==0) return(t*t); else return(t*t*a); } For the call fun(3, 3), how many calls to fun will be made, including the original call?
3
The following is the main part of bubble sort pseudocode: do swapped := false for i := 0 to n-2 if a[i] > a[i+1] then swap(a[i],a[i+1]) swapped := true end if end for while swapped Consider the list of ten integers below: 5, 3, 10, 11, 1, 8, 0, 2, 6, 4 What is the list after the FIRST iteration (for i = 0 to n-2) in a bubble sort? (sorting from smallest to largest).
3, 5, 10, 1, 8, 0, 2, 6, 4, 11
The following is the main part of bubble sort pseudocode: do swapped := false for i := 0 to n-2 if a[i] > a[i+1] then swap(a[i],a[i+1]) swapped := true end if end for while swapped Consider the list of ten integers below: 5, 3, 10, 11, 1, 8, 0, 2, 6, 4 What is the list after the FIRST iteration (for i = 0 to n-2) in a bubble sort? (sorting from smallest to largest).
3, 5, 10, 1, 8, 0, 2, 6, 4, 11
The following is the main part of bubble sort pseudocode: do swapped := false fori = 0 to n-2 if a[i] > a[i+1] then swap(afi.ali*1)) Swapped = true end if end for while swapped Consider the list of ten integers below: 5, 3, 10, 11, 1, 8, 0, 2, 6,4 What is the list after the FIRST iteration (for i = 0 to n-2) in a bubble sort? (sorting from smallest to largest).
3,5, 10, 1, 8, 0, 2, 6, 4, 11
Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex A to the vertex G. By this algorithm at each step the label of a vertex is set to the current distance from A to it. What is the label of the vertex F when the shortest path from A to G is determined?
30
What is value of the Shift Folding Hash Function if K = 23-45-89-2 and TSize = 100?
59
What is value of the Shift Folding Hash Function if K = 23-45-89-2 and TSize = 100?
59
What is the result of the breadth first traverse of the binary search tree T, after inserting the following keys into the tree sequentially (suppose T is empty before insertion): 7, 8, 4, 0, 1, -1, 10, 24
7, 4, 8, 0, 10, -1, 1, 24
What is the minimum number of nodes in a nearly complete binary tree with height 4? (In a tree the height of root is 1, and a binary tree with height h is called nearly complete if the tree is complete at level d for d = 1, 2, ..., h-1, and the leaves in the last level are all in the leftmost positions).
8
What is value of the Boundary Folding Hash Function if K = 34-56-89-3 and TSize = 100?
91
31. Which of the following data structure is linear type?
All of above
45. A connected graph T without any cycles is called
All of above
69. Pushdown list means:
All of the above
Specify the correct statement about bucket addressing method for handling collision (select the best answer).
All of the statements are incorrect
70. Which of the following is the feature of stack?
All operations are at one end
74. The size of a structure can be determined by a. size of variable name b. size of (struct tag)
Both a and b
Select the most correct statement about complexity of quicksort.
Both best and average cases are O(nlogn) , the worst case is O(n*2)
Select the most correct statement about complexity of quicksort
Both best and average cases are O(nlogn) , the worst case is O(n^2)
Select the most correct statement about complexity of quicksort.
Both best and average cases are O(nlogn) , the worst case is O(n^2)
Select the most correct statement about complexity of selection sort
Both best and worst cases are O(n*2)
Select the most correct statement about complexity of selection sort
Both best and worst cases are O(n^2)
Select the most correct statement about complexity of heapsort
Both best and worst cases are O(nlogn)
Select the most correct statement about complexity of mergesort
Both best and worst cases are O(nlogn)
Given a graph below. What is the output of depth-first traversal from vertex C? (visit nodes in ABC order if there are some nodes having the same selection ability)
C, B, A, E, G, F, D, H
Given a graph below. What is the output of depth-first traversal from vertex C? (visit nodes in ABC order if there are some nodes having the same selection ability)
C,B,A,E,G,F,D
Consider the following pseudocode: declare a queue of characters while(there are more characters in the word to read) {read a character if a character is '*' then dequeue and write the dequeued character to the screen else enqueue the character into the queue } What is written to the screen for the input "Goo**dAft***erno*on" ?
GoodAf
What is the correct definition of a hash function? (Select the best answer)
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
What is the correct definition of a hash function? (Select the best answer)
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
What is the correct definition of a hash function? (Select the best answer)
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 if = h(x) in the table T, where T[i] is used for storing an item having key x or its address
29. Identify the data structure which allows deletions at both ends of the list but insertion at only one en
Input-restricted deque
Specify the correct implementation of pop() method of a stack of Integers. This stack uses the object a of java.util.LinkedList class for storing data and the end of the list is treated as the top of the stack. (Choose the most suitable one)
Integer pop() { if (isEmpty()) return(null); return((Integer) a.removeLast(); }
Which graph representation is the best?
It depends on the problem
Which graph representation is the best?
It depends on the problem.
Specify the disadvantage of hashing algorithm (select the best answer):
It is difficult to expand hash tables because they are based on arrays
Suppose we are considering a singly linked list and p is some node in the list which has successor node. Select the most correct java code snippet that inserts new node with value x after the node p.
Node q = new Node(x); q.next = p.next; p.next = q;
30. Which of the following data structure is non-linear type?
None of above
50. Which of the following case does not exist in complexity theory
Null case
Select the statement that is most correct. Basically, the complexity (worst-case) of search algorithm in singly linked lists is:
O ( n )
Select the statement that is most correct. Basically, the complexity of inserting new element before a given element in the middle of a singly linked lists is
O ( n )
In the worst case, insertion sort algorithm is _______.
O(n^2)
In the worst case, quick sort is .
O(n^2)
In the worst case, quick sort is ______________.
O(n^2)
In the average-case, quicksort is __________.
O(nlogn)
In the best-case, mergesort is __________.
O(nlogn)
In the best-case, quicksort is ........
O(nlogn)
In the best-case, quicksort is __________.
O(nlogn)
In the worst-case merge sort is
O(nlogn)
In the worst-case mergesort is
O(nlogn)
In the worst-case mergesort is ________.
O(nlogn)
Question 1 In the best-case, quicksort is
O(nlogn)
Specify the correct implementation of dequeue() method of a queue. This queue uses the object a of java.util.ArrayList for storing data and the position 0 of the list is treated as the front of the queue. (Choose the most suitable one)
Object dequeue() { if (isEmpty()) return(null); return(a.remove(0)); }
Specify the correct implementation of dequeue() method of a queue. This queue uses the object a of java.util.LinkedList for storing data and the head of the list is treated as the head of the queue. (Choose the most suitable one)
Object dequeue() { if (isEmpty()) return(null); return(a.removeFirst(); }
Specify the correct implementation of dequeue() method of a queue. This queue uses the object a of java.util.ArrayList for storing data and the position 0 of the list is treated as the front of the queue. (Choose the most suitable one)
Object dequeue() { if (isEmpty()) return(null); return(a.remove(0)); }
Suppose we are implementing a queue using a singly linked list where the the head of the list is treated as the head of the queue. Specify the correct implementation of dequeue() method of the queue. (Choose the most suitable one)
Object dequeue() { if(isEmpty()) return(null); Node p = head; head=head.next; if(head==null) tail=null; return(p.info); }
Specify the correct implementation of dequeue() method of the queue. (Choose the most suitable one)
Object dequeue() { if(isEmpty()) return(null); Node p = head; head=head.next; return(p.info); }
Suppose we are implementing a stack using a singly linked list where the head of the list is treated as the top of the stack. Specify the correct implementation of pop() method of the stack. (Choose the most suitable one)
Object pop() { if(isEmpty()) return(null); Node p = head; head=head.next; if(head==null) tail=null; return(p.info);
Specify the correct implementation of pop() method of the stack. (Choose the most suitable one)
Object pop() { if(isEmpty()) return(null); Node p = head; head=head.next; if(head==null) tail=null; return(p.info); }
Suppose you are building a Java class named Student, which encapsulates a student's information. To provide comparison facility for this class, which implementation should be used?
Student implements Comparable
Select the statement that is most correct.
Tail recursion is a special case of recursion in which the last operation of the function, the tail call, is a recursive call
Select the most correct statement about complexity of bubble sort.
The best case is O (1n), and the worst case is O{n*2)
Select the most correct statement about complexity of insertion sort.
The best case is O (1n), and the worst case is O{n*2)
Select the most correct statement about complexity of bubble sort.
The best case is O (n), and the worst case is O(n*2)
Specify the correct statement about open addressing method for handling collision
The collision is resolved by finding an available table entry other than the position to which the colliding key is originally hashed
Consider the following 2 definitions about graph: An undirected graph is called connected when there is a path between any two vertices of the graph. If every node u in undirected graph G is adjacent to every other node v in G, a graph is said to be complete. Which of the following statements is correct:
The complete graph is always connected
Consider the following 2 definitions about graph: An undirected graph is called connected when there is a path between any two vertices of the graph. If every node u in undirected graph G is adjacent to every other node v in G, a graph is said to be complete. Which of the following statements is correct:
The complete graph is always connected
Consider the following 2 definitions about graph: An undirected graph is called connected when there is a path between any two vertices of the graph. If every node u in undirected graph G is adjacent to every other node v in G, a graph is said to be complete. Which of the following statements is correct:
The complete graph is always connected and vise versa
Consider the following 2 definitions about graph: An undirected graph is called connected when there is a path between any two vertices of the graph. If every node u in undirected graph G is adjacent to every other node v in G, a graph is said to be complete. Which of the following statements is correct:
The complete graph is always connected.
Specify the correct statement about hashing algorithm (Select the best answer).
The correct answer is: The expected complexity of hashing algorithm is O(1). However by the collision resolution, sometimes it may take O ( n).
Specify the correct statement about hashing algorithm (Select the best answer).
The expected complexity of hashing algorithm is O(1). However by the collision resolution, sometimes it may take O (n)
Given a description of an algorithm: sort(data[]) { for i = 1 to data.length-1 x = data[i]; move all elements data[j] greater than x by one position from left to right; place x in its proper position; }
This is insertion sort algorithm
In Huffman coding, both the sender and receiver must have a copy of the samecode in order for the decoded file to match the encoded file.
True
In a singly-linked list every element contains some data and a link to the next element, which allows to keep the structure. Select one: A. False B. True
True
In the array implementation, enqueuing can be executed in constant time O(1)
True
In the doubly linked list implementation, dequeuing can be executed in constant time O(1) Select one: A. True B. False
True
In the doubly linked list implementation, enqueuing can be executed in constant time O(1).
True
Linked lists allow easy insertion and deletion of information because such operations have a local impact on the list.
True
Recursive definitions on most computers are eventually implemented using a run-time stack and this implementation is done by the operating system.
True
Skip list helps avoiding sequential search.
True
State True or False: In a singly-linked list, there is no efficient way to insert a node before the last node of the list, but we can insert a node after a given node or at the beginning of the list with time complexity O(1).
True
State True or False: "Recursion bears substantial overhead. Each time the program calls a method, the system must assign space for all of the method's local variables and parameters. This can consume considerable memory and requires extra time to manage the additional space".
True
The advantage of arrays over linked lists is that they allow random accessing.
True
Select the statement that is most correct. Which of the following applications may not use a queue?
Undo sequence in a text editor
Which of the following applications may not use a queue?
Undo sequence in a text editor
43. In a Heap tree
Values in a node is greater than every value in children of it
What is the best case of bubble sort algorithm?
When an array to be sorted is already sorted.
In a graph if e=[u, v], Then u and v are called
all of the other options
52. A linked list index is ____ that represents the position of a node in a linked list.
an Integer
63. What member function places a new node at the end of the
appendNode()
Consider a graph below: cut-vertices in the graph are
b, c, e
Consider a graph below:
b,c,e
The operation for adding an entry to a queue is traditionally called:
enqueue
Select the statement that is most correct.
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
The efficiency of searching elements in a hash table is the same as in a linked list.
False
7. Each array declaration need not give, implicitly or explicitly, the information about
the first data from the set to be stored
60. What happens when you push a new node onto a stack?
the new node is placed at the front of the linked list
35. When representing any algebraic expression E which uses only binary operations in a 2-tree,
the variable in E will appear as external nodes and operations in internal nodes
41. In a binary tree, certain null entries are replaced by special pointers which point to nodes higher in the tree for efficiency. These special pointers are called
thread
State True or False: In a singly-linked list, there is no efficient way to insert a node before the last node of the list, but we can insert a node after a given node or at the beginning of the list with time complexity O(1).
true
23. The situation when in a linked list START=NULL is
underflow
Select the correct statement. Suppose T is a binary tree with 9 nodes. What is the minimum possible height of T? (Note: In a tree the height of root is 1)
4
65. Elements of an array are stored _______ in memory
Sequentially
68. _________ is the way you groups things together by placing one thing on top of another and then removing things one at a time from the top
Stack
Given a text describing the Kruskal's algorithm for finding the minimum spanning tree: "All edges are ordered by weight, each edge is checked to see whether it can be considered part of the tree. It is added to the tree if no cycle arises after its inclusion". Is this statement correct?
Yes, it is correct
Given a text describing the Kruskal's algorithm for finding the minimum spanning tree: "All edges are ordered by weight, each edge is checked to see whether it can be considered part of the tree. It is added to the tree if no cycle arises after its inclusion". Is this statement correct?
Yes, it is correct
The advantage of arrays over linked lists is that they allow random accessing.
true
Suppose we are implementing a queue using a singly linked list where the the end of the list is treated as the end of the queue. Specify the correct implementation of enqueue() method of the queue. (Choose the most suitable one)
void enqueue(Object x) { Node p = new Node(x); p.next = null; if(isEmpty()) head = tail = p; else { tail.next = p; tail = p; } }
Specify the correct implementation of enqueue() method of the queue. (Choose the most suitable one)
void enqueue(Object x) { Node p = new Node(x); p.next = null; if(isEmpty()) head = tail = p; else { tail.next = p; tail = p; } }
Skip list helps avoiding sequential search.
true
2. Which of the following data structure is linear data structure?
Arrays
42. The in order traversal of tree will yield a sorted listing of elements of tree in
Binary search trees
26. A data structure where elements can be added or removed at either end but not in the middle
Deque
34. The depth of a complete binary tree is given by
Dn = log2n+1
Select the correct statement. (Note: full binary tree = proper binary tree = 2-tree)
Every complete binary tree is also a full binary tree
Consider the following pseudocode: declare a queue of characters while(there are more characters in the word to read) {read a character if a character is '*' then dequeue the queue else enqueue the character into the queue } while(the queue is not empty) dequeue and write the dequeued character to the screen What is written to the screen for the input "HowAre**You**To**Day" ?
YouToDay
18. Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called
all of above
44. In a graph if e=[u, v], Then u and v are called
all of above
56. New nodes are added to the _____ of the queue.
back
20. Which of the following statement is false?
pointers store the next data element of a list
The operation for removing and returning the top element of the stack is traditionally called:
pop
Which of the following stack operations could result in stack underflow (become empty)?
pop
The operation for adding an entry to a stack is traditionally called:
push
21. Binary search algorithm can not be applied to
sorted binary trees
48. The complexity of linear search algorithm is
O(n)
In the average-case, quicksort is
O(n*2)
In the worst case, insertion sort algorithm is...............
O(n*2)
In the worst case, quick sort is ...............
O(n*2)
Select the most correct statement about complexity of selection sort
The correct answer is: Both best and worst cases are O(n^2)
What is the correct definition of a hash function? (Select the best answer)
The correct answer is: 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.
Suppose you are using the LZW algorithm to encode the message AABABDACA contents of the dictionary at the beginning of encoding are: (1)A (2)B (3)C (4)D What are the first 4 code words in the output when encoding the above string?
(1) (1) (2) (6)
Hinh anh
(2) j>0
The following is the main part of selection sort pseudocode: for i = 0 to n-2 // large loop find a[k], where a[(k] = min {a[i], a[{i+1],....a[n-1]} if k # i then swap afi] with a[k] end for Consider the List of ten integers below: 5, 3,9, 10, 1, 7, 0, 2, 6,4 What is the List after the FIRST TWO iterations of the large loop in a selection sort? (sorting from smallest to largest).
0,1, 9, 10, 3, 7, 5, 2, 6, 4
Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex 1 to the vertex 5. What are the correct order of vertices selected into the set S until the vertex 5 is selected? (Each step a vertex with minimal current distance is selected into S).
1, 2, 3, 4, 5
Partitioning is a technique used in quicksort. The following is a partition pseudocode: partition the array a from index low to index up x := a[low], i=low, j=up do increase i and stop at i, where a[i]>x decrease j and stop at j, where a[j]<=x if(i<j) swap a[i] with a[j] while(i<j) swap a[0] with a[j] Consider the list of eight integers (n=8) below: 6, 3, 10, 11, 8, 2, 7, 5 What is the list after it is partitioned by the first step of quicksort (low = 0, up = n-1)? (sorting from smallest to largest).
2, 3, 5, 6, 8, 11, 7, 10
67. How many parts are there in a declaration statement?
3
Suppose the h( n) function is defined on the set of integer numbers as below. For the call h(3), how many calls to h will be made, including the original call? int h(int n){ if (n == 0 || n==1) return(1); else return(h(n-1)+h(n-2)); }
5
Suppose the h( n) function is defined on the set of integer numbers as below. For the call h(3), how many calls to h will be made, including the original call? int h(int n) {if (n == 0 || n==1) return(1); else return(h(n-1)+h(n-2)); }
5
Suppose the h( n) function is defined on the set of integer numbers as below. For the call h(3), how many calls to h will be made, including the original call? int h(int n) {if (n == 0 || n==1) return(1); else return(h(n-1)+h(n-2)); }
5
Suppose a multi graph G is given by the adjacency matrix below. Which of the followings is the Euler cycle?
A, B, C, D, B, A
Given a graph below. What is the output of breadth-first traversal from vertex A? (visit nodes in ABC order if there are some nodes having the same selection ability)
A, B, C, G, D, E, F
Using the Huffman code tree below. What is the result of decoding the string: 001000101010100?
AABAABBBBA
38. The post order traversal of a binary tree is DEBFC Find out the pre order traversal
ABDECF
75. The reason for using pointer is ... Choose the false option from the following sentences
Accessing arrays or string elements
16. Which of the following data structure can't store the non-homogeneous data elements?
Arrays
Suppose you are using the LZW algorithm to encode the message AABABCADAB contents of the dictionary at the beginning of encoding are: (1) A (2) B (3) C (4) D What string is denoted by code word (7)?
BA
Suppose you are using the LZW algorithm to encode the message AABABCADAB contents of the dictionary at the beginning of encoding are: (1)A (2)B (3)C (4)D What string is denoted by code word (7)?
BA
The in-order traverse of tree will yield a sorted listing of elements of tree in
Binary search trees
Specify the correct statement about bucket addressing method for handling collision (select the best answer).
Colliding elements in the same position in the hash table are placed on a bucket assosiated with that position.
71. The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is.
D
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.
False
In all binary trees, there are 2i nodes at level i.
False
In circular linked-list, it is always required to define both head and tail nodes.
False
In the array implementation, dequeuing can be executed in constant time O(n)
False
State True or False: "A balanced tree is one whose root has many more left descendents than right descendants, or vice versa."
False
State True or False:"In a binary search tree, all the nodes that are left descendants of node A have key values greater than A; all the nodes that are A's right descendants have key values less than (or equal to)
False
The efficiency of searching elements in a hash table is the same as in linked list
False
64. The _______ function retrieves the value of the size member of the LinkedList class
getSize()
Specify the correct statement about chaining method for handling collision
In chaining, each positions of the table is associated with a linked list or chain of structures whose info fields store keys or references to keys
Specify the correct statement about chaining method for handling collision
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
Specify the correct statement about coalesced chaining method for handling collision (select the best answer).
In coalesced hashing, the linked list is created inside the hash table and a colliding key is put in the last available position of the table
Specify the correct statement about coalesced chaining method for handling collision (select the best answer).
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
Specify the correct statement about coalesced chaining method for handling collision(select the best answer)
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
Select correct statement
In the stack implemented by array, popping is executed in constant time O(1)
Partitioning is a technique used in
Insertion sort
Specify the disadvantage of hashing algorithm (select the best answer)
It is difficult to expand hash tables because they are based on arrays.
55. ______ form of access is used to add and remove nodes from a stack
LIFO
66. Each entry in a linked list is called a _______
Link
49. The complexity of merge sort algorithm is
O(n log n)
Select the statement that is most correct. Which of the following applications may not use a stack?
Multi-programming
Which of the following applications may not use a stack?
Multi-programming
Select the most correct statement.
Naturally a singly linked list is a good choice for queue implementation because both enque and dequeue actions are constant time O(1)
Select the most correct statement:
Naturally a singly linked list is a good choice for queue implementation because both enque and dequeue actions are constant time O(1)
Suppose we are considering a singly 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.
Node f = head; while(f.next != p) f = f.next; Node q = new Node(x); q.next = p; f.next = q;
Partitioning is a technique used in
Quick sort
Partitioning is a technique used in :
Quick sort
Partitioning is a technique used in __________.
Quick sort
An algorithm that calls itself directly or indirectly is known as
Recursion
Specify the reason for data compression (select the best answer)
Saving data storage
Select the most correct statement about complexity of bubble sort.
The best case is O ( n ), and the worst case is O(n^2)
Select the most correct statement about complexity of insertion sort
The best case is O ( n ), and the worst case is O(n^2)
Select the most correct statement about complexity of insertion sort.
The best case is O ( n ), and the worst case is O(n^2)
Specify the correct statement about coalesced chaining method for handling collision (select the best answer).
The correct answer is: 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.
Given a description of an algorithm: sort(data[]) { for i = 1 to data.length-1 x = data[i) move all elements data[j] greater than x by one position from left to right place x in its proper position } Select the most correct statement:
This is insertion sort algorithm
Given a description of an algorithm: sort(data[]){ for i = 1 to data.length-1 x = data[i]; move all elements data[j] greater than x by one position from left to right; place x in its proper position; } Select the most correct statement:
This is insertion sort algorithm
Given a description of an algorithm: sort(data[]) { for i = 1 to data.length-1 x = data[i] move all elements data[ j ] greater than x by one position from left to right place x in its proper position } Select the most correct statement:
This is insertion sort algorithm
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.
True
What ts the best case of bubble sort algorithm?
When an array to be sorted is already sorted
Consider the following pseudocode: declare a queue of characters while(there are more characters in the word to read) {read a character if a character is '*' then dequeue the queue else enqueue the character into the queue } while(the queue is not empty) dequeue and write the dequeued character to the screen What is written to the screen for the input "HowAre**You**To**Day" ?
YouToDay
51. Value of the first linked list index is _______
Zero
.Consider a graph below. Which of the followings is the Hamilton cycle?
a, b, c, d, e, a
Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex a to the vertex f. What are the first 4 vertices selected into the set S? (Each step a vertex with minimal current distance is selected into S).
a, b, c, e
Consider a graph below. Which of the followings is the Hamilton cycle?
a, b,c, d, e, a
Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex a to the vertex f. What are the first 4 vertices selected into the set S? (Each step a vertex with minimal current distance is selected into S).
a,b,c,d
Consider a graph below. Which of the followings is the Hamilton cycle?
a,b,c,d,e,a
46. In a graph if e=(u, v) means
both b and c
47. If every node u in G is adjacent to every other node v in G, A graph is said to be
complete
72. To delete a dynamically allocated array named `a`, the correct statement is
delete a;
The operation for removing and returning the end element of the queue is traditionally called:
dequeue
The operation for removing and returning the end element of the queue is traditionally called:
dequeue Correct
Consider the following pseudocode: declare a stack of characters while(there are more characters in the word to read) {read a character if a character is '*' then pop and write the poped character to the screen else push the character into the stack } What is written to the screen for the input "Good**Mor*ni***ng" ?
dorino
Consider the following pseudocode: declare a stack of characters while(there are more characters in the word to read) {read a character if a character is '*' then pop the stack else push the character into the stack } while(the stack is not empty) pop and write the poped character to the screen What is written to the screen for the input "Good**Mor*ni***ng" ?
gnMoG
73. To create a linked list, we can allocate space and make something point to it, by writing: struct-name *pointer-variable; Which of the following statement will correctly allocate the space
pointer-variable = malloc(sizeof(struct struct-name));
62. A Linked list can grow and shrink in size dynamically at _______
run time
61. What happens when you push a new node onto a stack?
the new node is placed at the front of the linked list
Specify the correct implementation of in-order traverse algorithm for binary trees.
void inOrder(Node p) { if (p != null) { inOrder(p.left); visit(p); inOrder(p.right); } }
11. Which of the following data structures are indexed structures?
linear arrays
Which of the following about queue is true:
A queue is a FIFO structure.
Specify the correct statement about chaining method for handling collision
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
Select the statement that is most correct. Basically, the complexity (worst-case) of search algorithm in singly linked lists is
O ( n )
24. Which of the following is two way list?
doubly linked list
In a singly-linked list every element contains some data and a link to the next element, which allows to keep the structure.
true
Linked lists allow easy insertion and deletion of information because such operations have a local impact on the list.
true
19. The difference between linear array and a record is
All of above
Specify the correct statement about bucket addressing method for handling collision (select the best answer).
Colliding elements in the same position in the hash table are placed on a bucket assosiated with that position
Specify the correct implementation of pop() method of a stack of Integers. This stack uses the object a of java.util.LinkedList class for storing data and the end of the list is treated as the top of the stack. (Choose the most suitable one)
Integer pop() { if (isEmpty()) return(null); return((Integer) a.removeLast(); }
Specify the correct statement about a binary search tree(select the most suitable one).
It is necessary to build a tree with optimized height to stimulate searching operation
22. When new data are to be inserted into a data structure, but there is no available space; this situation is usually called
overflow
10. The memory address of fifth element of an array can be calculated by the formula
LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array
Select the statement that is most correct. Which of the following applications may not use a stack? Select one: A.Undo sequence in a text editor. B.Keeping track of local variables at run time. C.Evaluating arithmetic expressions. D.Multi-programming.
Multi-programming
Specify the correct statement about open addressing method for handling collision
The collision is resolved by finding an available table entry other than the position to which the colliding key is originally hashed
12. Which of the following is not the required condition for binary search algorithm?
There must be mechanism to delete and/or insert elements in list
3. The operation of processing each element in the list is known as
Traversal
32. To represent hierarchical relationship between elements, which data structure is suitable?
Tree
Which of the following data structure is non linear data structure?
Trees
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.
True
Run length encoding is a lossless compression method in which repeated occurrences of a symbol are replaced by one occurrence of the symbol followed by the number of occurrences
True
14. Two dimensional arrays are also called
matrix arrays
17. Which of the following data structure store the non-homogeneous data elements?
Records
40. An algorithm that calls itself directly or indirectly is known as
Recursion
Consider the following pseudocode: declare a stack of characters while(there are more characters in the word to read) {read a character if a character is '*' then pop the stack else push the character into the stack } while(the stack is not empty) pop and write the poped character to the screen What is written to the screen for the input "Good**Mor*ni***ng" ?
gnMoG
37. When converting binary tree into extended binary tree, all the original nodes in binary tree are
internal nodes on extended tree
59. The pop() member function determines if the stack is empty by calling the _____ member function
isEmpty()
57. A _______ is a data structure that organizes data similar to a line in the supermarket, where the first one in line is the first one out.
queue linked list
25. The term "push" and "pop" is related to the
stacks
Suppose you are using the LZW algorithm to encode the message AABABDACA contents of the dictionary at the beginning of encoding are: (1) A (2) B (3) C (4) D What are the first 4 code words in the output when encoding the above string?
(1) (1) (2) (6)
State True or False: In circular linked-list, it is always required to define both head and tail nodes.
False
Select the correct statement. Suppose T is a binary tree with 9 nodes. What is the minimum possible height of T? (Note: In a tree the height of root is 1)
4
Given a raw message 'XXXXUUUUUXXXXUUXXXXXUU' (without single quote). Run the run-length encoding algorithm for that message, what is the output?
4X5U4X2U5X2U
What is the minimum number of nodes in a full binary tree with height 3? (In a tree the height of root is 1, and in a full binary tree every node other than the leaves has two children).
5
33. A binary tree whose every node has either zero or two children is called
Extended binary tree
27. When inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return
FAEKCDHGB
54. _______ form of access is used to add and remove nodes from a queue
FIFO , First In First Out
Consider the following pseudocode: declare a queue of characters while(there are more characters in the word to read) {read a character if a character is '*' then dequeue and write the dequeued character to the screen else enqueue the character into the queue } What is written to the screen for the input "Goo**dAft***erno*on" ?
GoodAf
Suppose we are considering a singly 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.
Node f = head; while(f.next != p) f = f.next; Node q = new Node(x); q.next = p; f.next = q;
Suppose we are considering a doubly linked list and p is some node in the list which has successor node. Select the most correct java code snippet that inserts new node with value x after the node p.
Node p1, p2; p1 = new Node(x); p2 = p.next; p.next = p1; p1.prev = p; p1.next = p2; p2.prev = p1;
Suppose we are considering a singly linked list and p is some node in the list which has successor node. Select the most correct java code snippet that inserts new node with value x after the node p.
Node q = new Node(x); q.next = p.next; p.next = q;
Select the statement that is most correct. Basically, the complexity of inserting new element before a given element in the middle of a singly linked lists is
O ( n )
Suppose we are implementing a stack using a singly linked list where the head of the list is treated as the top of the stack. Specify the correct implementation of pop() method of the stack. (Choose the most suitable one)
Object pop() { if(isEmpty()) return(null); Node p = head; head=head.next; if(head==null) tail=null; return(p.info); }
15. A variable P is called pointer if
P contains the address of an element in DATA
28. Which data structure allows deleting data elements from front and inserting at rear?
Queues
39. Which of the following sorting algorithm is of divide-and-conquer type?
Quick sort
Specify the reason for data compression (select the best answer):
Saving data storage
4. Finding the location of the element with a given value is:
Search
State True or False: "Recursion bears substantial overhead. Each time the program calls a method, the system must assign space for all of the method's local variables and parameters. This can consume considerable memory and requires extra time to manage the additional space".
TRUE
9. The memory address of the first element of an array is called
base address
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 ____________".
base cases
53. Why is the constructor of the LinkedList class empty?
because initialization of data members of the LinkedList class is performed by the constructor of the LinkedList class
13. Which of the following is not a limitation of binary search algorithm?
binary search algorithm is not efficient when the data elements are more than 1000
36. A binary tree can easily be converted into q 2-tree
by replacing each empty sub tree by a new external node
8. The elements of an array are stored successively in memory cells because
by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated
The operation for removing and returning the element of the queue is traditionally called:
dequeue
Which of the following queue operations could result in queue underflow (become empty)?
dequeue
Consider the following pseudocode: declare a stack of characters while(there are more characters in the word to read) {read a character if a character is '*' then pop and write the poped character to the screen else push the character into the stack } What is written to the screen for the input "Good**Mor*ni***ng" ?
dorino
State True or False: "A balanced tree is one whose root has many more left descendents than right descendants, or vice versa."
false
5. Arrays are best data structures
for relatively permanent collections of data
6. Linked lists are best suited
for the size of the structure and the data in the structure are constantly changing