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
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 ifcomparison operations and the number of times the loop will execute.
5 10 25 30 37 46 55 60 65 70
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.
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 s example
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,
Q6. Implement Horner’ rule for evaluating the following polynomial expression at x =5. Calculate the total number of times additions and
multiplication operations will ocuur in this example p(x) = 3𝑥
5- 4𝑥 4 + 5×3 – 6x + 9
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 will execute in this example.
Reviews
There are no reviews yet.