0% found this document useful (0 votes)
23 views72 pages

Mid A&D-4

The document consists of a series of questions and answers related to sorting algorithms, data structures, and algorithm analysis. It covers topics such as the characteristics of various sorting algorithms, hash functions, and the analysis of recursive functions. Each question is followed by the correct answer, providing a comprehensive overview of fundamental concepts in computer science.

Uploaded by

dshenodas101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views72 pages

Mid A&D-4

The document consists of a series of questions and answers related to sorting algorithms, data structures, and algorithm analysis. It covers topics such as the characteristics of various sorting algorithms, hash functions, and the analysis of recursive functions. Each question is followed by the correct answer, providing a comprehensive overview of fundamental concepts in computer science.

Uploaded by

dshenodas101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

1- The Bucket and Radix algorithms are ______ sorting.

a.linear comparison
b.recursive comparison
c.linear non-comparison
d.recursive non-comparison

Answer : c
www.yourwebsite.com 2
2- Heap tree is a complete, left-justified binary tree in which no node has a
value greater/lesser than the value in its parent.

True
False

Answer : True
www.yourwebsite.com 3
3- Heap sort algorithm has ______ in the best case.

a.O(N)
b.O(N LogN)
c.O(LogN)
d.O(1)

Answer : b
www.yourwebsite.com 4
4- Quicksort is generally faster, but Heapsort is better in time-critical
applications.

True
False

Answer : True
www.yourwebsite.com 5
5- Three methods are used in solving ______.

a.sorts
b.recurrences
c.searches
d.hashes

Answer : b
www.yourwebsite.com 6
6- Recurrence can often be used to describe an algorithm that contains a
recursive call to itself.

True
False

Answer : True
www.yourwebsite.com 7
7- We can do random access to any element using Heap data structure.

True
False

Answer : False
www.yourwebsite.com 8
8- Bucket sorting algorithm assumes keys to have uniform distribution.

True
False

Answer : True
www.yourwebsite.com 9
9- Which one of the following is the recurrence equation of Binary Search?

a.T(n) = T(n/2) + 1 , T(0) = 1


b.T(n) = T(n-1) + 1 , T(1) = 1
c.T(n) = T(n-1) + 1 , T(0) = 1
d.T(n) = T(n/2) + 1 , T(1) = 1

Answer : a
www.yourwebsite.com 10
10- All the Counting, Radix and Bucket sorting algorithms are approximately of
O(N).

True
False

Answer : False
www.yourwebsite.com 11
11- Two or more keys hashing to the same slot leads to _____.

a.redundancy
b.overfit
c.collision
d.overlap

Answer : c
www.yourwebsite.com 12
12- The primary clustering problem is result of applying _____ to resolve
collision.

a.linear probing
b.quadratic probing
c.separate chaining
d.double hashing

Answer : a
www.yourwebsite.com 13
13- In the division hash function method, the key k is partitioned into a
number of parts, each of which has the same length as the required address
with the possible exception of the last part.

True
False

Answer : False
www.yourwebsite.com 14
14- There are _____ main methods to resolve collision.

a.five
b.three
c.four
d.two

Answer : d
www.yourwebsite.com 15
15- Hash table depends on the load factor not on the number of items in the
table.

True
False

Answer : True
www.yourwebsite.com 16
16- The worst case of separate chaining takes _____ to search for an element
with a given key.

a.O(N)
b.O(N LogN)
c.O(N!)
d.O(LogN)

Answer : a
www.yourwebsite.com 17
17- ______ methods are used in solving mathematical recurrence .

a.Four
b.Two
c.Three
d.Five

Answer : c
www.yourwebsite.com 18
18- Generally a prime number is a best choice to spread keys evenly by a hash
function.

True
False

Answer : True
www.yourwebsite.com 19
19- For open addressing the load factor should be close to 1.

True
False

Answer : False
www.yourwebsite.com 20
20- Open addressing stores the keys in the hash table itself.
True
False

Answer : True
www.yourwebsite.com 21
21- What is the recurrence relation for Merge Sort?
a. T(n)=2T(n/2)+Θ(n)
b. T(n)=2T(n/2)+1
c. T(n)=T(n/2)+1
d. T(n)=T(n−1)+c

Answer : a
www.yourwebsite.com 22
22- In the recurrences equation T(n)=a T(n/b) + f(n) b is

a. the runtime of each function


