0% found this document useful (0 votes)
5 views

Data Structure N Algorithm

The document describes an algorithm to multiply two matrices. It takes two matrices as input, checks that the number of columns in the first matrix equals the number of rows in the second matrix. It then uses a nested loop to iterate through each element, multiplying the elements and adding them to the output matrix C.

Uploaded by

vedhh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Data Structure N Algorithm

The document describes an algorithm to multiply two matrices. It takes two matrices as input, checks that the number of columns in the first matrix equals the number of rows in the second matrix. It then uses a nested loop to iterate through each element, multiplying the elements and adding them to the output matrix C.

Uploaded by

vedhh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Input two matrixes. Output Output matrix C. Complexity O(n^3) Matrix-Multiply(A, B) 1 if columns [A] ?

rows [B] 2 then error "incompatible dimensions" 3 else 4 for i =1 to rows [A] 5 for j = 1 to columns [B] 6 C[i, j] =0 7 for k = 1 to columns [A] 8 C[i, j]=C[i, j]+A[i, k]*B[k, j] 9 return C

Algorithm Description To multiply two matrixes sufficient and necessary condition is "number of column s in matrix A = number of rows in matrix B". Loop for each row in matrix A. Loop for each columns in matrix B and initialize output matrix C to 0. This loop will run for each rows of matrix A. Loop for each columns in matrix A. Multiply A[i,k] to B[k,j] and add this value to C[i,j] Return output matrix C.

for i=1 to n for j=1 to n c[i][j]=0 for k=1 to n c[i][j] = c[i][j]+a[i][k]*b[i][k]

******************************************************************************** ********** Experiments should include but not limited to : Implementation of array operations: Stacks and Queues: adding, deleting elements Circular Queue: Adding & deleting elements

Merging Problem : Evaluation of expressions Operations on Multiple stacks & queues : Implementation of linked lists: inserting, deleting, inverting a linked list. Implementation of stacks & queues using linked lists: Polynomial addition, Polynomial multiplication Sparse Matrices : Multiplication, addition. Recursive and Nonrecursive traversal of Trees Threaded binary tree traversal. AVL tree implementation Application of Trees. Application of sorting and searching algorithms Hash tables implementation: searching, inserting and deleting, searching & sorti ng techniques.

You might also like