P1 CSD

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

Suppose that obj is an Object variable and that it refers to an Integer object. If s is a String variable, then which statement is correct about the assignment "s = (String) obj;"? A. The statement will not compile. B. The statement will compile, but there will be a run-time exception. C. The statement will compile and run with no exception.

b

Which of the following applications may use a queue? A. Undo sequence in a text editor. B. Multi-programming. C. Keeping track of local variables at run time. D. Store all variables in a program.

b

Which statements are true (select two): A. In a singly-linked| list we can insert a node after a given node with time complexity 0(n) B. In a singly-linked list we can insert a node after a given node with time complexity 0(1) C. In a singly-linked list we can insert a node before a given node in the middle of the list with time complexity 0(1) D. In a singly-linked list there is no efficient way to insert a node before a given node in the middle of the list (the action is considered efficient if it's complexity is 0(1)).

b d

Select the most correct statement about the complexity of bubble sort A. Both best and worst cases are 0(n~2) B. The best case is 0(n). and the worst case is 0(nlogn)| C. The best case is 0(n). and the worst case is 0(n~2) D. The best case is O(nlogn). and the worst case is 0(n~2)

c

Specify the correct statement about chaining method for handling collision A. None of others B. In this method, the table can never overflow if free memory is available, because the linked list is extendible. C. 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 D. In chaining, the linked-list is used instead of array for a hash table

c

Entries in a stack are "ordered". What is the meaning of this statement? A. A collection of stacks can be sorted. B. Stack entries may be compared with the '<' operation. C. The entries must be stored in a linked list. D. There is a first entry, a second entry, and so on.

d

Select the most correct statement about the complexity of insertion sort A. The best case is 0(n), and the worst case is O(nlogn) B. The best case is O(nlogn). and the worst case is 0(n~2) C. Both best and worst cases are 0(n~2) D. The best case is 0(n). and the worst case is 0(n~2)

d

Suppose cursor refers to a node in a linked list (using the IntNode class with instance variables called data and link). What statement changes cursor so that it refers to the next node? A. cursor++; B. cursor = link; C. cursor += link; D. cursor = cursor.link;

d

The complexity of heap sort is Answer A. 0(log n) B. 0(n) C. O(r02) D. 0(nlog n)

d

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

d

What is a primary difference between an array and a Vector from Java's Class Libraries: A. Vectors can have more than one index. B. Vectors can have negative integers as indexes. C. Vectors can have positive double numbers as indexes. D. Vectors grow automatically as needed.

d

Which of the following applications may use a stack? A. A parentheses balancing program. B. Keeping track of local variables at run time. C. Syntax analyzer for a compiler. D. All of the above

d

Which of the following data structure is linear type? a. Strings b. Lists c. Queues d. All of above

d

Which of the following data structure is non-linear type? a. Strings b. Lists c. Stacks d. None of above

d

Which of the following is true about linked list implementation of stack? (A) In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end. (B) In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning. (C) Both of the above (D) None of the above

d

Which one of the following is an application of Stack Data Structure? (A) Managing function calls (B) The stock span problem (C) Arithmetic expression evaluation (D) All of the above

d

What is the expression for generating a pseudorandom number in the range 1...N? A. (int) (Math.random() * N); B. (int) (Math.random() / N); C. (int) (Math.random() * (N + 1)); D. (int) (Math.random() / (N + 1)); E. (int) (Math.random() * N) + 1;

e

A graph that has neither self-loops nor parallel edges are called____ A. multi graph B. simple graph C. pseudo graph D. connected graph

b

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

b

In the linked list version of the Bag class an instance variable manyNodes is used to keep track of how long the linked list is. Why not just make a call to the IntNode method listLength()? A. The listLength() method is O(n) and the alternative is O(1). B. The listLength() method is private. C. The listLength() method results in an infinite loop for circular lists. D. The listLength() method works only for lists of integers.

a

Select the most correct statement about the complexity of selection sort A. Both best and worst cases are 0(n~2) B. The best case is 0(n), and the average case is O(nlogn) C. The best case is 0(n), and the average case is 0(n~2) D. The best case is 0(n). and the worst case is 0(n~2)|

a

Specify the correct implementation of in-order traverse algorithm for binary trees. 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):}

a

Suppose that obj is an Object variable and s is a String variable. Which of the following statements is a correctly-compiling widening conversion? Don't worry about possible run-time exceptions. A. obj = s; B. s = obj; C. s = (String) obj; D. Two or more answers are correct.

a

Suppose that the Bag is implemented with a linked list. Which of these operations are likely to have a constant worst-case time? A. add B. countOccurrences C. remove D. None of (A), (B), and (C) have a constant worst-case time E. TWO of (A), (B), and (C) have a constant worst-case time F. ALL of (A), (B), and (C) have a constant worst-case time

a

What kind of list is best to answer questions such as "What is the item at position n?" A. Lists implemented with an array. B. Doubly-linked lists. C. Singly-linked lists. D. Doubly-linked or singly-linked lists are equally best

a

How many stack will be needed for the evaluation of a prefix expression a. 1 b. 2 c. 0 d. 3

c

pointers store the next data element of a list a. True b. false

b

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 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

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

a

What is the correct definition of a hash table? (Select the best answer) A. Hash Table T is an array in memory used for storing items. Hash table T is used with a hash function h(x). which transforms a particular key x (string or number), into an index i = h(x) in the table. B. Hash Table T is an array in memory used for storing items. Hash table T is used with a hash function h(x). which transforms a particular key x (a string, number, record, or the like), into an index i = h(x) in the table. C. Hash Table T is an array in memory used for storing items or their addresses. Hash table T is used with a hash function h(x). which transforms a particular key x (a string, number, record, or the like), into an non-negative integer. D. Hash Table T is an array in memory used for storing items or their addresses. Hash table T is used with a hash function h(x). which transforms a particular key x (a string, number, record, or the like), into an index i = h(x) in the table.

d

void push(Integer x){ Node p = new Node(x); p.next = head; head=p; } a. True b. false

a

. If the two stacks are implemented on a single array, the overflow occurs at (select 2 answers) a. top1=top2 b. top1=top2-1 c. top1-1=top2 d. none of these

a b

void preOrder(Node p){ if(p = null) { visit(p); preOrder(p.left); preOrder(p.right); } } a.pre-order traverse algorithm a. True b. false

a

Answer |n a linked list, the tail node is introduced for performance purpose only. A. False B. True

a

In a singly-linked list every element contains some data and a link to the next element, which allows to keep the structure a. True b. false

a

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

a

To evaluate an expression without any embedded function calls: (A) One stack is enough (B) Two stacks are needed (C) As many stacks as the height of the expression tree are needed (D) A Turing machine is needed in the general case

a

Which of the following applications may use a stack? A. Auxiliary data structure for algorithms. B. Multi-programming. C. Store a waiting list of printing jobs. D. Store all variables in a program.

a


Set pelajaran terkait

ECON 200 Ch. 7, 8, 9 Connect Questions

View Set

Chapter 2: The Body & Body Planes

View Set

Health Definitions: Chapter 1 and 2

View Set

Chapter 7: Valuation Using the Sales Comparison and Cost ApproachesAssignment

View Set

P.E. Unit 1 Introduction To Fitness

View Set

Series 65 - Practice Exam (Answers - Not confirmed correct)

View Set

Le sens commun et la perspective sociologique

View Set

PSY3290 CH. 6 p Values, Null Hypothesis Significance Testing, and CI's

View Set