This preview shows page 1. Sign up to view the full content.
Unformatted text preview: 20000 j=n O(1)+ i j=1 O(n)) = n i=1 (O(n-i) +O(1)+ O(i*2 n )) = O(n*2 n ) 6. Write procedures to implement the following operations on singly linked lists. What is the time complexity of each operation? Assume a pointer implementation. a. 3ONLY(L). The procedure deletes from L all elements except those on 3k+1, k $ 0, positions. For instance if L=2,3,1,5,7,8,9 then 3ONLY(L) = 2,5,9, i.e. only positions 1,4,7 are left. procedure 3ONLY(var L: celltype;); var p : celltype; var n : integer; begin p := L; n:=1;...
View Full Document
- Spring '03