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
Lina20 [59]
3 years ago
8

Write pseudo codes for the function Change(A, heapsize, i, newValue) that accesses an element at the index i in the max-heap A (

Note that the index of this heap starts from 1), and changes its value to the value of the parameter newValue, and also maintains its max-heap property. Note that newValue can be larger or smaller than the value of A[i]. You can use the heap functions/algorithms to implement this function. Also if the value of i is out of the range, then it should not change anything in the heap. void Change(A, heapsize, i, newValue)
Computers and Technology
1 answer:
natima [27]3 years ago
5 0

Explanation:

The following pseudo-code for the function void Change(A, heapsize, i, newValue).

ALGORITHM:

STEP1: Define the function void Change(A, heapsize, i, newValue).

STEP2: Than find the maximum heap in an array A[i].

STEP3: Then index the following the right child, the left child and the parent.

maxheap property(A1 i)

maxright = left(i)

maxleft = right(i)

STEP4: Then, check the following condition, if maxleft <= A heapsize and [maxleft > A[i]].

then, laregest = i;

STEP5: Then, else

then, smallest = i;

STEP6: Then, check the condition, if maxright < = A heapsize.

then, largest = maxright;

STEP7: Set condition, if larger!= .

then, change A[i] with A[larger];

STEP8: Then built the maximum heap of an array element.

then, built - maxheap property (A)

then, A.heapsize = A.l

Set, if i = A.l/2 dowin to 1

then, maxheap property(A1 i)

STEP9: Then,  

void Change(A, heapsize, i, newValue)

{

if (indexi < o or index>=heapsize)

then, returm FALSE;

int old_val=heapA[index i].getkey()

heapA[index].setkey(new_val)

after that,  

if(new_val > old_val)

then, choose up the element in (index i)

else

then: choose down the element in (index)

return TRUE;

then call the function,  

Change()

STEP10: AFTER ALL, if the value of i is out of the range.

Then, change anything in heap A.

You might be interested in
Identity theft, where people steal personal information, continues to be a problem for consumers and businesses. Assume that you
svetlana [45]

Answer:

Secure the personal information with complex multi-factor authentication and configure intrusion detection and prevention and a firewall.

Explanation:

Multi-factor authentication is a method of securing a client's personal information from the client's side to the data centre. It uses more than one security processes not policies. There key be three authentications process like a password, security token and biometrics or two authentications like password and biometrics or token.

The firewall and intrusion detection and prevention are vulnerability preventive method to detect and stop cyber attacks.

5 0
4 years ago
Which of the following statements is correct? A. The columns will be listed in the results in the same order they are stored in
Mrac [35]

Hello! The answer to your question would be as followed:

C. The columns will be listed in the results in the same order they are listed in the SELECT clause of the SELECT statement.

5 0
4 years ago
A short
alexandr402 [8]

Explanation:

Java Bitwise Operators

Operator Description Example

>> (right shift) Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. A >> 2 will give 15 which is

8 0
3 years ago
What would you enter in the windows run box to launch system configuration?
tankabanditka [31]
Msconfig is what u would enter to launch system configuration
6 0
4 years ago
Which of the following does not correctly declare an ArrayList?
kotegsom [21]

Answer:

Option b. ArrayList‹Integer› = new ArrayList‹Integer›(10) does not correctly declare an ArrayList.

<u>Explanation</u>:

ArrayList in Java dynamically stores elements in it. It also called as re- sizeable array as it expands  in size when elements are added and decreases when an element is removed from it. This array list class also allows to use duplicate and null values.

The syntax for creating Array list is as follows

ArrayList<Type> obj = new ArrayList<Type>()

Type  specifies the type of ArrayList like Integer, Character, Boolean etc, and obj is the object name. But in the option b ArrayList‹Integer› = new ArrayList‹Integer›(10)  object name is missed and not specified.

6 0
3 years ago
Other questions:
  • Which of the following correctly describes the reason for quality customer service?
    15·2 answers
  • It can be useful to have a mentor because they will help you
    7·2 answers
  • What is the automotive name for the large wires that allow more electrical current to flow ?
    12·1 answer
  • Without a well-designed, accurate database, executives, managers, and others do not have access to the ____________________ they
    15·1 answer
  • You’ve been stuck in bumper-to-bumper traffic for nearly an hour on a hot summer day. The temperature warning light has just com
    7·1 answer
  • 14. Convert 11110111 from binary to denary<br> (1 Point)
    12·2 answers
  • Which of the following Internet protocols is used to request and send pages and files on the World Wide Web?
    15·1 answer
  • A man-made world event that would affect the labor market would be a(n) _____.
    13·1 answer
  • k-means clustering cannot be used to perform hierarchical clustering as it requires k (number of clusters) as an input parameter
    15·1 answer
  • You decide to use a packet sniffer to identify the type of traffic sent to a router. You run the packet sniffing software on a d
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!