Dear students, get fully solved assignments by professionals
Do send your query at :
or call us at :08263069601
BCSL-045 ASSIGNMENT SOLUTION (2020-21)
Q1. Write and test a program to sort the following array of 10 integer numbers using Selection Sort . Calculate the numbers of times the outer loop, inner loop, if statement and and swap operation will execute in this example. Show all the intermediate steps.
15 | 45 | 60 | 25 | 35 | 8 | 40 | 5 | 10 | 27 |
Answer : –
Q2. Implement Binary Search algorithm to search for a number 70 in the following sorted array of 10 integer numbers. Calculate the total no of mid operations, if statement and else if comparison operations and the number of times the loop will execute.
5 | 10 | 25 | 30 | 37 | 46 | 55 | 60 | 65 | 70 |
Answer : –
Q3. Write a program to traverse a graph using DFS. Apply this algorithm to the following graph and write the sequence of vertices to be travelled. Also calculate the number of times the for loop and if condition will execute in this example.
Answer : – Graph not present in the assignment’s question paper. Therefore, solution is not possible.
Q4. Write a program to find the maximum of the following list of integer numbers : 15, 20, 5, 4, 3, 17, 35.
Calculate (i) the number of times the loop will execute and (ii) the number of times the if statement will run in this example.
Answer : –
#include<stdio.h> int main() { |
Q5. Implement Prim’s algorithm to find a minimum cost spanning tree of the following graph and print the result . Represent the graph through adjacency matrix,
Answer : –
Adjacency Matrix
Q6. Implement Horner’s rule for evaluating the following polynomial expression at x = 5. Calculate the total number of times addition and multiplication operations will ocuur in this example
p(x) = 3x5 – 4x4 + 5x3 -6x + 9
Answer : –
Q7. Write a program to count the number of times an integer number 12 has occurred in the following array of 10 integer numbers.
15, 20, 35, 12, 11, 8 ,12, 7, 12, 16
Calculate the number of times (i) loop statement and (ii) increment operations will execute in this example.
Answer : –
Dear students, get fully solved assignments by professionals
Do send your query at :
or call us at :08263069601