• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Graph Data Strcuture with Answers

Question 31

Trie is also known as _____

  • Treap

  • Binomial Tree

  • 2-3 Tree

  • Digital Tree

Question 32

Let G be a weighted undirected graph and e be an edge with maximum weight in G. Suppose there is a minimum weight spanning tree in G containing the edge e. Which of the following statements is always TRUE?  
  • There exists a cutset in G having all edges of maximum weight.
  • There exists a cycle in G having all edges of maximum weight
  • Edge e cannot be contained in a cycle.
  • All edges in G have the same weight

Question 33

Let G be the directed, weighted graph shown in below figure gra We are interested in the shortest paths from A. (a) Output the sequence of vertices identified by the Dijkstra’s algorithm for single source shortest path when the algorithm is started at node A. (b) Write down sequence of vertices in the shortest path from A to E. (c) What is the cost of the shortest path from A to E?

    Question 34

    Consider a segment tree built on an array of N elements. What is the time complexity of updating a range of elements in the segment tree?

    • O(log N)

    • O(N)

    • O(log N + K), where K is the number of elements in the range

    • O(N log N)

    Question 35

    Which of the following operations can be efficiently performed using a segment tree?

    • Finding the longest increasing subsequence in a given range

    • Finding the most frequent element in a given range

    • Finding the number of inversions in a given range

    • Finding the top K elements in a given range

    Question 36

    The following code snippet is the function to insert a string in a trie. Find the missing line.

    Java
    private void insert(String str){
       TrieNode node = root;
       for (int i = 0; i < length; i++){
           int index = key.charAt(i) - 'a';
           if (node.children[index] == null)
              node.children[index] = new TrieNode();
           ________________________
       }
       node.isEndOfWord = true;
    }
    


    b)
    c) 
    d) 

    • node = node.children[index];

    •  node = node.children[str.charAt(i + 1)];

    • node = node.children[index++];

    • node = node.children[index++];

    Question 37

    Which of the following is not true?

    • Trie requires less storage space than hashing

    • Trie allows listing of all the words with same prefix

    • Tries are collision free

    • Trie is also known as prefix tree

    Question 38

    Given a disjoint-set forest with N elements, what is the maximum height of the trees in the forest after M union operations if union by rank and path compression techniques are used?

    • O(M)

    • O(logM)

    • O(N)

    • O(N + M)

    There are 38 questions to complete.

    Last Updated :
    Take a part in the ongoing discussion