b. the factor by which the input size is reduced
c. number of times a function calls itself
d. the input size

Answer : b
www.yourwebsite.com 23
23- In the heap sort the complexity will be better if the input is almost sorted
sequence.
True
False

Answer : False
www.yourwebsite.com 24
24- Algorithm min2(a[1],a[2],…,a[n]):
1. If n = 1, return a[1].
2. m1 = min2(a[1],a[2],…,a[n/2] );
2. m2 = min2(a[n/2+1],a[n/2+2],…,a[n] );
3. If m1 > m2, return m1, else return m2
For this algorithm the recurrence equation will be
a. T(n/2)+c
b. 2T(n/2)+c
c. T(n-1)+c Answer : b
www.yourwebsite.com 25
d. 2T(n-1)+c
25- LinearSearch has same recurrence equation as BinarySearch
True
False

Answer : False
www.yourwebsite.com 26
26- The above figure is an example of a maxheap

True
False

Answer : False
www.yourwebsite.com 27
27- In counting sort the Auxiliary Array A.
A[i] is the number of element less than or equal i
True
False

Answer : True
www.yourwebsite.com 28
28- Heap Sort is asymptotically optimal comparison sorts
True
False

Answer : True
www.yourwebsite.com 29
29- The substitution method can be used to establish an __________ bound
on difficult recurrences

a. none of above
b. upper
c. tight
d. lower

Answer : b
www.yourwebsite.com 30
30- Which sort algorithm require only d passes through the input numbers,
where d is digit numbers in some base
a. Counting sort
b. Bucket sort
c. Heap sort
d. Radix sort

Answer : d
www.yourwebsite.com 31
31- Recursion tree to use to generate exact solution
True
False

Answer : False
www.yourwebsite.com 32
32- The following is the recursion tree is for which recursive order

a. T(n)=3T(n)+n^2
b. T(n)=3T(n/4)+n^2
c. T(n)=3T(n/4)+n
d. T(n)=3T(n)+n

Answer : b
www.yourwebsite.com 33
33- A hash table is a data structure that stores elements and allows insertions,
lookups, and deletions to be performed in O(1) time.
True
False

Answer : True
www.yourwebsite.com 34
34- A good choice for division hashing function is

a. Odd number
b. Prime number
c. Even number
d. Big number

Answer : b
www.yourwebsite.com 35
35- Which is not characteristic of good hash function

a. The hash function when applied to unequal Objects, is very unlikely to return the
same number for each
b. Generate same different hash values for similar strings
c. The hash function when applied to equal Objects, returns the same number for each
d. Distribute data "uniformly" across entire set of possible hash values

Answer : b
www.yourwebsite.com 36
36- Perfect Hash function is always exist
True
False

Answer : False
www.yourwebsite.com 37
37- The 3 digit Folding Method hashing function for 123456789 is
a. 369
b. 468
c. 469
d. 368

Answer : d
www.yourwebsite.com 38
38- In Separate Chaining Operation the order of insertion could be O(1) if it
happen at the end of the list
True
False

Answer : False
www.yourwebsite.com 39
39- In Separate Chaining Operation the average order of search is
a. λ
b. 1 +λ/2
c. λ/2
d. 1 +λ

Answer : b
www.yourwebsite.com 40
40- In linear probing, collisions are resolved by sequentially scanning the array
True
False

Answer : True
www.yourwebsite.com 41
41- In the ..... estimate the minimum number of steps required to solve a
problem of size n.

a. average case
b. best case
c. worst case

Answer : b
www.yourwebsite.com 42
42- Number of primitive steps that are executed.

a. memory space
b. network bandwidth
c. running time

Answer : c
www.yourwebsite.com 43
43- T(n) of the next algorithm:
for i=1 to n do
P(i);

a. nlogn
b. logn
c. 2n

Answer : c
www.yourwebsite.com 44
44- The big-oh of running time T(n)=5n^2+3n logn+n is:

a. nlogn
b. n
c. n^2

Answer : c
www.yourwebsite.com 45
45- Body of loop is......

a. Parameters
b. Return
c. Indentation

Answer : c
www.yourwebsite.com 46
46- Any problem can be solved by only one algorithm.

True
False

Answer : False
www.yourwebsite.com 47
47- Algorithms must have a finite number of well-defined instructions/steps.

True
False

Answer : True
www.yourwebsite.com 48
48- A complex problem can be solved if it is broken down into small, simple
sub-problems.

