Find Jobs
Hire Freelancers

Dafny - Binary min-heap Software Verification

€8-30 EUR

In Progress
Posted over 5 years ago

€8-30 EUR

Paid on delivery
A binary min-heap without duplicated elements is a binary tree which satisfies two properties: 1. the value of each node is (strictly) greater then the value of its parent, with the minimum-value element at the root (this is the min-heap property), and 2. is complete. Binary heaps have efficient implementations on arrays. There are logarithmic algorithms to insert an element in a heap and to remove the minimum element from an heap. We concentrate on the former. Consider the below class featuring a partial implementation of a binary min-heap. The root is the second item in the array. We skip the index zero cell of the array for the convenience of implementation.1 class Heap { var s ize : nat ; var heap: array <int >; method i n s e r t ( x: i nt ) requires minHeap ( ) ensures minHeap ( ) { / / I n s e r t the new item at the end of the array var pos := s ize + 1; / / Perco late up while pos > 1 && x < heap [ pos / 2 ] { heap [ pos ] := heap [ pos / 2 ] ; pos := pos / 2 ; heap [ pos ] := x ; } } Write predicate minHeap() and add the necessary contract and annotations to method insert () so that Dafny accepts the code. In method insert, assume that there is enough room in the heap array to contain the new element. Suggestion: proceed in two steps. 1. Start with the quasi binary heap property. 2. Once this is working proceed to show that the complete binary tree property is preserved by method insert ().
Project ID: 18231609

About the project

2 proposals
Remote project
Active 5 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
2 freelancers are bidding on average €32 EUR for this job
User Avatar
Hello I am C++, Java and algorithm expert and interested in this project. I have reviewed details and confident to handle the project perfectly. I will keep codes simple and well documented. I can start now. Please share more details so we can discuss further. Regards, anshu
€30 EUR in 1 day
4.7 (577 reviews)
7.6
7.6
User Avatar
Hello, I have a lot of experience in C/C++ and Operating System, Algorithm and Data Structure. I am ready to discuss with you Thank you.
€34 EUR in 1 day
4.9 (134 reviews)
6.4
6.4

About the client

Flag of PORTUGAL
Lisboa, Portugal
5.0
1
Payment method verified
Member since Jan 27, 2014

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.