We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

ASSIGNMENT 2
Deadline
Your assignment must be uploaded/submitted at or before 4th June 2015.
Uploading instructions
Please view the assignment submission process document provided to you by the Virtual University to upload the assignment. And submit your solution as Microsoft word file.
Rules for Marking
It should be clear that your assignment will not get any credit if:
oThe assignment is submitted after due date.
oThe submitted assignment does not open or run.
oThe assignment is copied
Problem #1: 10 marks
Recall BuildHeap (1,n) that builds a heap of n-elements from an array:
for i = n/2 downto 1 do
bubble_down(i);
For the array drawn below, fill the boxes for each iteration of BuildHeap(1,10).
Assume that the root of the heap holds the maximum element.
15
20
8
56
2
38
36
26
28
7
Problem #2: 5 marks
Arrange the following in the Most to Least complexity order.
210000023232log1000000000000000100000000000000log*log1000000000000log*!log**1000000000000000

Views: 19423

Attachments:

Replies to This Discussion

 

15

20

8

56

2

38

36

26

28

7

 

15

20

8

56

7

38

36

26

28

2

 

15

20

8

56

7

38

36

26

28

2

 

15

20

38

56

7

8

36

26

28

2

 

15

56

38

28

7

8

36

26

20

2

 

56

28

38

26

7

8

36

15

20

2

 

 

You can solve the 1st question after watching this video..

https://www.youtube.com/watch?v=YJa3GpNUrNs

sheraz akram my 5th itration answer is

28 56 38 26 2 8 36 15 20 7 

if wrong plz send me correct  1 to 5 itrations 

Value in parent Node must be greater from all its child nodes' values. Your answer is wrong because you are not doing this. You need to do this in each iteration. 

Yes it is correct

Sheraz Akram bhai kia ap explain kr skte ho k kaisy 5th iteretion mein ap ne jump le lia ahi 15 wala. hamen sirf 5th iteretion tak values put krni hai. cmplt max heap yahan pe 5 se ziada iteretions se ziada le gi. ap aik bar phr se chek kr lo plz apka galat hai

aap ye link visit kr len samaj aa jay gi. but is main parent node main small value hai means hm log inverse main kry gy. ye sirf understanding k lie hai k heap kesy build kerty hain.

https://www.cs.usfca.edu/~galles/visualization/Heap.html

For the array drawn below, fill the boxes for each iteration of BuildHeap(1,10).

 sir ne ye bola hai

yes it is correct

yr i think yahan 36 r 8 and 15 r 20 b change hoga

5th iteration

56,28,38,26,7,36,8,20,15,2

Sheraz Akram bro jb min heap banaty hain tu parent node mai value small hoti hai or child nodes mai value greater hoti hai???? 

or max heap mai is k opposite hota hai??? explain kary agr wrong hn tu plz

Yes, MaxHeap mein Parent node ki value uskay tamaam child nodes se greater honi chahiye...

Aur MinHeap mein Parent node ki value uskay tamaan child nodes se small honi chahiye..

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service