True
False

Answer : True
www.yourwebsite.com 49
49- The best way to measure the running time of algorithms is empirical
analysis.

True
False

Answer : False
www.yourwebsite.com 50
50- The algorithm that has run time (log n) is faster than has (n log n).

True
False

Answer : True
www.yourwebsite.com 51
51- Which of the following sorting algorithms have a running time of
O(dn+dk)?

a. Count Sort
b. Heap Sort
c. Radix Sort
d. Insertion Sort

Answer : c
www.yourwebsite.com 52
52- Which of the following algorithm design techniques is used in Heap sort?

a. Divide and Conquer


b. Dynamic programming
c. Greedy method
d. Backtracking

Answer : a
www.yourwebsite.com 53
53- What is the worst time complexity of Insertion Sort?

a. nlogn
b. N^2
c. n
d. n(logn)^2

Answer : b
www.yourwebsite.com 54
54- Heap sort is usually O(n log n) but in the worst case slows to O(n^2).

True
False

Answer : False
www.yourwebsite.com 55
55- Quick sort is usually O(n log n) but in the worst case slows to O(n^2).

True
False

Answer : True
www.yourwebsite.com 56
56 - Counting Sort is not a comparison-based sorting algorithm.

True
False

Answer : True
www.yourwebsite.com 57
57 - Running time of insertion sort algorithm depends on the size of the array,
not on the contents of the array.

True
False

Answer : False
www.yourwebsite.com 58
58 - Insertion Sort works better than Heap sort.

True
False

Answer : False
www.yourwebsite.com 59
59 - Consider sorting n numbers using Comparison Sorting. The minimum
number of leaves is n!.

True
False

Answer : True
www.yourwebsite.com 60
60 - What is the best case time complexity of heap sort?

a. n log n
b. n^2
c. n
d. n (log n)^2

Answer : a
www.yourwebsite.com 61
61 - Consider sorting n numbers using Comparison Sorting. The maximum
number of leaves of a binary tree of height h is h^n.

True
False

Answer : False
www.yourwebsite.com 62
62 - If the recurrence relation is given as below:
T(n)= {
1 n=0
T(n) = T(n-1)+cn n > 0
}
T(n-2) equal
a. T(n-2)=T(n/4)+c(n/2)
b. T(n-2)=T(n-3)+c(n-2)
c. T(n-2)=T(n-3)+T(n-4)+c(n-2) Answer : b
www.yourwebsite.com 63
63 - The solution of the recurrence relation in Q62 is given by:

a. Tn=1+cn
b. Tn=n+cnlogn
c. Tn=1+(n^2+n)/2

Answer : c
www.yourwebsite.com 64
64 - Depending on Q62 and Q63, the big O of T(n) will be:

a. O(n)
b. O(n^2)
c. O(nlogn)

Answer : b
www.yourwebsite.com 65
65 - The solution of the recurrence relation that is given below:
T(n)= {
1 n=1
T(n) = 3.T(n/4)+n n > 1
}
T(n/16)=
a. 3.T(n/4)+(n)
b. 3.T(n/4^2)+(n/4)
c. 3.T(n/4^3)+(n/4^2) Answer : c
www.yourwebsite.com 66
66 - From Q65, the T(n/4^(k-1)) =

a. 3.T(n/4^(k-2))+n)
b. 3.T(n/4^k)+n/4^(k-1))
c. 3.T(n/4^(k-1))+(n/4^(k-2))

Answer : b
www.yourwebsite.com 67
67 - The value of k in Q65 is:

a. log n
b. n^4
c. n-1

Answer : a
www.yourwebsite.com 68
68 - The big theta of the recurrence relation that is given in Q65 is:

a. Ɵ(n)
b. Ɵ(n^2)
c. Ɵ(n log n)

Answer : a
www.yourwebsite.com 69
69 - Cost of a recursive algorithm is only equal to the cost of the recursive call
on smaller input size.

True
False

Answer : False
Total computation cost = Cost of children level + Cost of tree excluding children level
www.yourwebsite.com 70
70- Insertion sort has a good running time for "almost sorted" arrays O(n).
True
False

Answer : True
www.yourwebsite.com 71
Thank You
https://chat.whatsapp.com/BMG7gRiy5xlBX3GbQOFf3B

https://www.youtube.com/@ErrorbyBOT

https://www.facebook.com/ErrorbyBot/

You might also like