1 / 10

Data Structures

Data Structures. Ali Abdul Karem Habib Kufa University / mathematics & Science Of Computer. Data Structures. DATA STRUCTURE. SIMPLE. COMPOUND. LINEAR. NON-LINEAR. ARRAYS. LINKED LIST. TREES. STACKS. GRAPHS. QUEUES. DATA STRUCTURE.

gretel
Télécharger la présentation

Data Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Data Structures Ali Abdul KaremHabib Kufa University / mathematics & Science Of Computer

  2. Data Structures DATA STRUCTURE SIMPLE COMPOUND LINEAR NON-LINEAR ARRAYS LINKED LIST TREES STACKS GRAPHS QUEUES

  3. DATA STRUCTURE The logical and mathematical model of particular organization of data is called DATA STRUCTURE. Data Structures are containers for data. The simplest of them are called “atomic” because they hold only a single value and cannot be subdivided into lower-level components. Other “compound” data structures may hold multiple pieces of data, and are constructed from atomic types.

  4. Simple Data Structure Arrays • The group of linked similar type of elements by one common name then it is called as array . • Its is the simplest type of data structure. • Array it is a container that holds a fixed length . • It is start at 0 0 1 2 3 4 5 6 7 8 9 20 Array length is 10

  5. ARRAY .. Cont • Array Definition: int x[100]; char text[80]; • Array Initialization: int digits[5]={1,2,3,4,5}; char color[3]={‘R’, ‘E’, ‘D’}; • Multidimensional Arrays: int values[3][4]= { {1,2,3,4}, {5,6,7,8}, {9,10,11,12} } String: In C Strings are defined as arrays of characters.There are special string handling library routines like strcmp(s1,s2), strcpy(s1,s2),strlen(s)

  6. Representation of array in memory • One Dimensional array • Location(X[I])=Base Address+(I-1) • E.g :- • Find X[4] , Base Address=500 Location(X[I])=Base Address+(I-1) Location(X[4])=500 +(4 -1) =503

  7. Represent Two Dimensional Array • 1- Row – wise Method Location ( A[ i , j] )= base address +N *( i-1 )+( j-1 ) E.G :- A[5,7], M=5, N=7, Base Address=900 Find A[ 4 , 6 ] Location(A [I,J])=Base Address +N*(I-1)+(J-1) Location(A [4,6])=Base Address+7 *(4 -1)+(6 -1) =900+21+5 =926

  8. 2- Column – wise method Location(A [I,J])=Base Address + M *(J -1)+(I -1) E.g. A[5,7], M=5, N=7, Base Address=900 Find A[ 4 , 6 ] Location(A [4,6])=900 +5 *(6 -1)+(4 -1) =900+25+3 =928

  9. #include<iostream.h> • intsort[5]; • intitem,i,j; • void main() • { • cout<<"enter elements of array "<<endl; • for(i=0;i<5;i++) • { • cin>>sort[i]; • } • item=0; • for(i=0;i<5;i++) • for(j=i+1;j<5;j++) • { • if(sort[j]<sort[i]) • item=sort[i]; • sort[i]=sort[j]; • sort[j]=item; • } • //output sorting array • cout<<"output sorrting array"<<endl; • for(i=0;i<5;i++) • cout<<sort[i]<<endl; • getch(); • }

  10. Assignment -2- • 1- find the large number and small number in array ? • 2- find an element in array where K any element ?

More Related