Data Structure and Algorithm Analysis Set 26

Data Structure and Algorithm Analysis

Questions 251 to 260


251.
At the end of this code segment the queue
(a)  Contains numbers 1 to 8                   (b)  Contain numbers 1 to 10 but we can't see them
(c)  Is empty                                          (d)  Contains numbers 3 to 10
(e)  Contains only 1.
252.
What is the correct post fix form of the given infix expression a+b/(c+d)%e*(g-h/(i+j)*k)?
(a)  abcd+/e%ghij+/k**-+                        (b)  abcd+e/%ghij+/k**-+
(c)  ab+cd/e%ghij+/k**-                          (d)  ab+cd+/e%ghij+/k*-*
(e)  abcd+/e%ghij+/k*-*+.
253.
With the “wrap around” implementation of a queue, which of the following code should be used to work out the next location of deletion?
(a)   front++
(b)   front--
(c)   front = (front % max_queue_size) + 1
(d)   front = (front ++) % max_queue_size
(e)   front = 0.
254.
Which boolean expression indicates whether the number in two nodes (p and q) are the same? Assume that neither p nor q is null.
(a)  p == q                                             (b)  p.data == q.data                      (c)  p.link == q.link
(d)  p.link = q.link                                   (e)  p.data = q.data.
255.
Which of the following statements is not true?
(a)   An array is a data structure containing a number of items of the same type
(b)   An array is normally used to store two or more items of data
(c)   The lower bound of an array can be declared as any unsigned value
(d)   The elements of an array can be initialized when the array is declared
(e)   The number of elements in an array must be declared at compile time.
256.
Consider searching for a given value in a large, sorted array. Under which of the following  conditions is sequential search slower than binary search?
(a)   Always
(b)   Never
(c)   When the value being searched for is the first element in the array
(d)   When the value being searched for is the second element in the array
(e)   When the value being searched for is the last element in the array.
257.
The following data structure is used to store the values of the extreme ends of the freely hanging simple pendulum for every oscillation.
(a)  Linked List                                       (b)  Priority Queue   (c)  Deque
(d)  Double Stack                                  (e)  Array.
258.
The linked list which can be processed in either of the direction is
(a)  Single linked list                                                             (b)  Circular linked list
(c)  Stack implemented as linked list       (d)  Queue implemented as linked list
(e)  Double linked list.
259.
What does a run-time analysis usually count?
(a)   The number of arithmetic and other operations required for the program to run
(b)   The number of megabytes required for the program to run
(c)   The number of seconds required for the program to run
(d)   The number of seconds plus the number of megabytes
(e)   The number of seconds times the number of megabytes.
260.
Which of these is the correct big-O expression for 1+2+3+...+n?
(a)  O(log n)             (b)  O(n)                  (c)  O(n log n)          (d)  O(n²)                 (e)  O(1).



Answers



251.
Answer : (c)
Reason:  As using ‘while loop’ we have removed all the elements. Queue becomes empty.
252.
Answer : (e)
Reason:  Once we convert it all the other options are wrong except E
253.
Answer : (d)
Reason:  As in circular queue all the other options are not correct to identify the location pointed by front pointer where the recent deletion is made.
254.
Answer : (b)
Reason:  As we are comparing the data of both of the nodes, we have to check for the data, a member of nodes p, q. Also we have to use relational operator( ==).
255.
Answer : (c)
Reason:  As there is no any syntax to declare the lower bound of the array except the size of the array which can be declared.
256.
Answer : (a)
Reason:  As in all the cases the time taken by sequential( linear) search is O(n) which is greater than the time taken by binary search which is O(log n).
257.
Answer : (d)
Reason:  As the other data structures are not suitable to store the elements from both of the ends simultaneously.
258.
Answer : (e)
Reason:  As the Doubly linked list contains two pointers to keep track the address of both the previous and next nodes.
259.
Answer : (c)
Reason:  All the other options are meaning less. Because for run-time analysis, the number of operations and memory is not considered, but the unit time(i.e., seconds)
260.
Answer : (d)
Reason:  Because this the summation of the first ‘n’ numbers, that is n(n+1)/2   => ( n2+n)/2  => then by ignoring the lower order terms and the constants this becomes n2.   





1 comment :