Wednesday, November 1, 2017

Ex.No 7 Merge Sort



Ex no:7                               MERGE SORT
Aim
            To write a python program to sort a list of elements using Merge sort
Algorithm
Step1:Start
Step2:Divide the arrays into left sub array & right sub array
Step3:Conquer by recursively sorting the two sub arrays
Step4:Combine the elements back in by merging the two sorted sub arrays
Step5:Call the results and print the arrays
Step6:Stop

https://drive.google.com/file/d/0ByMcz7t6A0gieUNIR2t5WDJtdTA/view?usp=sharing



Ex No: 8 First n Prime Numbers



Aim
            To write a python program to generate n prime numbers
Algorithm
Step1:Start
Step2:Get the upper limit and lower limit upto which the prime numbers must be displayed
Step3:Let it be lower and upper.
Step4:For each number ‘num’ from lower till upper
Step4.1:Check if ‘num’ is prime( not divisible by number other than one and itself)
Step4.2:If prime, display the number
Step4.3:Else move to next number
Step5:Stop

https://drive.google.com/file/d/0ByMcz7t6A0giSzlzU3prYTJkVms/view?usp=sharing



Ex.No 9 Multiply Matrices



Aim
            To write a python program to multiply two matrices
Algorithm
·

Step1:Start
Step2:Read Matrix A and Matrix B
Step2:To multiply two matrices, sufficient and necessary condition is
Step2.1:Number of coloumns in matrix A = number of rows  in matrix B
     Step3:Loop for each row in matrix A
    Step4:Loop for each columns in matrix B and initialize output matrix C to 0. This loop will    
              run for each rows of matrix A
    Step5:Loop for each columns in matrix A
   Step6:Multiply A[i,k] to B[k,j] and add this value to C[i,j]
   Step7:Print matrix C
   Step8:Stop