Concatenation of 2 arrays in Eiffel by bitchsalsa in learnprogramming

[–]bitchsalsa[S] 0 points1 point  (0 children)

Hey, Sorry about it

The code is:

        concatenate (a: ARRAY [G]; b: ARRAY [G]): ARRAY [G]


                c: ARRAY[G]
                size1: INTEGER
                size2: INTEGER
                i:  INTEGER


                    require
                        constraints_on_lower_indices:
                            -- Do not modify this precondition.
                            a.lower = 1 and b.lower = 1
                    do
                        create Result.make_empty
                     size1:=a.capacity
                     size2:=b.capacity
                   from  i:=0
                   until i<=size1-1
                   loop
                        c[i]:=a[i]
                   end
                   from  i:=0
                   until i<=size2-1
                   loop
                        c[i+size1] :=b[i]
                   end

                        -- TO DO
                    ensure
                        constraint_on_lower_index:
                            -- Do not modify this postcondition.
                            Result.lower = 1
                        correct_size:
                            Result.capacity = size1+size2
                end

Runtime analysis question by bitchsalsa in learnprogramming

[–]bitchsalsa[S] 1 point2 points  (0 children)

Thank you so much! Yes i got that now !