联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Java编程Java编程

日期:2019-08-24 11:14

SIT221 Data Structures and Algorithms Trimester 2, 2019

Practical Task 6.2

(Credit Task)

Submission deadline: 10:00am Monday, September 2

Discussion deadline: 10:00am Saturday, September 14

General Instructions

In this task, answer all the following questions and complement each answer with a detailed explanation.

1. After hearing about a Binary Max‐Heap data structure,  Johnny English decides to implement it for his

supper‐duper algorithm. However, as he was not paying enough attention in class, his implementation of

the DownHeap procedure (also widely known in the literature as Max‐Heapify) is not absolutely correct.

He gave us the following pseudocode of his implementation:

Function JE_DownHeap(index x):

If ( H[Left(x)].key > H[x].key )

{

Swap elements H[x] and H[Left(x)]

JE_DownHeap(Left(x))

}

ElseIf ( H[Right(x)].key > H[x].key )

{

Swap elements H[x] and H[Right(x)]

JE_DownHeap(Right(x))

}

Your task is to give an example of a max‐heap for which the above JE_DownHeap procedure fails. More

specifically, you need to propose a heap where the root 1 is the only node breaking the essential Max‐

Heap Property so that running the above procedure JE_DownHeap(1) does NOT result in a valid max‐

heap. Use your instance to clearly illustrate how such heap may look like. You must draw the heap

before and after running JE_DownHeap(1). Note that your instance can be made quite small.

2. Assume now that Johnny English has eventually fixed the aforementioned problem and developed a

correct implementation of a max‐heap that provides all the standard operations such as:

‐ DeleteMax, Insert(K), IncreaseKey(X, K), in a logarithmic log time; and

‐ Max, in a constant 1 time,

where is the number of stored elements. Johnny English wants to add a new capability to this max‐heap

.Specifically, he would like to implement a DeleteElement(X) operation that removes element H[x] from

the max‐heap consisting of elements in a logarithmic log time. Note that the H[x] does not need

to be the maximum‐key element in .Also, naturally, has to maintain the Max‐Heap Property after

deletion of H[x].

Your task is to help Johnny English by providing a pseudocode of such a DeleteElement(X) operation with

a brief analysis of its running time as function of elements.

3. Johnny English knows that the maximum element of a binary max‐heap can be obtained by means of Max

operation in a constant 1 time. He however wants you to develop an efficient method (in pseudocode)

that finds the maximum element in log time, where 1 Remember that both insertion

and removal in a binary max‐heap of size takes a log time.

SIT221 Data Structures and Algorithms Trimester 2, 2019

Further Notes

You may find exploring the content of chapter 9.3 of the course book “Data Structures and Algorithms in

Java” by Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser (2014) useful to solve these

tasks. You may access the book on‐line for free from the reading list application in CloudDeakin available

in Resources Additional Course Resources Resources on Algorithms and Data Structures Course

Book: Data structures and algorithms in Java.

Marking Process and Discussion

To get this task completed, you must finish the following steps strictly on time: Submit your answers to the task via OnTrack submission system. You may submit a hand‐written and then

scanned document, but ensure that the text is very clear to read. Note that this is a theoretical task, thus

we do not expect you to write any program code.

Meet with your marking tutor to explain your solutions. When the solutions are hand‐written, do not

forget to bring them with you. Cloud students must record a short video explaining their work and use a

sort of white‐board, e.g. a graphical editor, or a scanned document with the answers. Answer all additional (theoretical) questions that your tutor may ask you. Questions are likely to cover

lecture notes, so attending (or watching) lectures should help you with this compulsory interview part.

Please, come prepared so that the class time is used efficiently and fairly for all the students in it. You

should start your interview as soon as possible as if your answers are wrong, you may have to pass another

interview, still before the deadline. Use available attempts properly.

Note that we will not check your solution after the submission deadline and will not discuss it after the

discussion deadline. If you fail one of the deadlines, you fail this task that may impact your performance and

your final grade in the unit. Unless extended for all students, the deadlines are strict to guarantee smooth

and on‐time work through the unit.

Remember that this is your responsibility to keep track of your progress in the unit that includes checking

which tasks have been marked as completed in the OnTrack system by your marking tutor, and which are still

to be finalised. When marking you at the end of the unit, we will solely rely on the records of the OnTrack?

system and feedback provided by your tutor about your overall progress and quality of your solutions.


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp