On the other hand, the operator back ()r: Zn → Ln receives a list and returns the list that results rom reversing the order of its elements. For instance: (→3 →4 → 10 →7)r=→7 →10 →4 →3 a) Inductively define the reverse operator. b) Show by structural induction that given two lists 41 and L2 It is true that (L1 • L2)r= Lr 2 º Lr1

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
In classes we define the set of linked lists on the natural ones LN as the smallest set
that meets the following rules:
1. Ø E LN.
2. Yes LE LN and kEN, then L→ k E LN.
The operator of concatenation of lists, denoted by , receives two lists and returns the list that
results from adding all the numbers from the second list to the end of the first. For instance:
(→3 →4 → 10) °(→2 →6) =→3 →4 →10 →2 →6
We then define the operator •: Ln × LN → Ln inductively like:
1. L•Ø = L, with LE LN.
2. L•(L-→ k) = (L • L} → k, with L, L'E Ln.
Notice that the concatenation operator is associative: (L1 • L2) • L3 = L1 •(L2 • L3).
On the other hand, the operator back ()r: Ln → Ln receives a list and returns the list that results
from reversing the order of its elements. For instance:
(→3 →4 → 10 →7),=→7 →10 →4 →3
a) Inductively define the reverse operator.
b) Show by structural induction that given two lists L1 and L2 It is true that
(L1 • L2)r= Lr 2 ° Lr1
Transcribed Image Text:In classes we define the set of linked lists on the natural ones LN as the smallest set that meets the following rules: 1. Ø E LN. 2. Yes LE LN and kEN, then L→ k E LN. The operator of concatenation of lists, denoted by , receives two lists and returns the list that results from adding all the numbers from the second list to the end of the first. For instance: (→3 →4 → 10) °(→2 →6) =→3 →4 →10 →2 →6 We then define the operator •: Ln × LN → Ln inductively like: 1. L•Ø = L, with LE LN. 2. L•(L-→ k) = (L • L} → k, with L, L'E Ln. Notice that the concatenation operator is associative: (L1 • L2) • L3 = L1 •(L2 • L3). On the other hand, the operator back ()r: Ln → Ln receives a list and returns the list that results from reversing the order of its elements. For instance: (→3 →4 → 10 →7),=→7 →10 →4 →3 a) Inductively define the reverse operator. b) Show by structural induction that given two lists L1 and L2 It is true that (L1 • L2)r= Lr 2 ° Lr1
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning