CSD201

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

B

In a graph if e=[u, v], Then u and v are called Select one: A. adjacent nodes B. all of the other options C. neighbors D. endpoints of e

D

Specify the correct implementation of in-order traverse algorithm for binary trees. Select one: A. void inOrder(Node p) { if (p == null) { inOrder(p.left); visit(p); inOrder(p.right); } } B. void inOrder(Node p) { inOrder(p.left); visit(p); inOrder(p.right); } C. void inOrder(Node p) { if (p != null) { visit(p); inOrder(p.left); inOrder(p.right); } } D void inOrder(Node p) { if (p != null) { inOrder(p.left); visit(p); inOrder(p.right); } }

B

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) A." Select one: A. True B. False

C

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. Select one: A. Node f = head; while(f.next != p) f = f.next; Node q = new Node(x); q.next = null; f.next = q; B. Node f = head; while(f != p) f = f.next; Node q = new Node(x); q.next = p; f.next = q; C. Node f = head; while(f.next != p) f = f.next; Node q = new Node(x); q.next = p; f.next = q; D. Node f = head; while(f.next != p) f = f.next; Node q = new Node(x); q.next = f; f.next = q;

A

Select the statement that is most correct. Basically, the complexity (worst-case) of search algorithm in singly linked lists is: A. O ( n ) B. O(log n) C. O(1) D. O(n^2)

A

In the doubly linked list implementation, dequeuing can be executed in constant time O(1) Select one: A. True B. False

A

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? Select one: A. -1 B. 2 C. 0 D. 1

A

Which of the following applications may not use a stack? Select one: A. Multi-programming. B. Keeping track of local variables at run time. C. Undo sequence in a text editor D. Evaluating arithmetic expressions.

D

Which of the following queue operations could result in queue underflow (become empty)? Select one: A. isEmpty B. enqueue C. Two or more of the other choices D. dequeue

A

An algorithm that calls itself directly or indirectly is known as Select one: A. Recursion B. Polish notation C. Sub algorithm D. Traversal algorithm

C

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? Select one: A. 2 B. 5 C. 3 D. 4

C

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 ____________". Select one: A. limit conditions B. conditions C. base cases D. steps

B

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? Select one: A. No, it is incorrect B. Yes, it is correct

B

In all binary trees, there are 2i nodes at level i. Select one: A. True B. False

B

In the array implementation, dequeuing can be executed in constant time O(n) Select one: A. True B. False

A

In the array implementation, enqueuing can be executed in constant time O(1) Select one: A True B False

A

Linked lists allow easy insertion and deletion of information because such operations have a local impact on the list. Select one: A. True B. False

A

Skip list helps avoiding sequential search. Select one: A. True B. False

B

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) Select one: A. Object dequeue() { if (isEmpty()) return(null); return(a.remove(a.size())); B. Object dequeue() { if (isEmpty()) return(null); return(a.remove(0)); } C. void dequeue(Object x) { if (isEmpty()) return(null); a.remove(a.size()-1); } D. Object dequeue() {if (isEmpty()) return; return(a.remove(a.size()-1)); }

D

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). Select one: A. 4 B. 6 C. 7 D. 5

A

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? Select one: A. 3 B. 8 C. 9 D. 2

C

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" ? Select one: A. GoodAE B. GoodAT C. GoodAf D. fAdooG

B

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" ? Select one: A. gnoMo B. gnMoG C. GoMng D. gnMoo

A

In the doubly linked list implementation, enqueuing can be executed in constant time O(1). A. True B. False

B

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) Select one: A. 2 B. 4 C. 3 D. 5

A

Select the correct statement. (Note: full binary tree = proper binary tree = 2-tree) Select one: A. Every complete binary tree is also a full binary tree. B. Every full binary tree is also a complete binary tree. C. No binary tree is both complete and full. D. Every binary tree is either complete or full.

C

Select the most correct statement: Select one: A. Using array for queue implementation may be the best choice. B. A doubly linked list is better choice than a singly linked list for queue implementation. C. Naturally a singly linked list is a good choice for queue implementation because both enque and dequeue actions are constant time O(1). D. None of the others is true

d

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 Select one: O(log n) O(1) O(n^2) O ( n )

D

Select the statement that is most correct. Select one: A. For a recursive method to terminate there must be one or more limit conditions. B. There is no difference between a recursive method and a non-recursive method. C. For a recursive method to terminate there must be one or more steps. D. 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

Select the statement that is most correct. Select one: A. Tail recursion is a special case of recursion in which the first operation of the function, is a recursive call. B. Tail recursion is a special case of recursion in which the last operation of the function, the tail call, is a recursive call.

