+44(0) 1234 567 890 info@domainname.com

Wednesday, 19 June 2013

Examples of Two Dimensional Array in Data Structure Lab 3

03:37

Share it Please
  • Example No:1
Translate the matrix multiplication algorithm into a program which finds the product C of an nxm matrix A and pxn matrix B. Test the program using


                                 A=  4       -3        5
                                       6        1       -2
                                       23     -7       -3

                                 B= 5       -1         6        2
                                      0        3        -2         1 


Algorithm

Let A be an nxm matrix, and let B be a pxn matrix array. This algorithm stores the product of A and B in a mxp matrix array C

Repeat Steps 2 to 4 for I=1to M

Repeat Steps 3 to 4 for J=1to N

Set C[I,J]=0 Initialize C[I,J]

Repeat for K=1 to P    

C[I,J]=C[I,J]+A[I,K]*B[K,J]

[END of inner loop]

[END of Step 2 loop]
[END of Step 1 loop]

Source Code:

 

  • Example No:02
Suppose A and B are n-elements vector array in memory and X an Y
are scalars. Write a program to find.
a) XA + YB
b) A . B
Test the program using A= (16, -6,7), B=(4,2,-3), X= 2, Y= -5

Source Code:


  •  Example No:03
Translate the linear search algorithm into a program which either find
the location LOC where ITEM appears in ARRAY or return LOC=0.?

Source Code:

      
  •    Example No:04


Translate binary search and insertion algorithm into a program which finds either the location LOC where ITEM appears in ARRAY or the location  LOC  where ITEM should be inserted into ARRAY. (For object 3, 4, and 5 take an array of 10 elements given below)? 
Source Code: 

  •  Example No:05
Write a program which uses Binary Search to search the elements 52,and 33 and print it.
Source Code:
 
  •  Example No:06
Write a program which uses Binary Search to search the elements 45,and 78 and delete it.
NUMBERS=[11,22,33,36,45,52,57,60,64,78]
 
 Source Code:


0 comments:

Post a Comment