3.3 Formula-based Representation 2)bool Find(int k, T&x) O(1) the k'th element in the list in X L=(a,b, c, d,e) find (1,x)=true, x=a find (2, x)=true, x=b find (4, x)=true, x=d find(0, x)=error find(9, x)=error
3.3 Formula-based Representation 2) bool Find(int k,T&x) O(1) the k’th element in the list in x L = (a,b,c,d,e) find(1,x) = true, x=a find(2,x) = true, x=b find(4,x) = true, x=d find(0,x) = error find(9,x) = error
3. 3 Formula-base Representation program 3.3 template <class T bool linearlistT>: Find (int k, t&x)const i if (k<l k>length) return false x-element/k-1 return true
3.3 Formula-base Representation program 3.3 template <class T> bool LinearList<T>:: Find(int k, T &x) const { if (k<1|| k>length) return false; x= element[k-1]; return true; }
3. 3 Formula-based representation 3)search(const T&x) O(length) return the index of x if found otherwise return o L=(a,b,d, b, e) search(d)=3 search(a search(3)=0
3.3 Formula-based Representation 3) search(const T&x) O(length) return the index of x if found,otherwise return 0 L = (a,b,d,b,e) search(d) = 3 search(a) = 1 search(z) = 0
3. 3 Formula-based Representation program 3.3 template <class T> int LinearList <T>: Search(const T& x)const i for( int i=0; 1< length; 1++) if(elementi==)return ++i return 0
3.3 Formula-based Representation program 3.3 template <class T> int LinearList <T>::Search(const T & x) const { for ( int i=0 ; i < length; i++) if (element[i]==x) return ++i; return 0; }
3.3 Formula-based Representation 4)delete (int k, T&x) delete the k th element and return it in x L=(a,b, c, d,e) delete (2, x) LF(a, c,d, e),x=b and index of c, d, e decrease by I delete( 0,x)=>error delete(20, x)=>error
3.3 Formula-based Representation 4) delete (int k,T&x) delete the k’th element and return it in x L = (a,b,c,d,e) delete(2,x) => L=(a,c,d,e),x=b, and index of c,d,e decrease by 1 delete(0,x) => error delete(20,x) => error