Skip to main content
Open navigation menu
Close suggestions
Search
Search
en
Change Language, English
Upload
Sign in
Sign in
0 ratings
0% found this document useful (0 votes)
6 views
24 pages
Array
The best book ever
Uploaded by
nextbolt4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Array For Later
Share
0%
0% found this document useful, Mark this document as useful
0%
0% found this document not useful, Mark this document as not useful
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
6 views
24 pages
Array
The best book ever
Uploaded by
nextbolt4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Go to previous items
Download
Save
Save Array For Later
Share
0%
0% found this document useful, Mark this document as useful
0%
0% found this document not useful, Mark this document as not useful
Print
Embed
Report
Go to next items
Download
Arrays Array is the collection of similar data type. Array is our data structure that has been used (as well as abused) more than any other Arrays are simple yet reliable and are used in more situations than you can count. They are like old friends. You accept and live with their qualities — good as well as bad. Data structures are classified into two categories — linear and non-linear. A data structure is said to be linear if its elements form a sequence. Elements in a non-linear data structure do not form a sequence. There are two ways of representing linear data structures in memory. One way is the Static Memory Allocation and second way is the Dynamic Memory Allocation. Static Memory Allocation is maintained with the help of Array and Dynamic Memory Allocation is maintained with the help of Pointers and Malloc function. We can represent this as graphically 34/1] 5] 6] 9/12}6]7] 8] 9 0123456789 An array of 10 elements (34 —}+ (56 ++ (0 = [98 [NULL A linked list contains 4 integers. Arrays are useful when the number of elements to be stored is fixed. They are easy to traverse, search and sort. On the other hand, linked lists are useful when the number of data items in the collection are likely to vary. Linked lists are difficult to maintain as compared to ‘an array. 2.1 TYPES OF ARRAY Array is the collection of similar data type and having a common name. Array is classified into two categories : ARRAY Single Dimentional Array Multi Dimentional Array 2D, 8D, 4D... We will only discussed Single Dimentional Array and 2D Array. Single Dimentional Array : The general syntex for defining the single dimentional array is as follows [sizk (17)EEL oe: Structure Using ‘C’ For example : if we define int a (5); The meaning of this line is that a is an array which holds 5 elements, the first element is stored at the position of a [0] and the 5" element is stored at the position of a [4]. Two Dimensional Array ; We can define the 2D array as follows : [size of row] [size of column]; For example : If we define int a[3](3]; The meaning of this line is that a is an array which holds 3 rows and 3 columns. The memory is allocated i.e., 18 bytes because here 9 elements exists. ‘The representation of 2D Array is as follows : a(0}(0] @[0)0) af0J[2) af1j(0] @fjM) a@f[1I[2] a(2)[0] al2itl] a[2){2) Three Dimensional Array (No, of 2D Array] [size of row] [size of column); If we define int a (21 (5) [3]; The meaning of this line is that we define two 2D array each of which is having 5 rows and 3 columns i.e., total elements are — 30 elements i.e., 60 bytes memory is allocated for this purpose 2.2 ARRAY OPERATIONS There are several operations that can be performed on an array. The following are the operations OPERATION DESCRIPTION ‘Traversal Processing each element in the array Search Finding the location of an element with a given value Insertion ‘Adding a new clement to an array Deletion Removing an element from an array Merging Combining two arrays into a single array Reversing Reversing the elements at an array * : t.—o c ‘Arrays B19] 2.3 HOW TO REPRESENT THE LINEAR ARRAY IN MEMORY We know that the memory of the microprocessor is simply a sequence of addressed locations as shown in the following figure. 1197 1198 1199 1200 1201 1202 1203 Let a be a linear array with n elements. As arrays are stored in consecutive memory location, the system need not keep track of the address of every element of a, but needs to keep track of the address of first element only. The address of the first element is also known as the base address of the array denoted by base(a). Using the base address, the computer computes the address of the K" element with the help of the following formula. Computer Memory Map 1210 loc (afk]) = base(a) + w * K Where w is the number of bytes/storage location for one element of the array. Example : Consider that array a is declared as array of integers with size 10, and its first element is stored at memory address 1197, i.e., its base address is 1197. loc (afk]) = base(a) + w *K; loc (af3)) = 1197+2*3 w = 2 bytes for integers loc (a[3]) = 1197 + 6 = 1203. Ans. Problem : Develop a Program whose Output is as follows : 1 Insert the element in an array 2 Delete an element from an array 3. Reverse an array 4° Display the array 5 Search the element in the array 6 Exit ENTER your choice Solution: — #include #include| | 20 | “Data Structure Using eee #inelude define MAX 20; void insert (int *, int, int); void del (int *, int); void reverse ( int *); void display (int *); void search (int *, int); void main() int a{max]; elrser(); int ch=1, pos, n; while (ch != 6) printf(“\n 1 -> Insert the Element in an array”); printf(“\n 2 — Delete an Element from an array”); printf(“\n 3 > Reverse An Array”); printf(“\n 4 -+ Display the Array”); printf(“\n 5 — Search the Element in the Array”); printf(“\n 6 + Exit”); printf(“\n Enter your choice”); scanf(“%d”,&ch); switch (ch) case 1: printf(“\nEnter the position where u want to insert the Record} scanf(“%d”,&pos); printf(“\nEnter the No, which you want to insert”); scanf(“%d”,&n); insert(a, pos, n); break; case 2: printf(“\nEnter the position where you want to delete the No.” scanf(“%d”,&pos); del(a, pos); break; case 3: reverse (a); break; case 4: display (a); break; case 5+ printf("\n Enter the Element which you want to search”); seanf(“%d" &n); search(a,n); break; case 6+ exit(}); default : printf(“\n Incorrect choice please Enter 1 > 6”); iil} getch(); void del (int *a, int pos) Bae tebe { int i; for(i=pos; i < max; i++) afi-l, (i); afi-1] = 0; 1 void reverse (int *a) inti, t; forti=0; i < MAX / 2; i++) if (ali) printf“\n\n The Element %d is present at %d"" position”, n, i+1); return;- EL Data Structure Using ‘C’ Void display (int *a) int i; printf (“\n”); for(i=0; i < MAX; i++) printf(“\t%d”, ali); ) 2.4 MERGING OF TWO ARRAYS Merging of arrays involves two steps : Sorting the array that are to be merged Adding the sorted elements of both the arrays to a new arrays in a sorted order. Problem : Program for merging of two arrays of different size. 1. Create first array 2. Create second array 3. Sort first array 4. Sort second array 5. Merge both the arrays 6. Display the merge array 7. Exit Solution: — #include #include #include #include #define MAX1 5; #tdefine MAX2 7; int *a; int *create(int); Void sort (int *, int); Void display (int *, int); int *merge (int *, int *); Void main() int *a, *b, *e, ch; elrser(Q); ch = 1; while (ch !=7) printf(“\n 1 -> Create first Array”); printf(“\n 2 -> Create Second Array”);Arrays EW printf(“\n 3 — Sort first Array”); » printf("\n 4 > Sort second Array”); printf(‘\n 5 > Merge both the Arrays”); printf(“\n 6 > Display the Merge Array”); printf(‘\n 7 > Exit”); printf(“\n Enter your choice”); scanfl“%od”, &ch); switch (ch) case 1: a= create (MAXI); break; ease 2: b = create (MAX2); break; case 3: sort(a, MAXI); printft“\n First Array\n”); display(a, MAX); break; case 4: sort(b, MAX2); printf(“\n Second Array”); display(b, MAX2); break; case 5: printf{“\n After merging”); ¢ = merge(a, b); display (c, MAX1 + MAX2); break; case 6: display(c, MAX] + MAX2); break; case 7: exit(); ; default : printf(“\n Invalid choice Either press 1, 2, 3, 4, 5, 6 or Ts | // End of switch ; | End of while getch(); | End of Main. int “create (int size) int *a, i; a = (int *) malloc (size * size of (int)); for(i=0; i < size; i++) printf(“\n Enter the Element No. %d”, i + 1); scanf(“%d”, &ali)); return a;24 Data Structure Using ‘C’ ) Void sort(int *a, int size) ( inti, t.j5 forli=0; i < size; i++) for(j=i+l; j < size; j++) if (ali) > alj]) } Void display (int *a, int size) int i; for(i=0; i < size; i++) printft“\nd%d?, afi); } int *merge (int *a, int *b) int *c; inti, j,k, size; size = MAX1 + MAX2; c= (int *) malloc (size + size of (int)); for(k=0, j=0, i=0; i <= size; i++) if (alk < bli) fil = afk); K++; if (K >= MAX1) for(i++; j < MAX2; j++, i++) efi] = bij}; elseArrays B25 | cli] = bil; itt; if >= MAX2) forli++; K < MAXI; K++, i++) fi] = alk); )/* End of if | /* End of else } /* End of for loop return c; ) 2.5 TWO DIMENSIONAL ARRAYS A 2D array is a collection of elements placed in m row, and n columns i.., if we want to store the elements in the form of MATRIX then definitely we have to use the concept of 2D Array. We can define the 2D Array as follows : [size of Row] [size of Column]; If we define int a[3) (3); The representation of this Array is as follows : @(0}(0] af[0])] a[0}(2) a(1}[0] afi] aft)(2) a(2)[0} a(2){1] a[2){2) The total number of elements in this array is 9. So 18 bytes memeory is allocated for this array. Row MAJOR and Column MAJOR Arrangement : Rows and columns of a MATRIX, are only a matter of imagination. When a MATRIX gets stored in memory, all elements of it are stored linearly since computer’s memory can only be viewed as consecutive units of memory : This leads to two possible arrangements : (i) Row major arrangement (ii) Column major arrangement The following figure shows these two arrangements : int a[3] [4] = { (12,11-9,23}, {14,7,11,21), (6,78,15,34},El Data Structure Using 'C’ | (@) Row major arrangement + Othrow —|+- ithrow —+|+- 2nd row —> 12} 1 |-9 {23 [14] 7 [a1 fr2a] 6 [78 | 15 | 34 502, 504, 506, 508, (ii) Column major arrangement | Oth column —>|¢- 1th column —>|¢ 2th column —>|¢- 3th column —>} 2] 14) 6 1 | 7 | 78 | -9 | 11 | 15 | 28 | 121] 34 502, 504, Since the array elements are stored in adjacent memory location, we can access any element of the array, once we know the BASE ADDRESS (starting address) of the ARRAY and number of rows and columns present in the array. 2.5.1 Address Calculation in 2D Array In general for an ARRAY a{m][n] the address of element aliJ[j] would be => Base address + number of bytes (i * n+ j) For example : If we want to calculate the address of 121 number in the above example. 121 is stored at a{1][3] i=Ljs3 and the order of array is a[3][4]. Son = 4 Base address — 502 so, => 502+1*4 +3 = 502 number of bytes +7 = 509 Ans. => 510 Ans. Column MAJOR arrangements : In general for an array a{m](n] the address of element ali][j] would be => (Base Address + j *m + 1) ¢ NOTE THAT - C language permits only a Row MAJOR arrangement, whereas Pascal uses # column MAJOR Arrangement. => 121 is present at al1J[3] iz1jj=3 = 502 + number of bites (3 * 3 + 1) m=3,n=4 502 + 2(10) = 502 + 20 = 522. Common MATRIX Operations : * MATRIX Addition « MATRIX Multiplication « Transpose of a MATRIX « Print the Diagonal elements « To calculate the determinant of a MATRIXAvays El 2.6 APPLICATIONS OF ARRAY , Arrays and Polynomials : Polynomials like can be maintained using an ARRAY. Arithmetic operations like addition and multiplication of polynomials are common and often we need to write a program involving these operations. Problem : Write a program to add two polynomials using Arrays : Solution: — #include #include #define MAX 10; struct poly i struct term ( int coeff, int exp; int number of terms } timax]; Ps Void initpoly(struct poly"); ‘Void polyappend(struct poly *, int, int); struct poly polyadd(struct poly, struct poly); Void display (struct poly); Void main() struct poly Py, Pa» P3i initpoly(&p,); initpoly(&p,); initpoly(&p,); polyappend(&p,, 1, 7); polyappend(&p,, 2, 6); polyappend(&p,, 3, 5); polyappend(&p,, 4, 4); polyappend(&p,, 5, 2); polyappend(&p,, 1, 4); polyappend(&p,, 1, 3); polyappend(&p», 1, 2); polyappend(&p,, 1, 1); polyappend(&p,, 2, 0); Py = polyadd(p,, pp);Bl Data Structure Using ‘C" printf(“\nfirst polynomial\n”); display(p,); printf(“\nsecond polynomial \n”); display(p,); printf(“\nResultant Polynomial\n”); display(p,); getch(); I Void initpoly (struct poly *p) inti; P > number of terms = 0 for(i=0; i < MAX ; i++) P > tli]. coeff = 0; P > tli. exp = 0; } Void polyappend (struct poly *p, int c, int e) ( p > tlp ~ no. of terms). coeff = ¢; p> tlp > no. of terms]. exp = (p > no of terms); ) Void display (struct poly P) int c; for(i=0; i p, no. of terms) © = py. no. of terms; else © = pp. no. of terms; forli=0, j icze; py. no. of terms ++) if (p,.[Link] = = 0 && [Link] == 0) bres if (p,.tli].exp >= p,.tfi].exp) if (p, [Link] { Ps-t{p,, no. of term].coeff = p,.[Link] + pe-tli]. coeff; Pz.t{ps. no. of terms].exp = p,-tlil-exp; [Link]) itt; Jets } else { [Link]. no. of terms).coeff = p;.[Link]; Pst[ps. no. of terms).exp = p,-[Link]; it } } else { [Link]. no. of terms].coeff = [Link] [Link]. no. of [Link] = [Link]; itt } ) return Psi ) Multiplication at Polynomials : Now we will discuss the multiplication of two polynomials : (ax? + bx +0) * (ax* + bx" + cx +d) > ax’ + abx! + acx® + adx* + abx! + b?x® + box? + bdx + acx® + 0% + odData Structure Using ‘C" 26 F 2 a’? + 2abx! + x*(2ac +6) + x4ab + be) + xbd + 02) +ed Ans. Now we will discuss the concept of string. Before we discuss the concept of string, we will discuss the concept of sparse matrices : 2.7 SPARSE MATRIX Am x n matrix A is said to be sparse, if many of its elements are ZERO. A MATRIX, that is not sparse is called dense matrix. The diagonal and Tridiagonal matrices fit into the category of sparse matrices. Now we will consider a sparse matrix which is as follows coood conoo cooreo cocoon a coo° coouacg A (5 x 6) Sparse Matrix How to represent the sparse MATRIX in memory ‘The following are the schemes by which we can represent the sparse matrix in memory : (a) ARRAY Representation : IN ARRAY REPRESENTATION An array of triplets of type
Is used to store NON ZERO Elements. ie. first field of the triplet is used to record row position, second to record column position and third one to record the NON ZERO Element of the sparse matrix. In addition, we need to record the size of the matrix. How the memory is calculated. The ARRAY REPRESENTATION will use (2 * (n+1) * size of (int) + n * size of (T)] Bytes of memory, where n is the number of NON ZERO elements and 7’ is the data type of the elements Required MEMORY declarations for the ARRAY Representation will be : #define MAX 50; struct triplet int row, column; float element; hi struct triplet sparsemat{max]; . « THE ARRAY representation very rarely used for practical purposes. The major limitation of array representation of a sparse MATRIX is that we need to know the number of NON ZERO terms in each of the sparse matrices, we plan to use when the array is created. (b) Linked Representation ; If we want to represent the sparse matrix with the help of linked list then it in as folloA (5 x 6) sparse matrices : coood conco coors cocoon ncoco°o cooas The description of this is as follows : ¢ It contains one starter node that has four fields. A. n row (number of rows), n col (number of columns), num (number of NON ZERO Elements), and start (a pointer to the first row containing at least one NON ZERO Element). B. A linked list of rows containing at least one NON ZERO term in the ascending order of their row values. Each node of this lists has three fields : Row (Row number for corresponding row list). NEXT (A pointer to next node in the row list). © First (a pointer to the first column in a row having NON ZERO item). C. A linked list of columns containing NON ZERO terms, in the ascending order of their column values. Each node of this lists has three fields * Col (Column number for corresponding row list). « Term (A NON ZERO value in column col). e Link (A Pointer to the next column having NON ZERO element). The linked list Representation of the above sparse matrix is as follows : 5} 6] 5 |! | | |Y EL Data Structure Using ‘C” | 2.8 STRING A string is the collection of characters and it is terminated with the help of ‘\0" character, « How to represent a string : A string can be represented using an array or a linked list. 4 STRING of characters having length n can be implemented by a one dimentional array of, elements where the i'” element of the array stores the i” character of the string. « The advantage of such a representation is that the array elements can be directly accessed and this could speed up several operations on strings. char 8 [10] S="Man" S(0]="M mena S(='a" 401 402 403 aaa S [3] = '\0' [Null Character} .1 The LINKED Representation is as Follows M| >|‘ | >] 'N' | Null] For operations on string we use the predefined header file 2.8.2 Functions on String 1. Strlen : Strlen is a predefined function which is used to calculate the length of any string. Problem : Write a program to input a string and calculate the length of that string. Solution : #include #include #include
Void main() char (80); int n; elrser(); printft"\n Enter the string”); scanft“%os",); n = strlen(s); printf(“\nThe length of the given string is %d", n); getch(); ! 2, Streat() : Streat() is a predefined function in
which is used to concatenate two strings. The general syntex is Void streat(source string, destination string);Arrays TRY With the help of this function, the source and the destination strings are concatenated and the final result is stored in source string. Problme : Write a program to input two string and the concatenate them and then print the concatenate string. Solution : #includecstdio.h> #include
#include Void main() char s[80], s1[40]; elrser(); printf(“\n Enter first string”); scanf(“%s”,s); printf(“\n Enter second string”); scanf(“%s”,s1); streat(s, s1); printf(“\n The concatening string is %s”, s); getch(); } 3. Strepy() : strepy() is a predefined function in which is used to copy the source string into destination string. Problem : Write a program to input one string and then copy it to the destination string and then print the destination string. Solution : #include #include #include Void main() char s(80], s1(80); clrser(); printf(“\n Enter the source string”); scanft“%s”, 8); strepy(sl,s); printf(“\n The copied string is %s”, s1); getch0); ) 4, Strrev() : strrev() is a predefined function which is used to reverse the string. Problem : Write a program to input a string and then reverse the string and print the reverse string. Solution : #include
#include— LS 7 EL Data Structure Using ‘C” | #includecstring.h> Void main() char s{80}, s1[80]; printf(“\n Enter the string”); scanfl“%s”, s); sl = strrev(s); printf(“\n The reverse string is %s”, s1); getch(); ! 5. Stremp() : stremp() is a predefined function in , which is used to compare source string to destination string. Problem : Write a program to input two string and then compare both the string. Solution : #include #include #include ‘Void main() char s(80], s1(80); printf{“\n Enter the first string”); scanf(“%s”, 8); printf(“\n Enter the second string”); scanf(“%s”, s1); if (stremp(s, s1) == 0) printf(“\n both the strings are equal”); else printf“\n both the strings are not equal”); getch(); } Now we have to do these operations with the help of USER Defined functions: #include #include #include int xstrlen(char *); void strepy(char *, char *); void streat(char *, char *); int xstremp(char *, char *); void main() char s1[ ] = “SRMS College ”;Arrays B35] char s2[ ]=“SRMS Medical college ”; char 83[80]; int 1; elrser(); printf{*\n First string is %s”, 81); 1 = strlen (s1); printf(“\n The length of the string s1 %d”, 1); printf(“\n The second string is %s”, 82); xstrepy (83, 81); printf(“\n string 83 after copied is %s", $3); xstreat (s3, 82); printf(“\n string s3 after concatanation is %s", s3); if (xstremp(s1,s2) == 0) printf(“\n The string s1 and s2 are similar”); else printf(“\n The string s1 and s2 are not similar”); getch(); int xstrlen(char *s) int l= while (*8) 145 sts ) return (0; ) void xstrepy (char *t, char *s) while (*s) tots; tH s+; = '\05 1 void xstreat ( char *t, char *s) while (*t) tet while (*s)EG oe Structure Using ‘© tit = tee; t= \0% } int xstremp (char *s, char *t) ( while (*s == *t) (if (Cs) return 0; st; tH return (*s, *t); } Pointers and strings : We can define the string as follows : char str[ ] = “Hello”; char *p = “Hello”; void main() char s{ ] = “Hello”; char s1[10]; char *s = “Good Morning”; /* Exror */ works; ) How to define two dimention array of string : char s{20] [20]; or char *qs{20]; If you want to store 20 names then you can write it as follows : forti=0; i < 10; i++): { printf(“\n Enter the string”); scanf(“%s", s[i]); ) 2.9 PATTERN MATCHING Pattern matching means we want to search sub-string into a string. 2.9.1 Brute Force Algorithm ‘This is the simplest algorithm for the searching of a sub-string in a string. In this algorithm the string ¢ in which the pattern string is to be searched i# scanned character by character.Arrays a7] ¢ Beginning from the 0" character of the string s1 each character, is compared with each and every character of the pattern string P. This process continues till either there is no mismatch or the pattern string P is not exhausted. If'a match is found then the index of characters of s from which the comparison bijon is returned as the position where the pattern string P is found. Program for Brute Force Algo : #include #include #includecstring.h> int xstrsearch(char *, char*); void main() char s(80}, s1[80]; int pos; elrser(); printf(“\n Enter the first string”); gets(s); printf(“\n Enter the second string”); gets (s1); pos = xstrsearch (s1, 82); printf“\n The pattern string is found at position %d”, pos); getch(); ) int xstrsearch(char *s1, char *s2) { int i, j,k; int 11 = strlen(s1); int 12 = strlen(s2); forliz0; i <= 11-12; i++) ( j k=1; while ((s1[k] == { Li) && Gj < 12) ket; Jes if Gj == 12) return 1; elseno | EL Data Structure Using ‘C’ | 2.10 ARRAY AS PARAMETER We can pass the array in the function with the help of Pointers. For example : If we define int max (int *) ‘The meaning of this line is that max is a function which accepts an integer type of Pointer i.e., an integer type of array and according to that array it returns an integer type of value Problem : Write a program to input 10 numbers and calculate the maximum number, with the help of function. Solution : #include #include #include int max (int *) // Function Prototype void main(); int a[10}, i, g, m; clescr(); for (i =0,i<10,i+j) printft“/n enter the No.”); scanft“%d”, and ali); m = max (a); // calling of the function prinft“/n the max. no. is %d”, m); getch(); ‘int max (int «p) int m, i; m = pl0); for (i = 1,1 < 0;i ++) if (m < pli]) m = plil; return (m); 2.11 ORDERED LIST If the list i.e., Array is ordered in either ascending or descending order than that is known as Ordered Lists.Arrays El Problem : Write a program to input 10 numbers and then sort the number in ascending , order with the help of function. Solution : ' #includecstdio.h> #include void sort(); void main() elrser(); sort(); geteh(; ) void sort); int a[10], i, j, t; for (i= 0; <10;i+t) { printf(“/n enter the No.”); scanfi“%d”, & ali); } for (i = 0:1 < 10; i++) for G =i + 1;j < 10, j++) if (alil > afj]) t=alil; afi) = aff); alj] =t Print(“/n The elements in the Sorted order”); for (i= 0; i< 10;i ++) prinft(“/n %d”, alil); getch();a Data Structure Using ‘C" J Ss JUMMARY Array is a linear Data Structure which holds the similar data. = Array plays a very important role if we want to store more than one element of the same type. m= The syntex for defining the 1D Array is (size]; m= If we define int a{3]; the meaning of this line is that @ is an array which holds 3 elements and the elements are stored from a{0] to a[2]. m The syntex for defining the 2D Array is [size of row] (size of column]; If we define this int a (3][3), the meaning of this line is that @ is an array which holds 9 elements and the elements are stored from a{0J{0] to a{2]{2]. The syntex for defining the 3D Array is [ (No. of two dimensional Array] [size of row] (size of column] PROBLEMS 1. What do you mean by Array ? Classify it ? 2. Write a program to input 10 number and calculate the max. number between 10 numbers ? 3. Write a program to input 10 numbers and calculate the min. number between 10 numbers ? 4, Write a program to input 10 numbers and sort that numbers in ascending order ? 5. Give an example to show the usefullness of an array ? 6. Define static memory allocation and dynamic memory allocation ? 7. Write an algo / function to merge two arrays stored in ascending order ? 8. A 2D Array X{6I{4] is stored a row wise in the memory. The first element of the array is stored at location 80. Find the memory location of X{3I(2] if the each elements of array requires (4) memory locations ? 9. Give an array X(6)[6] whose base address is 100. Calculate the location X{2][5] if each element occupies 4 bytes and array is stored row wise ? 10, Define 3D Array with example ? 11. Write a program to input two 3 x 3 matrices and print the addition of matrix ? 12. Write a program to input two 3 x 3 matrices and print the multiplication of matrix ? 13. Write a program to input a 3 x 3 matrix and caleulate the transpose of that matrix ? 14. Write a program to multiplication of two polynomials with the help of array ? 15. Define Markov Algo for Pattern Matching ? 16. Write a program to input a string and check whether the given string is palindrome or not? 17. Write a program to generate the Fibonacci series using arrays ? 18. Differentiate between static and dynamic memory allocation ? 19. Calculate the address of X[4, 3] in a 2D Array X [1..5, 1..4] stored in row major order in the main memory. Assume the base address to be 1000 and that each element requires (4) words of storage ? 20. Write a program to input 10 number and print the sum and average of numbers ?
You might also like
Understanding Arrays in Programming
PDF
No ratings yet
Understanding Arrays in Programming
23 pages
Unit-1 Array, One Dimensional Array
PDF
No ratings yet
Unit-1 Array, One Dimensional Array
9 pages
Accessing 2D Array Elements
PDF
No ratings yet
Accessing 2D Array Elements
46 pages
Linear Data Structures: Arrays Explained
PDF
No ratings yet
Linear Data Structures: Arrays Explained
118 pages
Array Insertion and Deletion Algorithms
PDF
No ratings yet
Array Insertion and Deletion Algorithms
23 pages
Understanding Arrays in C Programming
PDF
No ratings yet
Understanding Arrays in C Programming
14 pages
Sequential Data Structures Overview
PDF
No ratings yet
Sequential Data Structures Overview
21 pages
C Data Structures: Arrays & Functions
PDF
No ratings yet
C Data Structures: Arrays & Functions
33 pages
Binary Search and 2D Arrays in C
PDF
No ratings yet
Binary Search and 2D Arrays in C
14 pages
Array Operations and Algorithms Overview
PDF
No ratings yet
Array Operations and Algorithms Overview
53 pages
Data Structures: Arrays & Linked Lists
PDF
No ratings yet
Data Structures: Arrays & Linked Lists
158 pages
Linear Data Structures: Arrays Explained
PDF
No ratings yet
Linear Data Structures: Arrays Explained
53 pages
Arrays & Linked List Module 2 Notes-1
PDF
No ratings yet
Arrays & Linked List Module 2 Notes-1
37 pages
C Arrays: Initialization, Access, and Tasks
PDF
No ratings yet
C Arrays: Initialization, Access, and Tasks
33 pages
Lec 8 - Array
PDF
No ratings yet
Lec 8 - Array
33 pages
Column-wise Array Traversal in C
PDF
No ratings yet
Column-wise Array Traversal in C
26 pages
Various Structures
PDF
No ratings yet
Various Structures
37 pages
Data Structures: Arrays & Linked Lists
PDF
No ratings yet
Data Structures: Arrays & Linked Lists
159 pages
Arrays and Structures in C Programming
PDF
No ratings yet
Arrays and Structures in C Programming
56 pages
Understanding Arrays in Data Structures
PDF
No ratings yet
Understanding Arrays in Data Structures
18 pages
Understanding Sequential Data Structures
PDF
No ratings yet
Understanding Sequential Data Structures
79 pages
Understanding Array Indexing Basics
PDF
No ratings yet
Understanding Array Indexing Basics
7 pages
C Programming: Array of Pointers
PDF
No ratings yet
C Programming: Array of Pointers
20 pages
Data Structures: Arrays & Linked Lists
PDF
No ratings yet
Data Structures: Arrays & Linked Lists
108 pages
Arrays
PDF
No ratings yet
Arrays
27 pages
Week5 Lecture Notes
PDF
No ratings yet
Week5 Lecture Notes
25 pages
Introduction to Data Structures Overview
PDF
No ratings yet
Introduction to Data Structures Overview
88 pages
Part 5 Arrays MSA
PDF
No ratings yet
Part 5 Arrays MSA
36 pages
Arrays
PDF
No ratings yet
Arrays
8 pages
Understanding Arrays: Types and Operations
PDF
No ratings yet
Understanding Arrays: Types and Operations
8 pages
Arrays
PDF
No ratings yet
Arrays
8 pages
Arrays and Pointers in C Programming
PDF
No ratings yet
Arrays and Pointers in C Programming
44 pages
C Programming: Understanding Arrays
PDF
No ratings yet
C Programming: Understanding Arrays
18 pages
Understanding Arrays in C Programming
PDF
No ratings yet
Understanding Arrays in C Programming
14 pages
Understanding Arrays in C Programming
PDF
No ratings yet
Understanding Arrays in C Programming
42 pages
Understanding Data Structures in C
PDF
No ratings yet
Understanding Data Structures in C
55 pages
Understanding Arrays in C Programming
PDF
No ratings yet
Understanding Arrays in C Programming
16 pages
Memory Usage of String "abcd" in C
PDF
No ratings yet
Memory Usage of String "abcd" in C
47 pages
Understanding Arrays in Data Structures
PDF
No ratings yet
Understanding Arrays in Data Structures
20 pages
Understanding Arrays in Data Structures
PDF
No ratings yet
Understanding Arrays in Data Structures
29 pages
Understanding Arrays in DSA Basics
PDF
No ratings yet
Understanding Arrays in DSA Basics
12 pages
Linear Data Structures Overview
PDF
No ratings yet
Linear Data Structures Overview
206 pages
Understanding Arrays in C Programming
PDF
No ratings yet
Understanding Arrays in C Programming
49 pages
Data Structures Overview and Types
PDF
No ratings yet
Data Structures Overview and Types
86 pages
C Arrays: Structure and Operations Guide
PDF
No ratings yet
C Arrays: Structure and Operations Guide
15 pages
WINSEMFRE2025-26 CSE2014 ETH AP2025265000837 2026-02-09 Reference-Material-I
PDF
No ratings yet
WINSEMFRE2025-26 CSE2014 ETH AP2025265000837 2026-02-09 Reference-Material-I
15 pages
Understanding Data Structures: Types & Operations
PDF
No ratings yet
Understanding Data Structures: Types & Operations
76 pages
Array (1) KSKD
PDF
No ratings yet
Array (1) KSKD
31 pages
List ADT Operations and Implementations
PDF
No ratings yet
List ADT Operations and Implementations
41 pages
Introduction to Data Structures Overview
PDF
No ratings yet
Introduction to Data Structures Overview
48 pages
Understanding Arrays in C Programming
PDF
No ratings yet
Understanding Arrays in C Programming
6 pages
Understanding Arrays in C Programming
PDF
No ratings yet
Understanding Arrays in C Programming
6 pages
Data Structures: Arrays Explained
PDF
No ratings yet
Data Structures: Arrays Explained
12 pages
Understanding Arrays in C Programming
PDF
No ratings yet
Understanding Arrays in C Programming
12 pages
Data Structures in C Programming
PDF
No ratings yet
Data Structures in C Programming
12 pages
Arrays in C: Basics and Operations
PDF
No ratings yet
Arrays in C: Basics and Operations
6 pages
Introduction to Data Structures
PDF
100% (1)
Introduction to Data Structures
54 pages