Presentation is loading. Please wait.

Presentation is loading. Please wait.

Presented By: Mahmoud Rafeek Alfarra

Similar presentations


Presentation on theme: "Presented By: Mahmoud Rafeek Alfarra"— Presentation transcript:

1 Presented By: Mahmoud Rafeek Alfarra
MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Data structure Using C# Information Technology , 3’rd Semester Lecture 4: Multiple-Subscripted Arrays & Advanced Practices about array data structure Presented By: Mahmoud Rafeek Alfarra

2 Outline Multiple-Subscripted Arrays data structure Emank X Mezank !!
Sorting Searching Inserting Deleting Advanced practices Emank X Mezank !!

3 Multiple-Subscripted Arrays
Such arrays require two or more subscripts to identify particular elements. Presented & Prepared by: Mahmoud R. Alfarra

4 Sorting 1 2 3 4 2 77 7 9 8 1 55 12 56 10 79 2 80 81 45 90 99 3 89 87 55 4 78 Sorting Multiple-Subscripted Arrays can be done on rows or columns By row: must fix row index and increment the column index. By column: must fix col. index and increment the row index. Presented & Prepared by: Mahmoud R. Alfarra

5 Sorting Multiple-Subscripted Arrays By row
for ( int pass = 1, pass < colLength, pass++ ) for ( int col = 0; col < colLength- 1; i++ ) if ( b[Row][col] > b[Row][ i + 1 ] ) Swap( b[Row][col], b[Row][ i + 1 ] ); HW 4.1 Write a method that performs sorting multiple-subscripted arrays by row and by col. Presented & Prepared by: Mahmoud R. Alfarra

6 Searching in Multiple-Subscripted Arrays
6 for ( int row = 0, row < rowLength-1, row++ ) for ( int col = 0; col < colLength- 1; col++ ) if ( b[row][col] == wanted ) flagr=row; Flagc= col; Break; HW 4.2 Write a method that performs searching multiple-subscripted arrays. Presented & Prepared by: Mahmoud R. Alfarra

7 Inserting element Into Multiple-Subscripted Arrays
To Insert a new elements in an unsorted array, we must Shift the elements to the particular side. With fix the row or column index Presented & Prepared by: Mahmoud R. Alfarra

8 Deleting element from Multiple-Subscripted Arrays
8 To delete an element from an array, we must overwrite the specific element. With fix the row or column index Presented & Prepared by: Mahmoud R. Alfarra

9 Advanced practices 9 Use a single-subscripted array to solve the following problem: Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Provide for the “worst case” (in which all 20 numbers are different). Use the smallest possible array to solve this problem. Presented & Prepared by: Mahmoud R. Alfarra

10 Advanced practices 10 Use a single-subscripted array to solve the following problem: Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, insert it into the particular cell as sorted as and if it is duplicated reject it. Presented & Prepared by: Mahmoud R. Alfarra

11 Advanced practices 11 Use a single-subscripted array to solve the following problem: insert 20 integer numbers. Then delete all the duplicated numbers Presented & Prepared by: Mahmoud R. Alfarra

12 يوم تكون الجبــال كالعهن المنفـوش
Emank X Mezank !! يقـول الله تعالى: يوم تكون الجبــال كالعهن المنفـوش

13 Next Lecture Recursion


Download ppt "Presented By: Mahmoud Rafeek Alfarra"

Similar presentations


Ads by Google