16 - , T . You do not need to remember this formulation,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
3. (Special representations) We have invented special ways of drawing certain important relations. For example, we can represent a relation on R 2 as an area in the plane. The following diagram represents the relation R de±ned by x R y if and only if x + y 7 . 7 7 y x 4. (Matrix) Suppose that A = { a 1 ,a 2 ,... ,a m } and B = { b 1 ,... ,b n } . We can represent R by an m × n matrix M of booleans ( T , F ) , where recall from the logic course that T stands for True and F for False . For i = 1 ,... ,m and j = 1 ,... ,n , de±ne M ( i,j ) = T , a i R b j = F , otherwise where M ( i,j ) is the usual notation for the ith row and jth column of the matrix. For example, if A = { a 1 ,a 2 } , B = { b 1 ,b 2 ,b 3 } and R = { ( a 1 ,b 1 ) , ( a 2 ,b 1 ) , ( a 2 ,b 2 ) } as before, then the matrix is ± T F F T T F ² It is also common to use the elements 0 , 1 instead of F
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: , T . You do not need to remember this formulation, although past exam questions have asked questions about this representation. 5. (Implementation) On a computer, we can store a relation using an array. This allows random access and easy manipulation, but can be expensive in space if the relation is much smaller that A B . With a sparse relation, where there are not many ordered pairs, an alternative approach is to use an array of linked lists, called an adjacency list . For example, consider the binary relation R = { (1 , 1) , (1 , 3) , (2 , 1) } on set 17...
View Full Document

Ask a homework question - tutors are online