Question

SECTION B (4 QUESTIONS, 90 MARKS) Question 4. [32 marks in total] For this question, assume the definition of Java class Heap

0 0
Add a comment Improve this question Transcribed image text
Answer #1

(a)

Given elements 35, 4,72, 36,49, 50 Fixst elamont is 35 35 Second eloment is 4 (ue have to nsert neis eoment in the end Third+2 36 35 Fifth eloment is 49. 25 Here 49 is qreaton than its parent nodes have to interchange 36. So We node 49 and the 36

(b)

folloos: Deletion Operation: The heap is as 50 B6 35 deletion must be the Yoot Dunsing doletod nooda firest xeplaies and thenRaplocing 6ith Iast node hoole 50 36 49 49 is greator than 36. So 36 36 35 (35 49 interchanging get 4 we Nots, deleting repla(c)

Wosst fors care time Compleity heap twth for ihsestion eloments is a ollgn The oosst Care is hothing but eloment which the he(d)

fallows Cd) Gi ven axYay representation is ar index 6 7 4 5 89 3 2 value 10 40 30 45 70 60 40 50 25 10 xepresend Aopth (hoig(e)

Should have uploaded the appendix programme for modification as mentioned.

Add a comment
Know the answer?
Add Answer to:
SECTION B (4 QUESTIONS, 90 MARKS) Question 4. [32 marks in total] For this question, assume the definition of Java clas...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program insertion and deletion functions for a max heap represented as a linked binary tree. Assume that each...

    Write a C program insertion and deletion functions for a max heap represented as a linked binary tree. Assume that each node has a parent field as well as the usual left child, right child, and key fields. -Condition : Do not use Array representation. Use the following structure. typedef struct node *treePointer; typedef struct node { int key; treePointer parent; treePointer leftChild, rightChild; }; - INPUT i k : Insert the node with the key value of k in...

  • Write a C program insertion and deletion functions for a max heap represented as a linked binary tree. Assume that each...

    Write a C program insertion and deletion functions for a max heap represented as a linked binary tree. Assume that each node has a parent field as well as the usual left child, right child, and key fields. -Condition : Do not use Array representation. Use the following structure. typedef struct node *treePointer; typedef struct node { int key; treePointer parent; treePointer leftChild, rightChild; };    - INPUT i k : Insert the node with the key value of k in...

  • Please finish all the questions,Thanks Following is Appendix assume the definition of Java class Heap given in the App...

    Please finish all the questions,Thanks Following is Appendix assume the definition of Java class Heap given in the Appendix For this question, a. (2 marks Consider the following heap 30 12 20 19 6 10 18 Given the array representation of a heap discussed in class, what is the array that corre sponds to this heap? b. (5 marks) Successively insert into the heap of part (a.) 22, 35 and 11, in that order. Use the standard heap insertion algorithm....

  • Please submit only Python source code. 1. Arithmetic trees 50 marks You are given an input file with multiple pairs of...

    Please submit only Python source code. 1. Arithmetic trees 50 marks You are given an input file with multiple pairs of input lines. The first line of each pair is a tree given as a predecessor array. The second line is the value at the corresponding node. Values at leaf nodes (nodes with no children) are integers. At non-leaf nodes, the two possible values are + or *. The tree represents an arithmetic expression where the value at a non-leaf...

  • Assignment on Java programing 1. Write programs for the following exercises in Java. Each file should...

    Assignment on Java programing 1. Write programs for the following exercises in Java. Each file should have short description of the implemented class and for files with main method the problem it is solving. Make sure your files have appropriate names. Programs should write output to the Console. b) BST: Implement Binary Search Tree ADT with insert(int key), delete(int key), Node find(int key), and in-order traverse() where it prints the value of the key. Your operations should use recursion. The...

  • Need help in the below question. Answer in java Start with the tree.java program (Listing 8.1)...

    Need help in the below question. Answer in java Start with the tree.java program (Listing 8.1) and modify it to create a binary tree from a string of letters (like A, B, and so on) entered by the user. Each letter will be displayed in its own node. Construct the tree so that all the nodes that contain letters are leaves. Parent nodes can contain some non-letter symbol like +. Make sure that every parent node has exactly two children....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT