Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

OZ Programming Languge. A record is described by label, ealures, and fields. For

ID: 3870996 • Letter: O

Question

OZ Programming Languge.

A record is described by label, ealures, and fields. For a tuple, the set of its leatures is uriquely identified by its width. a) Explain why the number of tuple's features is uniquely dientified by its widthl For a general record this is different. Therefore, Ozprovides an operation that returns the arity of a record is a sorted list, where integers go first in increasing order, folloved by atoms in increasing order. For example, irity (:1 a:2 3:3) } returns [3 b] b) Can you think of a good reason why the arity is sorted? To construct a record without giving lields, you can use MaceRecordwhich lakes a label and a list of Tealures (which does net need to be sorted). c) What is the answer provided by this example. declare [MakeRecord r [b a 31 } X.b-a x.a-b Browse X

Explanation / Answer

A)      Explain why number of tuple’s features is uniquely identified by its width:

Records are structured compound entities. Each record has ‘label’ and ‘arguments’.

For example following is a record:

                    chegg(key:K name:N occupation:O)

It has three arguments and a label ‘chegg’. Each arguments are a pair of Feature:Field.

So, Features from above records are: key, name, occupation

Field : K, N, O are variables.

We can omit the features from the record and in OZ this is called a tuple.

Tuples are special records with integer as for instance :

Tuple: chegg(K N O)

         It can also be written as chegg(1:K 2:N 3:O) which is called syntactic notation.

Tuple’s features are arbitrary and uniquely identified by its width because :

è To intact the record structure

è Helps to assign record structure to a node

è To perform equality test between two record structure

è To check whether two nodes have same structure

è Helps to check each pairwise corresponding nodes have identical OZ values.

B)      Why arity is sorted?

Arity is list of features from a tuple which are sorted lexicographically. They are sorted due to which we can search element from a record in more optimized way.

For example: We can perform binary search when list of integers are sorted. So based on the sorted features of tuple we can search element efficiently.

Assigning of two structure is easy

Easy to check whether pairwise corresponding nodes have identical OZ values etc.

C)      Output : True

Equality test check whether two records X , Y are equal or not.

It return Boolean value TRUE if nodes of same structure and each pairwise corresponding have identical OZ values.