L7_List - What are Lists The next Data Structure that we...

Info iconThis preview shows pages 1–16. Sign up to view the full content.

View Full Document Right Arrow Icon
What are Lists The next Data Structure that we learn is called a list . [4, 8, 5, 6, 7, 3] Head Tail Operations: There are many operations on lists. The basic ones are Obtaining the head of a list. Obtaining the tail of a list. Page 1 of 47
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Head and Tail of a List [ , , , , , ] Head Tail Head : Tail : [ , , , , ] Head is an element. Tail is a list. Page 2 of 47
Background image of page 2
Head and Tail of a List ['a', 'd', 'e', 'b', 's', 'a', 'e'] Head : 'a' Tail : ['d', 'e', 'b', 's', 'a', 'e'] Head is an element. Tail is a list. Page 3 of 47
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Head and Tail of a List [4, 5, 8, 9, 7, 6, 3] Head : 4 Tail : [5, 8, 9, 7, 6, 3] Head is an element. Tail is a list. Page 4 of 47
Background image of page 4
Head and Tail of a List [4] Head : 4 Tail : [] Head is an element. Tail is a list. Page 5 of 47
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Head and Tail of the Empty List [] Head : - Tail : - Empty List has no head. Empty List has no tail. ( In fact, Empty List is usually seen as a constant. ) Page 6 of 47
Background image of page 6
Head and Tail of a List [[1,2], [3,4,8,9], [5,6,7]] Head : [1,2] Tail : [[3,4,8,9], [5,6,7]] Head is an element. Tail is a list. Page 7 of 47
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Head and Tail of a List ['a', [3,4,8,9], , 23] Head : 'a' Tail : [[3,4,8,9], , 23] Head is an element. Tail is a list. Page 8 of 47
Background image of page 8
Head and Tail of a List [[], [2,3], [1]] Head : [] Tail : [[2,3], [1]] Head is an element. Tail is a list. Page 9 of 47
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Head and Tail of a List [[]] Head : [] Tail : [] Head is an element. Tail is a list. Page 10 of 47
Background image of page 10
List Operations The list construction operation constructs a new list from a head and a list. Cons(4, [5, 8, 9, 7, 6, 3]) [4, 5, 8, 9, 7, 6, 3] Page 11 of 47
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
List Operations The list construction operation constructs a new list from a head and a list. Cons(4, [8]) [4, 8] Page 12 of 47
Background image of page 12
List Operations The list construction operation constructs a new list from a head and a list. Cons(9, []) [9] Page 13 of 47
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
List Operations The list construction operation constructs a new list from a head and a list. Cons(7, Cons(8, Cons(9, []) )) Cons(7, Cons(8, [9] ) ) Cons(7, [8, 9] ) [7, 8, 9] Page 14 of 47
Background image of page 14
The list construction operation constructs a new list from a head and a list. Cons([1,2,3], [4, 5, 6])
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 47

L7_List - What are Lists The next Data Structure that we...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online