A

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) Select one: A. Object dequeue() { if (isEmpty()) return(null); return(a.removeFirst(); } B. void dequeue(Object x) { if (isEmpty()) return; a.remove(a.size()-1); } C. void dequeue(Object x) { if (isEmpty()) return(null); a.remove(a.size()-1); } D. Object dequeue() { if (isEmpty()) return(null); return(a.removeLast()); }

A

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) Select one: A. Integer pop() { if (isEmpty()) return(null); return((Integer) a.removeLast(); } B. void pop(Integer x) { if (isEmpty()) return(null); a.remove(a.size()-1); } C. Integer pop() { if (isEmpty()) return(null); return((Integer) a.remove(a.size())); } D. Integer pop() {if (isEmpty()) return; return((Integer) a.remove(a.size()-1));

A

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). Select one: A. True B. False

A

State True or False: In circular linked-list, it is always required to define both head and tail nodes. Select one: A. False B. True

B

State True or False: "A balanced tree is one whose root has many more left descendents than right descendants, or vice versa." Select one: A. True B. False

B

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". Select one: A. False B. True

D

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)); } Select one: A. 4 B. 2 C. 3 D. 5

A

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)); } Select one: A. 5 B. 4 C. 2 D. 3

B

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. A. Node p1, p2; p1 = new Node(x); p.next = p1; p1.prev = p; p2 = p.next; p1.next = p2; p2.prev = p1; B. Node p1, p2; p1 = new Node(x); p2 = p.next; p.next = p1; p1.prev = p; p1.next = p2; p2.prev = p1; C. Node p1, p2; p1 = new Node(x); p.next = p1; p1.prev = p; p1.next = p2; p2.prev = p1; p2 = p.next;

A

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. Select one: A. Node q = new Node(x); q.next = p.next; p.next = q; B. p.next = new Node(x); p=p.next; C. Node q = new Node(x); p.next = q; q.next = p.next; D. Node q = new Node(x); q.next = null; p.next = q;

A

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) Select one: A. void enqueue(Object x) { Node p = new Node(x); p.next = null; if(isEmpty()) head = tail = p; else { tail.next = p; tail = p; } } B. void enqueue(Object x) { Node p = new Node(x); p.next = null; if(isEmpty()) head = tail = p; else tail.next = p; } C. void enqueue(Object x) { Node p = new Node(x); p.next = null; tail.next = p; tail = p; }

A

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) Select one: A. Object dequeue() { if(isEmpty()) return(null); Node p = head; head=head.next; if(head==null) tail=null; return(p.info); } B. Object dequeue() { if(isEmpty()) return(null); Node p = head; head=head.next; if(head==tail) tail=null; return(p.info); } C. Object dequeue() { if(isEmpty()) return(null); Node p = head; head=head.next; return(p.info); }

A

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) Select one: A. Object pop() { if(isEmpty()) return(null); Node p = head; head=head.next; if(head==null) tail=null; return(p.info); B. } Object pop() { if(isEmpty()) return(null); Node p = head; head=head.next; if(head==tail) tail=null; return(p.info); C. } Object pop() { if(isEmpty()) return(null); Node p = head; head=head.next; return(p.info); }

A

The advantage of arrays over linked lists is that they allow random accessing. Select one: A. True B. False

a

The advantage of arrays over linked lists is that they allow random accessing. Select one: A.True B.False

C

The in-order traverse of tree will yield a sorted listing of elements of tree in Select one: A. Heaps B. Binary trees C. Binary search trees D. None of others

D

The operation for removing and returning the end element of the queue is traditionally called: Select one: A. delete B. remove C. peek D. dequeue

D

The operation for removing and returning the top element of the stack is traditionally called: Select one: A. peek B. delete C. remove D. pop

D

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). Select one: A. 7 B. 9 C. 6 D. 8

A

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 Select one: A. 7, 4, 8, 0, 10, -1, 1, 24 B. 24, 10, 8, 7, 4, 1, 0, -1 C. -1, 0, 1, 4, 7, 8, 10, 24 D. 7, 4, 8, 0, 10, 1, -1, 24

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 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" ? Select one: A. ouToDay B. eYouToDa C. yaDoTuoY D. YouToDay

A

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" ? Select one: A. dorino B. dorinM C. dorinG D. dorioM

D

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: Select one: A. The complete graph is always connected and vise versa. B. None of the other options C. The connected graph is always complete. D. The complete graph is always connected.

A

Recursive definitions on most computers are eventually implemented using a run-time stack and this implementation is done by the operating system. Select one: A. True B. False

A

Select the statement that is most correct. Which of the following applications may not use a queue? Select one: A. Undo sequence in a text editor. B. Store a waiting list of printing jobs. C. Multi-programming. D. Auxiliary data structure for algorithms.

B

State True or False: 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

B

The operation for adding an entry to a queue is traditionally called: Select one: A. add Incorrect B. enqueue C. append D. insert

B

The operation for adding an entry to a stack is traditionally called: Select one: A. insert B. push C. append D. add

A

Which of the following stack operations could result in stack underflow (become empty)? Select one: A. pop B. isEmpty C. Two or more of the other choices D. push


Set pelajaran terkait

Chapter 14 Skin, Hair, and Nails

View Set

NUR 114- Iggy Perfusion Practice

View Set

Prescott's Microbiology Chapter 1

View Set

Electronics Components Bucket Day Questions

View Set