Capgemini Data Structures & Alogrithm MCQ

Questions 11: Consider an array of integer : A

A = {1,2,6,5,7,8,9,6,7},{2,2,2,4,5,2,2,1,2}
A function named "min" takes an array as a parameter and returns the minimum element of the array. Find the value of the following expression:

min(A[0])+min(A[1])

  • Options
  • a : 2
  • b : 3
  • c : 4
  • d : 5
  • Answer: a) 2

    Questions 12: Consider a stack of integers.
    The stack is allocated 5 memory cells.

    STACK : 1, 3, 3, _, _

    The following operations are performed on the stack :
    i) PUSH(STACK,4)
    ii) PUSH(STACK,10)
    iii) POP(STACK,ITEM)


    What value will be stored in ITEM?

  • Options
  • a : 1
  • b : 10
  • c : 4
  • d : 3
  • Answer: b) 10

    Questions 13: Consider an array S of integers :
    S = {1, 1, 1, 2, 4, 3, 4, 3, 4, 3, 2, 2, 3, 4, 3}

    The following operations are performed on the array:
    1. Duplicates are removed.
    2. 4 is appended.
    3. 1 is appended.
    4. 2 is appended.
    5. Duplicates are removed.
    Calculate the sum of all the elements of the array

  • Options
  • a : 6
  • b : 8
  • c : 9
  • d : 10
  • Answer: d) 10

    Questions 14: Consider a tree, T shown in the diagram below, calculate the number of descendant nodes of the root node

  • Options
  • a : 21
  • b : 24
  • c : 20
  • d : 18
  • Answer: c) 20

    Questions 15: Consider a tree shown in the diagram below.

    Which of the following vertices have no siblings?

  • Options
  • a : D and L
  • b : M
  • c : G
  • d : C
  • Answer: b) M

    Questions 16: Consider a tree shown in the diagram below.

    Calculate the degree of root node in the tree.

  • Options
  • a : 4
  • b : 2
  • c : 3
  • d : 1
  • Answer: c) 3


    More Questions Will Be Uploaded Soon............