Computers and Technology, 07.04.2020 20:25, takaylawynder
For this question, we will use the heap-supporting functions as seen in the lecture slides as building blocks for this assignment to build a new heap implementation. The heap implementation shown in the lecture slides is an example of a min-heap, in which the smallest element is at the root and all elements in child trees are larger than the value at the root. We can also construct max-heap data structures in which the largest element in the heap is at the root and all elements in child trees are smaller than the root.
The objective is to define SCHEME functions to manipulate a heap which:
1. maintain a binary tree as a heap,
2. use a generic (first order) order relation,
3. provides functions which can determine if a heap is empty? as well as heap-insert, heap-remove, and combine-heaps
(a) Define a SCHEME procedure, named (heap-insert f x H), which adds element x to heap H using the first-order relation f to determine which element belongs at the root of each (sub)tree.
For instance, if we wanted the same behavior as the heaps in the lecture slides (min-heap), we would use the "less than" function as our first-order relation:
(heap-insert < 100 (heap-insert < 10 (list))) (10 () (100 () ()))
If, instead, we wanted a max-heap implementation, where the largest element is at the root of the heap, we would use the "greater than" function as our first-order relation.
(heap-insert > 100 (heap-insert > 10 (list))) (100 () (10 () ()))
Note, you must use the same first-order relation for all of the heap procedures applied to a particular heap structure
HELPER FUNCTIONS
(define (create-heap value left right)
(list value left right))
(define (heap-root H) (car H))
(define (left T) (cadr T))
(define (right T) (caddr T))
(define (heap-insert f x H)
...)
Answers: 2
Computers and Technology, 22.06.2019 00:00, azainababbas
Sam is a data analyst at an advertising firm. he often uses a spreadsheet that contains media ratings details. he would like to filter the spreadsheet data based on different filter criteria. which operators can he use to specify the combination of filter criteria? sam can use the ( blank ) operators to specify a combination of filter criteria.
Answers: 3
Computers and Technology, 22.06.2019 12:40, Rententen3845
How do i get the most points, without any effort?
Answers: 2
Computers and Technology, 22.06.2019 17:00, smartoa
Annie is creating a corporate report for a company’s annual meeting. in the report, she wants to add the signature of various department heads. which device can annie use to capture signatures to include in the report? a. printer b. monitor c. e-reader d. digitizing tablet
Answers: 1
For this question, we will use the heap-supporting functions as seen in the lecture slides as buildi...
Mathematics, 16.09.2020 05:01
Mathematics, 16.09.2020 05:01
Physics, 16.09.2020 05:01
Mathematics, 16.09.2020 05:01
Mathematics, 16.09.2020 05:01
Mathematics, 16.09.2020 05:01
Mathematics, 16.09.2020 05:01
Spanish, 16.09.2020 05:01
Spanish, 16.09.2020 05:01
Mathematics, 16.09.2020 05:01