1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
suter [353]
4 years ago
6

Outline an algorithm in **pseudo code** for checking whether an array H[1..n] is a heap and determine its time efficiency.

Engineering
1 answer:
svlad2 [7]4 years ago
3 0

Answer:

Condition to break: H[j] \geq max {H[2j] , H[2j+1]}

Efficiency: O(n).

Explanation:

Previous concepts

Heap algorithm is used to create all the possible permutations with K possible objects. Was created by B. R Heap in 1963.

Parental dominance condition represent a condition that is satisfied when the parent element is greater than his children.

Solution to the problem

We assume that we have an array H of size n for the algorithm.

It's important on this case analyze the parental dominance condition in order to the algorithm can work and construc a heap.

For this case we can set a counter j =1,2,... [n/2] (We just check until n/2 since in order to create a heap we need to satisfy minimum n/2 possible comparisionsand we need to check this:Break condition: [tex]H[j] \geq max {H[2j] , H[2j+1]}

And we just need to check on the array the last condition and if is not satisfied for any value of the counter j we need to stop the algorithm and the array would not a heap. Otherwise if we satisfy the condition for each j =1,2,.....,[n/2]p then we will have a heap.

On this case this algorithm needs to compare 2*(n/2) times the values and the efficiency is given by O(n).

You might be interested in
Write a new ARMv8 assembly file called "lab04b.S" which is called by your main function. It should have the following specificat
Len [333]

Answer:

my_mul:

.globl my_mul

my_mul:

   //Multiply X0 and X1

   //   Does not handle negative X1!

   //   Note : This is an in efficient way to multipy!

   SUB SP, SP, 16       //make room for X19 on the stack

   STUR X19, [SP, 0]    //push X19

   ADD X19, X1, XZR     //set X19 equal to X1

   ADD X9 , XZR , XZR //set X9 to 0

mult_loop:

   CBZ X19, mult_eol

   ADD X9, X9, X0

   SUB X19, X19, 1

   B mult_loop

mult_eol:

   LDUR X19, [SP, 0]

   ADD X0, X9, XZR      // Move X9 to X0 to return

   ADD SP, SP, 16       // reset the stack

   BR X30

Explanation:

6 0
4 years ago
The blade tension is correct when you can hear a<br>O Thunk<br>O Twang<br>O Neither​
Anastaziya [24]

Answer:

maybe it's twang because of the blade tension

3 0
3 years ago
State three characteristic of lines of magnetic flux​
stepladder [879]

Answer:

1. The magnetic flux line form a closed loop.

2. The magnetic flux line repel each other.

3. The magnetic flux line never intersect.

5 0
3 years ago
Read 2 more answers
What kind of microscope would be used to study a whole or opaque object?
djyliett [7]

Answer:

the compound light microscope

Explanation:

The stereomicroscope is to study section to study the entire objects in three dimensions at low magnification. A Compound light microscope is used for small or thinly sliced objects under higher magnification than stereomicroscope.

4 0
4 years ago
Show that y = '(t - s)f(s)ds is a solution to my" + ky = f(t). Use g' (0) = 1/m and mg" + kg = 0. 6.1) Derive y' 6.2) Using g(0)
Gre4nikov [31]

Answer:

Explanation:

Given that:

y = \int^t_og'(t-s) f(s) ds \  \text{is  solution to } \ my"ky= f(t)

where;

g'(0) = \dfrac{1}{m}     and mg"+kg = 0

\text{Using Leibniz Formula to prove the above equation:}

\dfrac{d}{dt} \int ^{b(t)}_{a(t)} \ f (t,s) \ ds = f(t,b(t) ) * \dfrac{d}{dt}b(t) - f(t,a(t)) *\dfrac{d}{dt}a(t) + \int ^{b(t)}_{a(t)}\dfrac{\partial}{\partial t} f(t,s) \ dt

So, y = \int ^t_0  g' (t-s) f(s) \ ds

\text{By differentiation with respect to t;}

y' = g'(o) f(t) \dfrac{d}{dt}t- 0 + \int^{t}_{0}g'' (t-s) f(s) ds \\ \\  y' = \dfrac{1}{m}f(t) + \int ^t_0 g'' (ts) f(s) \ ds

y'' = \dfrac{1}{m} f'(t) + g"(0) f(t) + \int^t_o g"'(t-s) f(s)ds --- (1)

Since \ \ mg" (t) +kg (t) = 0  \\ \\  \implies g" (t) = -\dfrac{k}{m} g(t) --- (111) \\ \\  put \  t \  =0 \  we  \ get;\\g" (0) = - \dfrac{k}{m } g(0)  \\ \\  g"(0) = 0 \ \ \ \   ( because \  g(0) =0) \\ \\

Now \ differentiating \ equation (111) \ with \ respect \ to \ t  \\ \\  g"'(t) = -\dfrac{k}{m}g(t)  \\ \\  replacing  \ it \ into  \ equation \ (1) \\ \\ y" = \dfrac{1}{m}f' (t) + 0 + \int ^t_o  \dfrac{-k}{m}g' (t-s) f(s) \ ds \\ \\ y" = \dfrac{1}{m}f' (t) - \dfrac{k}{m} \int ^t_o g' (t-s) \ f(s) \ ds \\ \\  y" = \dfrac{1}{m}f'(t) - \dfrac{k}{m}y \\ \\  my" = f'(t)-ky \\ \\ \implies \mathbf{ my" +ky = f'(t)}

7 0
3 years ago
Other questions:
  • A signalized intersection approach has an upgrade of 4%. The total width of the cross street at this intersection is 60 feet. Th
    15·1 answer
  • Consider a magnetic disk consisting of 16 heads and 400 cylinders. This disk has four 100-cylinder zones with the cylinders in d
    7·1 answer
  • The universe is sometimes described as an isolated system. Why?
    14·1 answer
  • GG(ss) = 1 ss2 + 3 We want to design a feedback control system in a unity feedback structure by adding a controller DD(ss) = ss+
    9·1 answer
  • Weight limit for a pallet
    15·2 answers
  • What are atomic bombs made out of <br> Just wondering
    10·1 answer
  • I really need a good grade please help
    13·1 answer
  • Mera bhai bhot pad marta h loll usko bvasir h kya koi upaye h pls tell pls​
    6·1 answer
  • What is the sum of A+B+ C
    13·1 answer
  • The metal control joints used to relieve stresses caused by expansion and contraction in large ceiling or wall expenses in inter
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!