What kind of list is best to answer many questions such as what is the item at position N?

Data Structure and Algorithm Analysis

Questions281 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.
282.
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.
283.
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.
284.
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.
285.
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.
286.
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.
287.
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.
288.
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.
289.
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.
290.
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
282.
Answer : (c)
Reason: Because in simple graphs the loops are not allowed.
283.
Answer : (a)
Reason: Because in stack implemented using linked list, head always points to the top most node.
284.
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).
285.
Answer : (b)
Reason: As the fully parenthesized expression requires its sub parts to be in the parenthesis
286.
Answer : (e)
Reason: Because the pointer is used to hold the address of the next node in the list.
287.
Answer : (a)
Reason: Because index is required to locate a particular position, and in arrays this index can be used to locate an element.
288.
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.
289.
Answer : (d)
Reason: Because the answer is -18.
290.
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.


<< Prev Set 1 Set 2 Set 3 Set 4 Set 5 Set 6 Set 7 Set 8 Set 9 Set 10 Set 11 Set 12 Set 13 Set 14 Set 15 Set 16 Set 17 Set 18 Set 19 Set 20 Set 21 Set 22 Set 23 Set 24 Set 25 Set 26 Set 27 Set 28 Set 29 Set 30 Next >>