ALGORITHUM
ALGORITHUM
2. The indirect change of the values of a variable in one module by another module
is called
a. Trees b. Graphs
a. Sorting b. Merging
c. Inserting d. Traversal
a. Traversal b. Search
int gcd(n,m)
n = n%m;
return gcd(m,n);
a. theta(log n) b. omega(n)
C. theta (log log n) d. Theta (sqrt(n))
9.
The time factor when determining the efficiency of algorithm is measured by
Counting microseconds
A
.
B Counting the number of key operations
.
C Counting the number of statements
.
D Counting the kilobytes of algorithm
.
10.
The space factor when determining the efficiency of algorithm is measured by
A Counting the maximum memory needed by the algorithm
.
B Counting the minimum memory needed by the algorithm
.
C Counting the average memory needed by the algorithm
.
D Counting the maximum disk space needed by the algorithm
.
11.
Which of the following case does not exist in complexity theory
A Best case
.
Worst case
B.
C Average case
.
D Null case
.
12. The Worst case occur in linear search algorithm when
A
Item is somewhere in the middle of the array
.
B Item is not in the array at all
.
C
Item is the last element in the array
.
D Item is the last element in the array or is not there at
. all
13.
The Average case occur in linear search algorithm
When Item is somewhere in the middle of the array
A
.
B
When Item is not in the array at all
.
C When Item is the last element in the array
.
When Item is the last element in the array or is not there at
D
all
.
14.
The complexity of the average case of an algorithm is
A
Much more complicated to analyze than that of worst case
.
B Much more simpler to analyze than that of worst case
.
Sometimes more complicated and some other times simpler than that of worst
C
case
.
D None or above
.
15.
The complexity of linear search algorithm is
A O(n)
.
B
O(log n)
.
C O(n2)
.
D O(n log n)
.
16.
The complexity of Binary search algorithm is
A O(n)
.
B O(log )
.
C O(n2)
.
D O(n log n)
.
17.
The complexity of Bubble sort algorithm is
A O(n)
.
B O(log n)
.
C O(n2)
.
D O(n log n)
.
18
The complexity of merge sort algorithm is
.
A O(n)
.
B O(log n)
.
C O(n2)
.
D O(n log n)
.
19. The indirect change of the values of a variable in one module by another module
is called
A internal change
.
B inter-module change
.
C side effect
.
D side-module update
.
20. Which of the following data structure is not linear data
structure?
A Arrays
.
B Linked lists
.
C Both of above
.
None of above
D.
21.
Which of the following data structure is linear data structure?
A Trees
.
B
Graphs
.
C
Arrays
.
None of above
D.
22.
The operation of processing each element in the list is known as
A
Sorting
.
B
Merging
.
C
Inserting
.
D
Traversal
.
23.
Finding the location of the element with a given value is:
A
Traversal
.
B. Search
C
Sort
.
None of above
D.
24.
Arrays are best data structures
A for relatively permanent collections of data
.
for the size of the structure and the data in the structure are constantly
B
changing
.
C for both of above situation
.
D for none of above situation
.
25.
Linked lists are best suited
for relatively permanent collections
A
of data
.
for the size of the structure and the data in the structure are constantly
B
changing
.
C for both of above situation
.
D for none of above situation
.
26. Each array declaration need not give, implicitly or explicitly, the information
about
A the name of array
.
the data type of array
B.
C the first data from the set to be stored
.
D the index set of the array
.
27. The elements of an array are stored successively in memory cells
because
A by this way computer can keep track only the address of the first element and
. the addresses of other elements can be calculated
the architecture of computer memory does not allow arrays to store other
B
than serially
.
C both of above
.
D. none of above
28. The time factor when determining the efficiency of algorithm is measured
by
a. Counting microseconds
29. The space factor when determining the efficiency of algorithm is measured
by
a. Best case
b. Worst case
c. Average case
d. Null case
c. Sometimes more complicated and some other times simpler than that of
worst case
d. None or above
32.Which of the following data structure can't store the non-homogeneous data
elements?
a. Arrays
b. Records
c. Pointers
d. None
35. A data structure where elements can be added or removed at either end but
not in the middle
a. Linked lists
b. Stacks
c. Queues
d. Deque
40. The running time of an algorithm T(n),where 'n' is the input size, of a
recursive algorithm is given as follows.is given by
d, if n ≤ 1
The order of this algorithm is
41. There are 4 different algorithms AI, A2, A3, A4 to ·solve a given problem
with the order Iog(n), log(log(n)), nIog(n) ,n / log(n) respectively. Which is the
best algorithm?
43. The order of an algorithm that finds whether a given Boolean function of 'n'
variables, produces a 1 is
A. constant B. Linear C. algorithmic D. Exponential .
Explanation :
Let T(1) = T(2) = T(3) = k (say). Then T(4) = k + k - k = k
T(5) = k+ k- k= k.
By mathematical induction it can be proved that T(n) = k, a constant.
44. Which of the following algorithms solves the all-pair shortest path problem?
A. Dijkstra's algorithm
B. Floyd's algorithm
C. Prim's algorithm
D. Warshall's algorithm.
Explanation :
46. Which of the following algorithm design technique is used in the quick sort
algorithm?
A.Dynamic programming
B. backtracking
C.divide and conquer
D. Greedy method
49.Which of the following is not the required condition for binary search algorithm?
d. When Item is the last element in the array or is not there at all
a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)
a. O(n)
b. O(log )
c. O(n2)
d. O(n log n)
1. YES 2.NO
1.(n+1)/2
2.(2n+1)/2
3.(n+1)
4.2(n+1)
59. Which of the following is not the required condition for the binary search
algorithm?
4. None of above
SORTING:
a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)
a. O(n)
b. O(log n)
c. O(n2)
63.Which one of the following in place sorting algorithms needs the minimum
number of swaps?
• Quick sort
• Insertion sort
• Selection sort
• Heap sort
70. An in place sorting algorithm is one that uses ___ arrays for storage
1. Two dimensional arrays
2. More than one array
3. No Additional Array
4. None of the above
73. Marge sort continues its division until n elements in the list.the value of n is:
1. [log2n]+1
2. [ log10n]+1
3 . [log2n]+2
4. [log10n]+2
75. For searching a page from your book , which method is generally used
1. Linear Search
2.Binary Search
84. An algorithm is made up of two independent time complexities f (n) and g (n).
Then the
complexities of the algorithm is in the order of
3.Min(f(n),g(n)) 4.f(n)+g(n)
87. Consider that n elements are to be sorted. What is the worst case time
complexity of
Bubble sort?
1.O(1) 2.O(log2n)
3.O(n) 4.O(n2)
88. A characteristic of the data that binary search uses but the linear search ignores
is
the___________.
89. The average search time of hashing with linear probing will be less if the load
factor ?
2. equals one
4. none of above
90. As part of maintenance work, you are entrusted with the work of rearranging
the library books in a shelf in proper order, at the end of each day. The ideal choice
will be ?
91. The way a card game player arranges his cards as he picks them up one by one,
is an example of ?
4. all
93. A technique for direct search is
4. All of above
2. for( ; ;);
3.return;
101. When a variable of data type double is converted into float, then
4.none of these
103. To sort many large objects or structures, it would be most eficient to place
104. Suppose DATA array contains 1000000 elements. Using the binary search
algorithm, one requires only about n comparisons to find the location of an item in
the DATA array, then n is
1. 60 2. 45 3. 20 4. None of these
107. Using the standard algorithm, what is the time required to determine that a
number n is prime ?
2.A serial search continues searching, element by element, either until a match is
found or until the end of the array is encountered
3.A serial search is useful when the amount of data that must be search is small
4.For a serial search to work, the data in the array must be arranged in either
alphabetical or numerical order
109. A search begins the search with the element that is located in the middle of the
array
1. serial 2.random
3.parallel 4.binary
110. A sort which iteratively passes through a list to exchange the first element with
any element less than it and then repeats with a new first element is called
111. Which of the following statements is used in the binary search algorithm to
halve the array ?
1. search argument
2.sorting argument
3.detection argument
4.binary argument
113. If the binary search algorithm determines that the search argument is in the
lower half of the array, which of the following statements will, set the appropriate
variable to the appropriate value?
2.A binary search continues having the array either until a match is found or until
there are no more elements to search
3.If the search argument is greater than the value located in the middle of the
binary, the binary search continues in the lower half of the array
4.For a binary search to work, the data in the array must be arranged in either
alphabetical or numerical order
115. You want to check whether a given set of items is sorted. Which of the
following sorting methods will be most efficient if it is already in sorted order?
116. Which of the following sorting methods will be the best if number of swappings
done, is the only measure of efficienty?
1. Bubble sort 2.Selection sort
117. You are asked to sort 15 randomly generated numbers. You should prefer
4.All of these
120. A sorting technique that guarantees that records with the same primary key
occurs in the same order in the sorted list as in the original unsorted list is said to be
1. Stable 2. Consistent
3. external 4. Linear
1. 4 6 2. 5 4 6
3.9 6 4.9 3 2
2.backtracking approach
3.heuristic search
4.greedy approach
123. A machine took 200 see to sort 200 names, using bubble sort. In 800 sec, it can
approximately sort
Explanation :
For sorting 200 names bubble sort makes 200x(199/2)= 19900 c9omaprisons. The
time needed for 1 comparison is 200 sec (approximately). In 800 sec it can make
80,000 comparisons. We have to find n, such that n(n-1)/2= 80,000. Solving, n is
approximately 400.
1. stack 2.set
3. List 4.Queue
125. The recurrence relation that arises in relation with the complexity of binary
search is
3.T(n) = T(n/2)+log(n)
4.T(n) = T (n/2) + n
4.none of these
Ans: D
The header file stdio.h contains definitions of constants,macros and types, along
with
128. Choose the directive that is used to remove previously defined definition of the
macro
Ans: C
The preprocessor directive #undef OKAY would cause the definition of OKAY to be
Ans: A
130. For implementing recursive function the data structure used is:
Ans: B
Ans: B
132. The variable that are declared outside all the functions are called ______.
Ans: B
The variables that are declared outside all functions are called global variable
c. Bottom up approach
d. Hierarchical approach
134. What do you call the selected keys in the quick sort method?
135. The time complexity in the normal quick sort ,randomized quick sort algorithm
in worst case is
136.Let there be an array of length 'N' , and the selection sort algorithms is used to
sort it, How many times a swap function is called to complete the execution?
a. Insertion b.Selection
c. Deletion d. Exchange
141. What is the type of the algorithm used in solving the 8 Queens problem?
a. Greedy b.Dynamic
c. Backtracking
142. The asymptotic notation for defining the average time complexity is
a.Equivalent b. Symmetric
c. Reflexive d. Transitive
143. Which of following algorithm scans the list by swapping the entries whenever
pair of adjacent keys are out of desired order?
a. Symmetric b. Reflexive
b. Knapsack problem
c. Selection problem
d. Merge sort
146. The method which traverses the array sequentially to locate the given item in
an array is called
147. What would be the total number of moves in Tower of Hanoi when n = 7?
148. Which of the following versions of merge sort algorithm does uses space
efficiently?
a. Contiguous version
b. Array version
c. Linked version
d. Structure version
149. What is the time taken by the binary search algorithm to search a key ‘k’ in a
sorted array of ‘n’ elements?
150. There are two sorted lists L1 and L2. Their lengths are n1 and n2 respectively.
You are asked to design an algorithm to generate a sorted list L3 from L1 and L2.
That is, for example, if L1=[1,5,30] and L2=[3,6,12,24,43] then
L3=[1,3,5,6,12,24,30,43]. Which of the following methods is the most efficient?
a. Taking elements from L1 one by one, and inserting them into L2 such that the
order of L2 remains unchanged
b. Appending two lists (i.e. join one list's beginning to the other one's end),then
applying quick sort to the appended list
c. Using a merge method that compares two elements at the head of both lists. The
smaller one is then taken out and inserted at the end of L3 while the larger one is
kept its location unchanged. Repeat this until either L1 or L2 is empty.
b. While defining the ADT as a mathematical concept, the space efficiency isn’t a
major concern
152. Which of the following information is not saved in the activation record, when
ever a function call is executed?
c. Formal parameters
153. Consider using binary search to look for a given value in an array of integers.
Which of the following must be true in order for the search to work?
II. The array does not contain any duplicate values.
154. Which of the following are essential statement types for describing algorithms?