You are on page 1of 8

1) The worst case occurs 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
item is not there at all
E. None of these

2) If you can sort small amount of records then which sort is efficient? [ ]
A. Merge B. Heap C. Selection D. Insertion E) Bubble

3) The complexity of sorting algorithm measures the ...... for function (). [ ]
A. Average Time B) Running Time C. average-case complexity
D. case-complexity E) None of These

4) Complexity of linear search algorithm is......... [ ]


A. O (n) B. O (log n) C. O (n2) D. O (n log n) E) O (n Log n2)

5) Binary search algorithm cannot be applied to ... [ ]


A. Sorted Linked List B. Sorted Binary Trees C. Sorted Linear Array
D. Pointer Array E. None of These

6) Which of the following is not a limitation of binary search algorithm? [ ]


A. Must Use A Sorted Array
B. Requirement of sorted array is expensive when a lot of insertion and deletions are needed.
C. A and B
D. Binary search algorithm is not efficient when the data elements more than 1500.
E.A and C

7) The Average case occurs in linear search algorithm....... [ ]


A. When item is somewhere in the Staring position of the array
B. When item is not the array at all
C. When item is the last element in the array
D. B and C
E. When item is somewhere in the middle of the array

8) The complexity of Selection sort algorithm is..... [ ]


A. O (n) B. O (log n) C. O (n2) D. O (n log n) E. None of these

9) Sorting algorithm can be classified as..... [ ]


A. Simple algorithm which require the order of n2 comparisons to sort n items.
B. Sophisticated algorithms that require the O (nlog2n) comparisons to sort items.
C. O(n) and O(n2).
D. Both of the above.
E. None of the above.

10) The run time complexity of Insertion sort algorithm in worst case. [ ]
A. O(n) B. O(log n) C. O(n2) D. O(n log n) E. None of these

11) The run time complexity of Insertion sort algorithm in Best case. [ ]
2
A. O(n) B. O(log n) C. O(n ) D. O(n log n) E. None of these

12) The run time Complexity of Merge sort algorithm is..... [ ]


A. O(n) B. O(log n) C. O(n2) D. O(n log n) E. None of these
13) The run time complexity of Quick sort algorithm in worst case scenario [ ]
A. O(n) B. O(log n) C. O(n2) D. O(n log n) E. None of these

14) The run time complexity of Quick sort algorithm in Best case scenario [ ]
A. O(n) B. O(log n) C. O(n2) D. O(n log n) E. None of these.

15) The run time Complexity of Heap sort algorithm is..... [ ]


A. O (n) B. O (log n) C. O (n2) D. O (n log n) E. None of these

16. ......order is the best possible for array sorting algorithm which sorts n item.[ ]
A. O (n2) B. O (n log n) C. O (n + log n) D. O (log n) E. None

17. The time factor when determining the efficiency of algorithm is measured by [ ]
A. Counting microseconds B. Counting the number of key operations
C. Counting the kilobytes of algorithm D. counting the number of statements
E. None of these.

18. The operation of processing each element in the list is known as [ ]


a. Sorting b. Merging c. Inserting d. Traversal E. All

19. The complexity of Binary search algorithm is [ ]


A. O (n) B. O (log n) C. O (n2) D. O (n log n) E. None of these

20. Partition and exchange sort is..... [ ]


A. Quick Sort B. Tree Sort C. Heap Sort D. Bubble Sort E. None

21) Which of the following sorting algorithm is of divide and conquer type? [ ]
A. Bubble sort B. Insertion sort C. Quick sort D. Merge sort
E.C and D

22) The simplest sorting is........ [ ]


A. quick sort B. shell sort C. heap sort D. selection sort E)None

23) A tree sort is also known as ......... sort. [ ]


A. Quick B. shell C. Heap D. selection E .All of the Above

24) The operation that combines the element is of A and B in a single sorted list C with n=r
+ s element is called.... [ ]
A. Inserting B. Mixing C. Merging D. Sharing E. None of these

25. Two main measures for the efficiency of an algorithm are [ ]

A. Time and space B. Data and space C. Processor and memory


D. Complexity and capacity E. All of these
Level 2: Gypsum 10points
1) State True or False for internal sorting algorithms. [ ]
I) Internal sorting are applied when the entire collection if data to be sorted is small enough that
the sorting can take place within main memory.
II) The time required to read or write is considered to be significant in evaluating the
performance of internal sorting.
A. I-True, II-True B. I-True, II-False C.I-False, II-True
D.I-False, II-False. E. Based on the No .Of. Records.

