2c03-review - 00091

2c03-review - 00091 - 1 ) end end if (p 1...

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

View Full Document Right Arrow Icon
4 p 1 := FIRST(L 1 ); p 2 := FIRST(L 2 ); while (p 1 <> END(L 1 ) and p 2 <> END(L 2 )) do begin x 1 := RETRIEVE(p 1 , L 1 ); x 2 := RETRIEVE(p 2 , L 2 ); if (x 1 < x 2 ) then return(true) else if (x 1 > x 2 ) then return(false) else begin p 1 := NEXT(p 1 , L 1 ); p 1 := NEXT(p 1 , L 1 ) end end if p 2 <> END(L 2 ) then return(true) else return(false) end b.[6] NE(L 1 , L 2 ). This function returns TRUE if L 1 L 2 , FALSE otherwise. Function NE(L 1 , L 2 : List) : Boolean p 1 , p 2 : position; x 1 , x 2 : elementtype; begin p 1 := FIRST(L 1 ); p 2 := FIRST(L 2 ); while (p 1 <> END(L 1 ) and p 2 <> END(L 2 )) do begin x 1 := RETRIEVE(p 1 , L 1 ); x 2 := RETRIEVE(p 2 , L 2 ); if (x 1 <> x 2 ) then return(true) else begin p 1 := NEXT(p 1 , L 1 ); p 1 := NEXT(p 1 , L
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 ) end end if (p 1 &lt;&gt; END(L 1 ) or p 2 &lt;&gt; END(L 2 )) then return(true) else return(false) end 5.[30] Give, using A big O @ notation, the worst case running times of the following procedures as a function of n. Provide some calculation/justification. Just a formula only is not sufficient. a.[5] procedure P1(n:integer); var i,j,k : integer; /* assume arrays are such that access error never occurs*/ begin for i:=1 to n do if ( (n is not odd) and (n is not divided by 5)) then begin...
View Full Document

Ask a homework question - tutors are online