GeeksforGeeks » Multiple Choice Questions

Data Structure Questions

(2 posts)

Tags:

  1. kapil
    guest
    Posted 2 years ago #

    1. In a complete binary tree, the parent of any node at index i can be determined by
    a. .2i
    b. 2i+1
    c. i/2
    d. i^2-1

    2. Which of these is the correct big -Oh expression for 1+2+3+...+n?
    a. O(log n)
    b. O(n)
    c. O(n log n)
    d. O(n^2)

  2. geek4u
    guest
    Posted 2 years ago #

    For 1, answer is (c). Take one example of any complete tree and you can see it.

    For 2, answer is (d). 1 + 2... n = n(n+1)/2 = O(n*2)


Reply

You must log in to post.

RSS feed for this topic