Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7041093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:59:47+00:00 2026-05-28T01:59:47+00:00

Suppose we have a binary heap of n elements and wish to insert n

  • 0

Suppose we have a binary heap of n elements and wish to insert n more elements(not necessarily one after other). What would be the total time required for this?

I think it’s theta (n logn) as one insertion takes logn.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:59:48+00:00Added an answer on May 28, 2026 at 1:59 am

    Assuming we are given:

    • priority queue implemented by standard binary heap H (implemented on array)
    • n current size of heap

    We have following insertion properties:

    • W(n) = WorstCase(n) = Θ(lg n) (Theta). -> W(n)=Ω(lg n) and W(n)=O(lg n)
    • A(n) = AverageCase(n) = Θ(lg n) (Theta). -> W(n)=Ω(lg n) and W(n)=O(lg n)
    • B(n) = BestCase(n) = Θ(1) (Theta). -> W(n)=Ω(1) and W(n)=O(1)

    So for every case, we have

    • T(n) = Ω(1) and T(n) = O(lg n)

    WorstCase is when, we insert new minimal value, so up-heap has to travel whole branch.

    BestCase is when, for minimal-heap (heap with minimal on top) we insert BIG (biggest on updated branch) value (so up-heap stops immediately).

    You’ve asked about series of n operations on heap containing already n elements,
    it’s size will grow

    from n to 2*n
    

    what asymptotically is …

    n=Θ(n)
    2*n=Θ(n)
    

    What simplifies our equations. (We don’t have to worry about growth of n , as it’s growth is by constant factor).

    So, we have “for n insertions” of operation:

    • Xi(n) = X_for_n_insertions(n)
      • Wi(n) = Θ(n lg n)
      • Ai(n) = Θ(n lg n)
      • Bi(n) = Θ(n)
    • it implies, for “all case”:
      • Ti(n) = Ω(n) and Ti(n) = O(n lg n)

    P.S. For displaying Theta Θ , Omega Ω symbols, you need to have UTF-8 installed/be compatible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please , suppose i have this Binary Tree structure : Type TPMyTree = ^TMyTree;
Suppose I have a Makefile: all: $(BINARY) $(BINARY): $(OBJS) $(DEBUG_OBJS) #Link objects here $(OBJS):
Suppose I have a binary search tree which, initially, satisfies all of the red-black
Suppose we have a binary file, that contains 32 bit numbers. Each 32bit number
Suppose I have a struct and a file with binary representations of those structs
Suppose I have an ELF binary that's dynamic linked, and I want to override/redirect
Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX
Suppose I have a stringbuilder in C# that does this: StringBuilder sb = new
Suppose we have a table A: itemid mark 1 5 2 3 and table
Suppose I have the following CSS rule in my page: body { font-family: Calibri,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.