2c03-review - 00050

2c03-review - 00050 - .next; end end end Time complexity is...

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

View Full Document Right Arrow Icon
6 next: celltype; procedure EXCHANGE1-6(var L: celltype;): var p,q : celltype; var tmp : elementtype; var i: integer; begin p := L; q := L; for i := 1 to 5 do if (q .next <> nil) then q := q .next; while (q .next <> nil) do begin for i := 1 to 5 do if (q .next <> nil) then begin tmp := p .next .element; p .next .element := q .next .element; q .next .element := tmp; end else break; if (q .next <> nil) then begin p := q .next; q:= p; for i := 1 to 5 do if (q .next <> nil) then q := q
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: .next; end end end Time complexity is O(n) 4.[16] Using the operations defined above write procedures (in pseudo-code) to compute the functions from Question 1. [4] procedure NO3ONLY(var L: List;); var p : position; var n : integer; begin p := FIRST(L); n:=1; while (p &lt;&gt; END(L)) do begin if ((n mod 3) = 0) then begin Delete(p,L); n:=n+1; end p := Next(p,L); n:= n+1; end end [6] function C1H2H(L1, L2: List;):List; var p,q : position; begin {delete odd elements in List one} p := FIRST(L1);...
View Full Document

Ask a homework question - tutors are online