Data Structure and Algorithm Analysis
Questions 281 to 290
281.
|
This algorithm scans the list by swapping the entries
whenever pair of adjacent keys are out of desired order.
(a) Insertion
sort (b) Quick sort (c) Shell sort (d) Bubble sort (e)
Radix sort.
|
At a given node of a simple graph, the number of loops are
_________
(a) More than one (b) Not
more than one (c) Zero
(d) Exactly
two (e) Equal
to the number of nodes of the graph.
|
|
In the linked list implementation of the stack, where does
the push member function place the new entry on the linked list?
(a) At the head
(b) At the tail
(c) After all other
entries those are greater than the new entry
(d) After all other
entries those are smaller than the new entry
(e) At null node.
|
|
I have implemented the queue with a circular array,
keeping track of first, last, and count (the number of
items in the array). Suppose first is zero, and last is SIZE-1.
What can you tell me about count?
(a) count must be zero.
(b) count must be SIZE
(c) count must be SIZE-2
(d) count must be SIZE+1
(e) count could be zero or SIZE, but no other
values could occur.
|
|
Convert the following postfix expression to a fully-parenthesized
infix expression:
A B C - D E + * F * +
(a) (A + ((B - C) *
(D + E) * F))
(b) (A + (((B - C) *
(D + E)) * F))
(c) A + (((B - C) *
(D + E)) * F)
(d) (A + ((B - C) * (D
+ E)) * F)
(e) A + ((B - C) * (D
+ E)) * F.
|
|
The linked list would be able to make use of a
------------- whose value is the address of the location which stores
the node.
(a) integer (b) float (c) char (d) void (e) pointer.
|
|
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
(e) Circular linked
list implemented with priorities.
|
|
Consider the following pseudo code:
declare a stack of characters
while (there are more characters in the
word to read ) {
read a
character
push the character on the stack
}
while ( the
stack is not empty) {
pop a character off the stack
write the character to the screen
}
What is written to the screen for the input
"carpets"?
(a) serc (b) steprac (c) carpets (d) ccaarrppeettss (e) stepr.
|
|
What is the value of the postfix expression 6 3 2 4 + - *
(a) Something
between 5 and 15
(b) Something
between -5 and -15
(c) Something
between 5 and -5
(d) Something
between -15 and -100
(e) Something
between 15 and 100.
|
|
Suppose we have a circular array implementation of the
queue type, with ten items in the queue stored at data[2] through data[11].
The current SIZE is 22. Where does the insert method place the new entry in
the array?
(a) data[1] (b) data[22] (c) data[12] (d) data[11] (e) data[21].
|
Answers:
281.
|
Answer : (d)
Reason: As in bubble
sort always we swap the adjacent keys if they are not in desired order
|
Answer : (c)
Reason: Because in
simple graphs the loops are not allowed.
|
|
Answer : (a)
Reason: Because in
stack implemented using linked list, head always points to the top most node.
|
|
Answer : (e)
Reason: Because
first = 0 and rear = size-1 means either the stack is full or it was made to
empty by after filling it to full. (Since this is a circular queue).
|
|
Answer : (b)
Reason: As the fully
parenthesized expression requires its sub parts to be in the parenthesis
|
|
Answer : (e)
Reason: Because the
pointer is used to hold the address of the next node in the list.
|
|
Answer : (a)
Reason: Because
index is required to locate a particular position, and in arrays this index
can be used to locate an element.
|
|
Answer : (b)
Reason: This nothing
but pushing the characters on the stack and popping them from the stack and
hence it will print the input in the reverse because of LIFO manner.
|
|
Answer : (d)
Reason: Because the
answer is -18.
|
|
Answer : (c)
Reason: Because
still the space is there in the queue and the next available location is 12th
indexed one, therefore new element is inserted at that location.
|
No comments :
Post a Comment