Algorithms - Algorithm Design Techniques

Common Data for Q. 16 & Q. 17

We are given 9 tasks T1, T2… T9. The execution of each task requires one unit of time. We can execute one task at a time. Ti has a profit Pi and a deadline di profit Pi is earned if the task is completed before the end of the dith unit of time.
 TaskT1T2T3T4T5T6T7T8T9
 Profit152030181810231625
 Deadline725345273

16. To implement Dijkstra's shortest path algorithm on unweighted graphs so that it runs in linear time, then data structure to be used is

  • Option : C
  • Explanation :
    In order to find minimum size of X capable of storing any kind of binary tree, the worst case size of the tree has to be taken.
    In the worst case size of the tree has to be taken. In the worst case only a single node will contain the data at each level of the tree.
    For example, for 4 data items, the worst case binary tree will be as follows

    Generalizing the concept, for n vertices, the levels of tree that are required will be n.
    Memory required at each level (starting from root) will be 20, 21, 22, .... 2n-1
    ∴ Minimum size = 20 + 21 + 22, .... 2n-1
    = 20(2n-1)/(2-1) = 2n-1
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


17. Dijkstra's single source shortest path algorithm when run from vertex a in the below graph, computes the corrects shortest path distance to

  • Option : D
  • Explanation :
    Dijkstra’s single source shortest path in not gives the guarantee to work on negative weight edges graph.
    But in this graph it gives the correct shootest path for all vertex.
    Shortest path for
    B → 1
    e → –2
    F → O
    g → 3
    h → –2
    d → 6
    C → 3
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


18. Consider the directed graph shown in the figure below. There are multiple shortest paths between vertices S and T. Which one will be reported by Dijkstra's shortest path algorithm? Assume that, in any iteration, the shortest path to a vertex v is updated only when a strictly shorter path to v is discovered.

Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


19. Let G be an undirected connected graph with distinct edge weights. Let emax be the edge with maximum weight and emin the edge with minimum weight. Which of the following statements is false?

  • Option : C
  • Explanation :
    If emax is maximum weight edge in graph, them it is possible that emax contain’s in minimum spanning tree.
    Example

    cd is maximum weight edge and it must present in minimum spanning tree
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *


20. What is the weight of a minimum spanning tree of the following graph?

  • Option : B
  • Explanation :
    Minimum Spanning tree is

    Total sum = 1 + 2 + 2 + 2 + 3 + 4 + 4 + 5 + 8 = 31
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *