Question: Sparse Representation of Binary Numbers We can represent binary numbers as a list of increasing integers where each element is a power of two: type

 Sparse Representation of Binary Numbers We can represent binary numbers as

a list of increasing integers where each element is a power of

two: type nat-int list For example: 5 1 4] or 15-[1 2;

Sparse Representation of Binary Numbers We can represent binary numbers as a list of increasing integers where each element is a power of two: type nat-int list For example: 5 1 4] or 15-[1 2; 4; 8 or 17 16]. We can represent O with the empty ist. The sparse representation can be a more useful way of representing numbers than using a dense representation i.e. one using ones and zeroes), especially for human-readable arithmetic 1. Implement a functioninc nat -> nat which increments a given sparse binary number. 2. Implement a function dec : nat-> nat which decrements (i.e., subtracts one from) a given sparse binary number. If given 0 as input, you should raise the exception Domain 3. Implement a function add nat -> nat which adds two sparse binary numbers Implement a function sbinToInt nat -> int using a helper function toInt which translates a given sparse binary number to an integer tail-recursively using an accumulator Sparse Representation of Binary Numbers We can represent binary numbers as a list of increasing integers where each element is a power of two: type nat-int list For example: 5 1 4] or 15-[1 2; 4; 8 or 17 16]. We can represent O with the empty ist. The sparse representation can be a more useful way of representing numbers than using a dense representation i.e. one using ones and zeroes), especially for human-readable arithmetic 1. Implement a functioninc nat -> nat which increments a given sparse binary number. 2. Implement a function dec : nat-> nat which decrements (i.e., subtracts one from) a given sparse binary number. If given 0 as input, you should raise the exception Domain 3. Implement a function add nat -> nat which adds two sparse binary numbers Implement a function sbinToInt nat -> int using a helper function toInt which translates a given sparse binary number to an integer tail-recursively using an accumulator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!