Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following formal specification, write the TSL specification for Search

ID: 3760265 • Letter: G

Question

Given the following formal specification, write the TSL specification for Search.

procedure Search (Key : ELEM ; T: SEQ of ELEM;

       Found : BOOLEAN; L: ELEM_INDEX) ;

Pre-condition

            -- the sequence has at least one element

            T’FIRST <= T’LAST

Post-condition

            -- the element is found and is referenced by L

            ( Found and T (L) = Key)

or

            -- the element is not in the array

            ( not Found and

            not (exists i, T’FIRST <= i <= T’LAST, T (i) = Key ))

Explanation / Answer

The equivalance partitions for the search routine.
with sequence value and element value.
The single value with the element value is in sequence.
The single value with the element value is not in sequnce.
The single value with More than one value with the element value is the first element in sequence
The single value with More than one value with the element value is the last element in sequence.
The single value with more than one value with the element value is the the middle element in sequence.
The single value with more than one value with the element value is Not in sequence.


The input sequence with value is 17 and the key is 17 the output as true,1
The input sequence with value is 17 and the key is 0 the output as false,??
The input sequence with value is 17,29,21,23 with key is 17 the output as true,1
The input sequence with value is 41,18,9,31,30,16,45 with key is 45 the output as true,7
The input sequence with value is 17,18,21,23,29,41,38 with key is 23 the output as true,4
The input sequence with value is 21,23,29,33,38 with key is 25 the output as false,??

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote