GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
63 views

Consider M1 and M2 be two complete binary tree which satisfy max-heap property, each of size ‘n’. What is the time complexity to combine both M1 and M2 such that combine tree will be min heap tree?

  • O (n log n)
  • O (n)
  • O (n2)
  • O (n2 log n)
asked in DS by Junior (899 points)   | 63 views
M1 and M2 are contain total of 2n elements.(stores it in the array and construct min heap)

to construct min heap with n elements is o(nlogn)

=o(2nlog2n)=o(nlogn)

1 Answer

+2 votes
We have 2n number of elements and building a min heap using 2n elemets take O(2n) i.e.O(n) time
answered by (271 points)  

Related questions

0 votes
0 answers
2
asked in DS by Vishal Goyal Junior (899 points)   | 40 views
0 votes
0 answers
3
asked in DS by Vishal Goyal Junior (899 points)   | 40 views


Top Users Mar 2017
  1. rude

    5118 Points

  2. sh!va

    3054 Points

  3. Rahul Jain25

    2920 Points

  4. Kapil

    2730 Points

  5. Debashish Deka

    2602 Points

  6. 2018

    1574 Points

  7. Vignesh Sekar

    1422 Points

  8. Akriti sood

    1382 Points

  9. Bikram

    1350 Points

  10. Sanjay Sharma

    1128 Points

Monthly Topper: Rs. 500 gift card

21,531 questions
26,861 answers
61,191 comments
23,206 users