{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# DS02 - s 7 p s cfw m st Sequential List X(Polynomial ADT[t...

This preview shows pages 1–20. Sign up to view the full content.

✸✦➠ ♣✪ ( { [ ( Sequential List) Sequential List) / ( ( Polynomial ADT) Polynomial ADT) ( a ( Sparse Matrix) Sparse Matrix) ( a ( String) String)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
° x q ± ²° / ³ z [ ♥☛
X { [ / L ´ Q ♥☛ ➐✹✦ ²° ² / L ´ Q ♥☛ ➐✹✦ / ° ✱❺ / L ´ Q ♥☛ ➐✹✦ / L ´ Q ♥☛ ➐✹✦

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
° x #include <iostream.h> class szcl { int e ; public: szcl ( ) { e = 0; } szcl ( int value ) { e = value ; } int get_value ( ) { return e ; } }
main ( ) { szcl a 1[3] = { 3, 5, 7 } , * elem ; for ( int i =0, i <3, i ++ ) cout << a 1[ i ]. get_value ( ) << “\n” ; // } elem = & a 1 ; for ( int i =0, i <3, i ++ ) { cout << elem get_value ( ) << “\n” ; // } elem ++ ; } return 0 ; }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
²° ( ( Array Array ) ) e #include <iostream.h> #include <stdlib.h> template <class Type> class Array { Type *elements ; // / int ArraySize ; // e void getArray ( ) ; // / public: Array ( int Size=DefaultSize ) ; Array ( const Array <Type>& x ) ;
~Array ( ) { delete [ ] elements ;} Array <Type> & operator = ( const Array <Type> & A ) ; Type& operato [ ] ( int i ) ; Array <Type> operator Type * ( ) const { return elements ; } int Length ( ) const { return ArraySize ; } void ReSize ( int sz ) ; }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
template <class Type> void Array <Type>:: getArray ( ) { // b x elements = new Type [ ArraySize ] ; if ( elements == 0 ) cerr << "Memory Allocation Error" << endl; } /
template <class Type> void Array <Type>:: Array ( int sz ) { // e if ( sz <= 0 ) { cerr << "Invalid Array Size" << endl; return; } ArraySize = sz ; getArray ( ) ; }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
template <class Type> Array <Type>:: Array ( const Array <Type> & x ) { // / int n = ArraySize = x.ArraySize ; elements = new Type [ n ] ; if ( elements == 0 ) cerr << "Memory Allocation Error" << endl; Type *srcptr = x.elements ; Type *destptr = elements ; while ( n -- ) * destptr++ = * srcptr++ ; }
template <class Type> Type & Array <Type>::operator [ ] ( int i ) { // i if ( i < 0 || i > ArraySize - 1 ) cerr << "Index out of Range" << endl; return element [ i ] ; } / m Position [ i ] = Position [ i - 1] + Number [ i - 1]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
template <class Type> void Array <Type>:: Resize ( int sz ) { if ( sz >= 0 && sz != ArraySize ) { Type * newarray = new Type [ sz ] ; if ( newarray == 0 ) cerr << "Memory Allocation Error" << endl; int n = ( sz <= ArraySize ) ? sz : ArraySize ; Type *srcptr = elements ; Type *destptr = newarray ; while ( n-- ) * destptr++ = * srcptr++ ; delete [ ] elements ; elements = newarray ; ArraySize = sz ; } }
pYmº Hs [ * i i . . i i . . j j . . j j Hs[ * k k

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
tmºª* à ° µ tmº ²° + - = = 0 , ) ( 0 , α ) ( i l i LOC i i LOC 1 LOC ( i ) = LOC ( i - 1 ) + l = α + i*l
- - - - - - - - = ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ ] ][ [ 1 1 2 1 1 1 0 1 1 2 2 2 1 2 0 2 1 1 2 1 1 1 0 1 1 0 2 0 1 0 0 0 m n a n a n a n a m a a a a m a a a a m a a a a a Ð tm LOC LOC ( ( j j , , k k ) = ) = j * m + k j * m + k

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
n n e . ♥☛ m 1 , m 2 , m 3 , …, m n z i i 1 1 , i , i 2 2 , i , i 3 3 , …, i , …, i n n . . n n j n j k k j n n n n n n i m i i m i m m m i m m m i i i i LOC + = + + + + + = - = + = - 1 1 1 1 4 3 2 3 2 1 2 1 ) , , , (
²° ( ( Sequential List Sequential List ) ) n n z z 0 0 t . | . t e a a 1 1 , a a 2 2 , …, a a n n z

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Ðtm ²° ( SeqList SeqList ) e template <class Type> class SeqList { Type *data ; // / int MaxSize ; // b int last ; // / public: SeqList ( int MaxSize = defaultSize ) ; ~SeqList ( ) { delete [ ] data ; } int Length ( ) const { return last+ 1 ; } int Find ( Type & x ) const;
int IsIn ( Type & x ) ; int Insert ( Type & x, int i ) ; int Remove ( Type & x ) ; int Next ( Type & x ) ; int Prior ( Type & x ) ; int IsEmpty ( ) { return last == - 1 ; } int IsFull ( ) { return last == MaxSize - 1 ; } Type & Get ( int i ) { return i < 0 || i > last s NULL : data [ i ] ; } }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 82

DS02 - s 7 p s cfw m st Sequential List X(Polynomial ADT[t...

This preview shows document pages 1 - 20. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online