2) Finding the location of a given item in a collection of items is called...... [ ]


A. Discovering B. Finding C. Searching D. Mining E. None

3) if no of records and key is also long , then ...... sorting can be efficient. [ ]
A. Merge B. Heap C. Insertion D. Selection E. Quick

4). if no of records are long and key is short , then ...... sorting can be efficient. [ ]
A. Merge B. Heap C. Insertion D. Selection E. none

5. The function used to modify the way of sorting the keys of records is called ...[ ]
A. Indexing function B. Hash Function C. Addressing function
D. The Entire above E. None of the above

6. 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
E. None of these

7. Which of the following case does not exist in complexity theory [ ]


A .Null Case B. Best case C. Worst case D.A and C E. None of these

8. The complexity of the average case of an algorithm is [ ]


A. Much more complicated to analyze than that of worst case.
B. Much simpler to analyze than that of worst case.
C. Sometimes more complicated and some other times simpler than that of worst case .
D. None or above.
E. above All.

9. What does Collision Means? [ ]


A) Problem in Hashing. B) Advantage in Hashing. C).Problem in Linear Search
D). Both A and C E. None of These.

10. Linear Probing Means [ ]


A. Error in hashing B. searching the hash table for a free location, based on size
C. insert the key value at index of array.
D. sequentially searching the hash table for a free location.
E. Randomly searching the hash table for a free location.
11.ReHashing means? [ ]
A. compute a new hash address using the old hash address as in put.
B. compute a old hash address using the new hash address as in put.
C. compute a old hash address using the old hash address+1 as in put.
D. compute a new hash address using the new hash address+1 as in put.
E. None of These

12.Chaining Means? [ ]
A Hash table is implemented as an arrays
B. Hash table is implemented as an array of linked lists
C. Hash table is implemented as an array of Trees
C. Hash table is implemented as an array of Graphs
D. None of these

13. The largest element in a heap is stored at the ----- [ ]


A. Leaf B. Middle C. Root. D. Any Place E. None

14. The Given Statement True for [ ]


“Every iteration eliminates half of the remaining possibilities”
A. Binary Search B. Sequential Search C. Fibonacci Search
D. These Entire E. None of These.

15. Which of the Following Requires Sorted list. [ ]


A. Binary Search B. Sequential Search C. Fibonacci Search
D. These Entire E. None of These.

16. A ----- is binary Tree has a every leaf on the same level, and every non leaf node have
two children. [ ]
A. Perfect Binary Tree B. Completed Binary tree C. Tree
D. Both a and B E. None

17. A ------binary tree is a binary tree, which is completely filled, with the possible exception
of the bottom level, which is filled from left to right. [ ]
A. Perfect Binary Tree B. Completed Binary tree C. Heap Tree
D. Both a and B E. None

18. A -------- binary tree in which the value of each node is greater than the values of
its leaves. [ ]
A. Perfect Binary Tree B. Completed Binary tree C. Heap Tree
D. Both a and B E. None

19. Here A is Array of Elements and i is the index of an Array than MAX_HEAP
PROPERTY Satisfies ----- Condition . [ ]
A .A[PARENT (i)] > A[i] B. A[PARENT (i)] < A[i]
C. A[PARENT (i)] == A[i] D. A[PARENT (i)] ≥ A[i] E. None of These

20. Here A is Array of Elements and i is the index of an Array than MAX_HEAP
PROPERTY Satisfies ----- Condition . [ ]
A .A[PARENT (i)] > A[i] B. A[PARENT (i)] < A[i]
C. A[PARENT (i)] == A[i] D. A[PARENT (i)] ≥ A[i] E. None of These
21. If node A[k] has children its left child is A [2*k+1] and right child is A [2*k+2].
Which Algorithm Satisfies the above Condition? [ ]
A. Binary Sort B. Heap Sort C. Insertion Sort D. A &B E. None

22.What is disadvantage of Linear Search? [ ]


A. Slow for An N Array elements. B. Requires More Memory at Runtime
C. It Examines N/2 Elements On Average D. Both A and C.
E. Both A and B.

23. What is disadvantage of Binary Search? [ ]


A. Slow for An N Array elements. B. Requires More Memory at Runtime
C. It Requires Sorted Array elements D. Both A and C.
E. Both A and B.

