2c03-review - 00051

2c03-review - 00051 - end[6 function MIDDLE(L List List var...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
7 while (p<>END(L1)) do begin Delete(p, L1); if p<>END(L1)p := NEXT(p, L1); end {delete even elements in List two} p := FIRST(L2); if p<> END(L2) then p := NEXT(p, L2); while (p<>END(L2)) do begin Delete(p, L2); if p<>END(L2) then p := NEXT(p, L2); end {concatenate two Lists} p := FIRST(L1); while (p <> END(L1)) do p := NEXT(p,L1) ; q := FIRST(L2); while (q <> END(L2)) do begin INSERT(RETRIVEV(q,L2), p,L1); q := NEXT(q,L2) ; end return(L1);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: end [6] function MIDDLE(L: List): List; var p : position; var n,i : integer; begin p := FIRST(L); n:=0; while (p <> END(L)) do begin p := NEXT(p,L); n:= n+1; end if ((n mod 2) =1) then begin p := FIRST(L); for (i:=1 to (n div 2) do Delete(p,L); p := NEXT(p.L) ; for (i:=1 to (n div 2) do Delete(p,L); end else begin p := FIRST(L); for (i:=1 to (n div 2 )-1) do Delete(p,L); p := NEXT(NEXT(p,L), L); for (i:=1 to (n div 2)-1) do Delete(p,L);...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online