Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

------------ Definitions -------------- (Each part graded for correctness in evaluating statement and for fair effort completeness in the justification) Statements like these are used to

image text in transcribed

------------ Definitions --------------

image text in transcribedimage text in transcribed

(Each part graded for correctness in evaluating statement and for fair effort completeness in the justification) Statements like these are used to build the specifications for programs, libraries, and data structures (API) which spell out the expected behavior of certain functions and methods. In this HW question, you're analyzing whether and how order matters for the remove and prepend functions. (a) Prove or disprove the following statement: VELVM EN (prepend( remove(l, m), m)=1). (b) Prove or disprove the following statement: 31 Lam E N prepend( remove(l, m), m) =1). RNA related definitions Consider the following definitions related to RNA strands: Definition Set of bases B = {A, C, U, G}. The set of RNA strands S is defined (recursively) by: Basis Step: A ESC ESUES,GES Recursive Step: If s ES and be B, then sb ES where sb is string concatenation. Definition The function malen that computes the length of RNA strands in S is defined recursively by rnalen: S+Z+ Basis Step: If be B, then rnalen(b) = 1 Recursive Step: If s ES and b E B, then rnalen(sb) = 1 + rnalen(s) Definition The function basecount that computes the number of a given base b appearing in a RNA strand s is defined recursively by basecount: Sx B+N -- i when b = b2 Basis step: If by E B, by E B, basecount(61, 62) when bu + b2 1+ basecounts, bu) when b = b2 Recursive Step: If s S, b1 B, by B, basecount(sb1, 62) basecount(s, 12) when bi #b2 Definition The function mutate: S x BS is defined recursively as: by when bu = A Basis step: If b, E B and by e B, mutate(61, 62) 161 when b17 A Smutate(s, & s, b2b2 when b = A Recursive Step: If s ES, b E B, b2 B, mutate(sb1,b2) mutate(s, 62)when b + A Linked list related definitions Definition The set of linked lists of natural numbers L is defined by: Basis Step: Recursive Step: If 1 L and n N, then (n,1) EL l] EL Definition The function remove Tail: L + L that removes the last node of a linked list (if it exists) is defined by: remove Tail: LL Basis Step: remove Tail(l) = 11 Recursive Step: Ifle L and n N, then remove Taill (1, 1)) = {l), when I = [] (n, removeTail(l) ), when I [] : Definition The function remove : L XN L that removes a single node containing a given value (if present) from a linked list is defined by: remove: L XN + L Basis Step: If me N then remove([], m) = 0 11 Recursive Step: If I EL,NEN, m N, then remove((n, l), m) when n=m (n, remove(l, m)) when n #m Definition: The function prepend : L x NL that adds an element at the front of a linked list is defined by: prepend(1, n) = (n,1) Definition The function append : L x NL that adds an element at the end of a linked list is defined by: append: L XN L Basis Step: If m E N then append(), m) = (m, (1) Recursive Step: Ifle L and n e N and m N, then append(n,1), m) (n, append(1, m)) (Each part graded for correctness in evaluating statement and for fair effort completeness in the justification) Statements like these are used to build the specifications for programs, libraries, and data structures (API) which spell out the expected behavior of certain functions and methods. In this HW question, you're analyzing whether and how order matters for the remove and prepend functions. (a) Prove or disprove the following statement: VELVM EN (prepend( remove(l, m), m)=1). (b) Prove or disprove the following statement: 31 Lam E N prepend( remove(l, m), m) =1). RNA related definitions Consider the following definitions related to RNA strands: Definition Set of bases B = {A, C, U, G}. The set of RNA strands S is defined (recursively) by: Basis Step: A ESC ESUES,GES Recursive Step: If s ES and be B, then sb ES where sb is string concatenation. Definition The function malen that computes the length of RNA strands in S is defined recursively by rnalen: S+Z+ Basis Step: If be B, then rnalen(b) = 1 Recursive Step: If s ES and b E B, then rnalen(sb) = 1 + rnalen(s) Definition The function basecount that computes the number of a given base b appearing in a RNA strand s is defined recursively by basecount: Sx B+N -- i when b = b2 Basis step: If by E B, by E B, basecount(61, 62) when bu + b2 1+ basecounts, bu) when b = b2 Recursive Step: If s S, b1 B, by B, basecount(sb1, 62) basecount(s, 12) when bi #b2 Definition The function mutate: S x BS is defined recursively as: by when bu = A Basis step: If b, E B and by e B, mutate(61, 62) 161 when b17 A Smutate(s, & s, b2b2 when b = A Recursive Step: If s ES, b E B, b2 B, mutate(sb1,b2) mutate(s, 62)when b + A Linked list related definitions Definition The set of linked lists of natural numbers L is defined by: Basis Step: Recursive Step: If 1 L and n N, then (n,1) EL l] EL Definition The function remove Tail: L + L that removes the last node of a linked list (if it exists) is defined by: remove Tail: LL Basis Step: remove Tail(l) = 11 Recursive Step: Ifle L and n N, then remove Taill (1, 1)) = {l), when I = [] (n, removeTail(l) ), when I [] : Definition The function remove : L XN L that removes a single node containing a given value (if present) from a linked list is defined by: remove: L XN + L Basis Step: If me N then remove([], m) = 0 11 Recursive Step: If I EL,NEN, m N, then remove((n, l), m) when n=m (n, remove(l, m)) when n #m Definition: The function prepend : L x NL that adds an element at the front of a linked list is defined by: prepend(1, n) = (n,1) Definition The function append : L x NL that adds an element at the end of a linked list is defined by: append: L XN L Basis Step: If m E N then append(), m) = (m, (1) Recursive Step: Ifle L and n e N and m N, then append(n,1), m) (n, append(1, m))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Accounting, Representation And Responsibility

Authors: Niels Joseph Lennon

1st Edition

0367540436, 9780367540432

More Books

Students also viewed these Accounting questions

Question

Describe the tools that augment the traditional SDLC?

Answered: 1 week ago

Question

2. Follow through with fair consequences.

Answered: 1 week ago

Question

Why should an individual manager be interested in supporting HR?

Answered: 1 week ago