12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Sec. 2.1 Sets <strong>and</strong> Relations 27example, bag [3, 4, 5, 4] is distinct from bag [3, 4, 5], while set {3, 4, 5, 4} isindistinguishable from set {3, 4, 5}. However, bag [3, 4, 5, 4] is indistinguishablefrom bag [3, 4, 4, 5].A sequence is a collection of elements with an order, <strong>and</strong> which may containduplicate-valued elements. A sequence is also sometimes called a tuple or a vec<strong>to</strong>r.In a sequence, there is a 0th element, a 1st element, 2nd element, <strong>and</strong> soon. I indicate a sequence by using angle brackets 〈〉 <strong>to</strong> enclose its elements. Forexample, 〈3, 4, 5, 4〉 is a sequence. Note that sequence 〈3, 5, 4, 4〉 is distinct fromsequence 〈3, 4, 5, 4〉, <strong>and</strong> both are distinct from sequence 〈3, 4, 5〉.A relation R over set S is a set of ordered pairs from S. As an example of arelation, if S is {a, b, c}, thenis a relation, <strong>and</strong>{〈a, c〉, 〈b, c〉, 〈c, b〉}{〈a, a〉, 〈a, c〉, 〈b, b〉, 〈b, c〉, 〈c, c〉}is a different relation. If tuple 〈x, y〉 is in relation R, we may use the infix notationxRy. We often use relations such as the less than opera<strong>to</strong>r (

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!