24. We can solve collisions using many strategies, like Open Addressing, it contains---
Following Techniques [ ]

A. Linear probing, Quadratic probing, Double hashing .


B. Linear probing, Quadratic probing, Separate Chaining.
C. Linear probing, Divide and Conquer, Double hashing.
D. Divide and Conquer, Double hashing, Separate Chaining.
E. None of These

25. Liner probing Means------ [ ]

A. Simply you can find the free Index in Liner Way from I th Value.
B. Simply you can find the free Index in Liner Way from 0 th Value.
C .Simply you can find the free Index in Liner Way from Size -1th Value.
D. All of the Above
E. None of These

26. ----- Sorts are used only the primary memory during sorting process. [ ]

A. External Sorts B. Internal Sorts C. Memory Based Sorts


D.A and B. E. None
1). The User wants to Enter the Group of Strings, Simply Treated as Employee Names, You have
to Develop a Method nameSort().The user can call this Method , then it will perform sort
the names of employee in alphabetically.

Here is the Code

/* pre condition: user enters Employee Names in Strings Only


* and stores in an array called as names.
* post condition: All values must be Arranged in *
Alphabetically .
*/
for(int i=0;i<k;i++)
for(int j=i+1;j<k;j++)
{
if(/* your code here */)
{
/* Your Code*/
}
}
2).User wants to Enter integers, the method sort() will sort the
entire numbers and prints it into sorting order.

Here

/* Pre condition is the user enters numbers only and

* post condition is to prints in assending order by using *


sort() method. */

public static void sort( int arr[] )


{
int N = arr.length;
int i, j, pos, temp;

/*
Your code here.
*/
}

3) write the method code of public static void main() will


prints all alphabets in reverse order,like z,y,x,v,u.....b,a.

/* Pre condition: no-precondition


* Post condition: to print alphabets in reverse order.
*/
Public static void main()
{
/*Your code here*/
}
4. write the method charSort() will prints all alphabets in
ascending order, like a, b, c,....Z.

/* Pre condition: no-precondition


* Post condition: to print alphabets in Ascending order.
*/
Public static charSort()
{
/* your Code here*/
}
Public static void main()
{
charSort();
}
5.write the code for a Method sequentialSearch() is to returns
the index of key in x or -1 if key is not in x.

Complete method sequentialSearch below.


public static int sequentialSearch(int[] x, int key)
{

/* your code here*/


}

6. Complete the private recursive helper method sort below. The


method sorts a[low]…a[high] while leaving the rest of the array
untouched. You may assume that method merge works as specified.
public class MergeSort
{
public static void sort(int[] a)
{
sort(a, 0, a.length - 1);
}

private static void sort(int[] a, int low, int high)


{
/* to be implemented */

}
/** Precondition: a[low]...a[mid] is sorted &&
* a[mid+1]...a[high] is sorted
* Postcondition: a[low]...a[high] is sorted
*/
private static void merge(int[] a, int low, int mid, int high)
{
/* your code implement here.
*/
}
}
7. Method sort () arranges the elements in x in increasing order using the insertion sort
algorithm.

Complete method sort below.

/** Precondition: Array values from a[0]...a[n-1] is given by


user in input.
* Post condition: a[low]...a[high] is sorted
*/
public static void sort(int[] x) {
/* write your code here*/
}

8. The precondition for method binarySearch is: x is sorted in increasing order. The
method returns the index of key in x. If key is not in x, the method returns (-(insertion
point) – 1) where insertion point is the index at which key would be inserted in x to
maintain x in sorted order.

Complete method binarySearch below. You must declare and write a recursive helper
method with an appropriate header.

public static int binarySearchPerform(int[] x, int key) {


return binarySearch(x, key, 0, x.length - 1);
}
private static int binarySearch(int[] x, int key, int start, int end) {
/* write your code here */.
}

9. Method sort arranges the elements in x in increasing order using the selection sort
algorithm.

Complete method sort below. You may also declare and implement a swap method with
the header of your choice.

/** Precondition: Array values from a[0]...a[n-1] is given by


user in input.
* Post condition: a[low]...a[high] is sorted
*/
public static void sort(int[] x) {
/* write your code here*/
swap(x, i, minIndex);
}
private static void swap(int[] x, int i, int j)
{
/* write your code here for swap of variables.*/
}

You might also like