Important Questions of Java Programming
Unit-I
Q1) Define Algorithm. Write down the characteristics of algorithm.
Q2) Write the characteristics of Algorithm. Solve the following recurrence relation
using Master theorem:
T (n) = 9T (n/3) +n
Q3) Do prepare quick, merge, and heap sort.
Unit-II
Q1) Define red-black tree and its properties. Create a red-black tree with keys 41,
38, 31, 12, 19, 8. Explain diUerent types of rotations in red-black tree.
Q2) Explain B-tree. Write down its properties. Insert the following information :
F, S, Q, K, C, L, H, T, V, W, M, R, N, P, A, B, X, Y, D, Z, E, G, I
Into an empty B-tree with degree t=3.
Unit-III
Q1) Define Divide and Conquer approach.
Q2) Explain Greedy Approach with an example.
Q3) Explain single source shortest path problem. Apply Dijkastra’s algorithm to the
given undirected graph. Consider the source vertex is S=0.
Q4) Write down the Bellman Ford algorithm. Find the shortest path using Bellman-
Ford algorithm from s to t of the following figure:
By: Mr. Amrit Jaiswal 1
Q5) Explain Fractional Knapsack problem. Solve for the given set of items and
knapsack weight capacity = 15, find the optimal solution for the problem using greedy
approach :
Objects 1 2 3 4 5 6 7
Profit(P) 5 10 15 7 8 9 4
Weights(W) 1 3 5 4 1 3 2
Unit-IV
Q1) Write down the Floyd- Warshall ’s Algorithm. Apply all pair sources shortest
path problem and find out the minimum distance between each pair of given
vertices as mentioned in the directed graph shown as below :
Q2) Discuss Backtracking approach. Explain N-Queen problem and describe an
algorithm to solve n-queen problem.
Q3) Explain 0/1 Knapsack problem. Solve the following instance of the 0/1
knapsack problem using dynamic programming:
By: Mr. Amrit Jaiswal 2
Weight 1 2 3 2
Profit 10 15 25 12
The capacity of Knapsack m=5.
Q4) Define resource allocation problem.
Q5) Discuss the sum of subset problem. Apply this problem to given data set A and
show complete state space representation including all backtracking steps with
clear representation:
A= {3, 4, 12, 5, 2}, Sum= 9
Unit-V
Q1) What are the String matching problem? Consider working module q=11, how
many spurious hits does the Rabin-Karp matcher counter in the tent
T=3141592653589793 when looking for the pattern P=26.
Q2) Explain :
a) P problems b) NP problems
c) NP Complete problem d) NP Hard problem
By: Mr. Amrit Jaiswal 3