GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
85 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 Active (1.9k points)  
retagged by | 85 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 Active (1.9k points)   | 47 views
0 votes
0 answers
3
asked in DS by Vishal Goyal Active (1.9k points)   | 44 views


Top Users Jul 2017
  1. Bikram

    4386 Points

  2. manu00x

    2464 Points

  3. Debashish Deka

    1850 Points

  4. joshi_nitish

    1686 Points

  5. Arjun

    1340 Points

  6. Hemant Parihar

    1184 Points

  7. Arnab Bhadra

    1112 Points

  8. Shubhanshu

    1080 Points

  9. Ahwan

    900 Points

  10. rahul sharma 5

    732 Points


24,031 questions
30,983 answers
70,430 comments
29,358 users