0% found this document useful (0 votes)
9 views4 pages

AADS QuestionBank

Uploaded by

Piyush Agrahari
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)
9 views4 pages

AADS QuestionBank

Uploaded by

Piyush Agrahari
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/ 4

‭1.

‬ A ‭ pply the Knuth-Morris-Pratt algorithm to‬‭P =bacbaaa‬‭and‬‭T =‬


‭bacbacabcbacbbbacabacbabcbbba.‬
‭2.‬ ‭Consider the search for a pattern in a text when the pattern is not in the text. What is the‬
‭smallest number of character comparisons in this case executed by Knuth-Morris-Pratt?‬
‭3.‬ ‭An example of the worst case for bruteForceStringMatching() are strings‬‭P‬‭=‬‭a‭m‬ ‭–‬ 1‬‭b‬‭and‬‭T‬
‭=‬‭a‭n‬ ‬‭. Explain.‬
‭4.‬ ‭List the prefixes of the string P="aaabbaaa" that are also suffixes of P.‬
‭5.‬ ‭Draw a figure illustrating the comparisons done by brute-force pattern matching for the‬
‭text "aaabaadaabaaa" and pattern "aabaaa".‬
‭6.‬ ‭Repeat the previous problem for the KMP pattern matching algorithm, not counting the‬
‭comparisons made to compute the failure function.‬
‭7.‬ ‭What do you mean by a hash table and a hash function? Explain the following hash‬
‭functions with an example (i). Division method (ii). Mid square‬
‭8.‬ ‭What do you mean by collision and how can you handle it using linear probing?‬
‭9.‬ ‭Construct a B tree of order 3 for the following data:‬

‭50, 30, 21, 90, 10, 13, 20, 70, 25, 92, 80‬

‭10.‬‭Construct hash table of size 10 using linear probing with replacement strategy for‬
‭collision resolution. The hash function is h(x)=x%10. Calculate total number of‬
‭comparisons required for searching. Consider slot per bucket is 1.‬

‭25, 3, 21, 13, 1, 2, 7, 12, 4, 8‬

‭11.‬‭Construct hash table of size 10 using linear probing without replacement strategy for‬
‭collision resolution. The hash function is h(x)=x%10. Calculate total number of‬
‭comparisons required for searching. Consider slot per bucket is 1.‬

‭31, 3, 4, 21, 61, 6, 71, 8, 9, 25‬

1‭ 2.‬‭Write an algorithm to delete a node from B-tree.‬


‭13.‬‭Applications of skip list.‬
‭14.‬‭For the given set of values:‬

‭11, 33, 20, 88, 79, 98, 44, 68, 66, 22‬

‭ reate a hash table of size 10 and resolve collision using chaining with replacement and‬
C
‭without replacement. Use the modulus hash function.‬
‭15.‬‭Insert the following keys in an initially empty B-tree of order 5:‬

‭3, 7, 9, 23, 45, 1, 5, 14, 25, 24, 13, 11, 8, 19, 4, 31, 35, 56‬

‭ how the tree after each insertion. Mention the total number of times that a split happens‬
S
‭during these insertions.‬

1‭ 6.‬‭How many keys can a B-tree of order m and of height h hold?‬


‭17.‬‭Are B-trees immune to the order of the incoming data? Construct B-trees of order 3 (two‬
‭keys per node) first for the sequence 1, 5, 3, 2, 4 and then for the sequence 1, 2, 3,4, 5. Is‬
‭it better to initialize B-trees with ordered data or with data in random order?‬
‭18.‬‭What is the worst case of inserting a key into a 2–4 tree?‬
‭19.‬‭In the discussion of B-trees, which are comparable in efficiency to binary search trees,‬
‭why are only B-trees of small order used and not B-trees of large order?‬
‭20.‬‭What is the minimum number of keys that are hashed to their home positions using the‬
‭linear probing technique? Show an example using a 5-cell array.‬
‭21.‬‭Outline an algorithm to delete a key from a table when the linear hashing method is used‬
‭for inserting keys. What is the worst case time complexity of the algorithm?‬
‭22.‬‭What is the maximum number of disk accesses needed to delete an element that is in a‬
‭non-leaf node of a B-tree of order m?‬
‭23.‬‭Suppose that Prim’s algorithm has been executed, starting from node F, up to the point at‬
‭which there are four edges selected for inclusion in the minimal spanning tree. List these‬
‭four edges in the order that they are selected for inclusion, using notation similar to (A,‬
‭B) to specify an edge.‬

‭24.‬‭Apply Prim’s algorithm to find the minimum spanning tree from the given graph and‬
‭show the intermediate steps:‬
‭25.‬‭Construct the minimum spanning tree (MST) for the given graph using Kruskal’s‬
‭Algorithm.‬

‭26.‬‭Find the shortest distance from A to J on the network below using Dijkstra’s algorithm.‬
‭27.‬‭Why Dijkstra’s algorithm cannot be used for negative weights. How can we modify the‬
‭Dijkstra’s algorithm such that it works with negative weights? Write the modified‬
‭algorithm and discuss its run time complexity.‬
‭28.‬‭Apply Kruskal’s algorithm to find the minimum spanning tree from the following graph.‬

‭Show the intermediate steps. Compute the time complexity of Kruskal’s algorithm.‬

‭29.‬‭asd‬

You might also like