BCA DS Assignment
BCA DS Assignment
Note: Write Answer of all questions in a Note book and submit it after summer vacation up to 10 th July
2024. If you have any doubts then discuss after summer break.
1. Define data structure. List the various linear and non-linear data structures and explain them in brief.
2. What does abstract data type means? Briefly explain linear and nonlinear data structures.
3. Discuss the basic operations performed with linear structure.
4. Explain the dynamic memory allocation functions in C++.
5. Differentiate the following terms:
a. Liner and Non-Linear Data Structures
b. Primitive and Non-Primitive Data Structures
6. Discuss best case, average case and worst case time analysis with example.
7. Define Algorithm. Write an algorithm to multiply two matrices. Also Perform Time Analysis for the
same.
8. Write short note on performance analysis and performance measurement of an algorithm.
9. Write algorithm to sum values in vector V and find out the execution time required.
10. Define Time complexity and Space complexity. Calculate time complexity for given expression. for
(k=0; k<n; k++)
{
rows[k]=0;for(j=0;j<n;j++)
{
rows[k]=rows[k]+matrix[k][j];
total=total+ matrix[k][j];
}
}
11. Given a two dimensional array A1[8][14] with base address 100 and size of each element is 4 bytes,
find address of the element A1[4][12].
12. Given a two dimensional array Z1[10][18] with base address 100 and size of each element is 2 bytes,
find address of the element Z1[4][12].
13. What is stack? Explain basic primitive operation of stack with example.
14. Write a C++ program to implement a stack with all necessary over flow and under flow checks using
array.
15. Write a C++ program to reverse a string of characters using stack.
16. Write an algorithm to check if an expression has balanced parenthesis using stack and implement it in
C++.
17. What is recursion? Write a C++ program for GCD using recursion.
18. Write a recursive algorithm to find factorial.
19. Enlist difference between recursive and iterative algorithms. Write any one recursive function
showing the stack contents while function call and return.
20. Write a C++ user define function for tower of Hanoi for N disk and three towers. Write stack
representation for N= 4.
21. Explain Difference between FIFO and LIFO.
22. What is the advantage of Polish expression over infix notation? Writean algorithm to convert an infix
expression into reverse Polish expression
23. Convert the given infix expression to postfix and prefix expression.
i. A+( (B–C) * (D–E)+F) / G) % (H– J)
ii. (A+B) * (C –D) % E* F
iii. (A+B) *(C ^(D– E) +F)– G
iv. A+B * C
v. A+B * C ^D– E
vi. A+[(B +C)+ (D+E) * F]/ G
Page 1 of 4
vii. (A+B)*C/D+E^F /G
viii. (A+B) * C / D
ix. ((A+B–C/ D) / E)
x. A/ (B–C /D^E) +F
xi. A– B / (C * D^E)
24. Evaluate the following expressions.
i. 5+4*2
ii. 4+2*5 ^2+9/3 –1* 8
iii. 4025+ 205*3 +*
iv. 9+5*7–6^2+9/3
v. 8*2-1+7*5
25. Evaluate the following Postfix expression assume A=1, B=2, C=3
i. AB+ C–B A+C-+
ii. ABC +*CB A-+ *
26. Name two divide and conquer algorithms for sorting.
27. Applyquicksortalgorithmtosortthefollowingdata.Justifythesteps.42, 29, 74, 11, 65, 58
28. Write a C++ program for insertion sort and discuss its efficiency.
29. Write an algorithm and C++ Function to implement Selection Sort Method.
30. Write an algorithm and C++ program to implement Bubble Sort Method.
31. Write an algorithm and C++ program to implement Quick Sort Method.
32. Write an algorithm and C++ program to implement Merge Sort Method.
33. Using Quick sort give tracing for following set of numbers 42, 11, 23, 58, 65, 72, 36, 99.
34. Write down precondition and algorithm of binary search method.
35. Differentiate between arrays and linked list.
36. Write an algorithm to implement ascending priority queue using singular linear linked list which has
insert() function such that queue remains ordered list. Also implement remove() function.
37. Write an algorithm to reverse a given single link list.
38. Write a program to insert and delete an element after a given node in a singly linked list. Write a
function in any programming language to insert an element in an ordered list.
39. Write a C++ program to add two polynomials represented using doubly linear linked list. Also write
necessary functions to represent polynomial using doubly linear link list.
40. Write a program in C++ language to concatenate two doubly linked lists.
41. Briefly explain advantages of doubly link list over singly link list. Write function delete(p, &x)
which delete the node pointed by p in doubly link list.
42. State the advantages of circular and doubly linked lists over a singly linked list.
43. Write an algorithm to perform each of the following operations on Circular singly linked list using
header node
i. Add node at the end
ii. Add node at beginning
44. Discuss following with reference to trees.
Tree Node Parent node Child node
Link. Root Leaf Level
Height Degree Binary tree Complete binary tree
Strictly binary tree Threaded binary tree Forest Sibling
Binary search tree Height balanced tree Spanning tree Full binary tree
Minimum spanning Almost complete binary tree Ancestor node
tree
45. What are the applications of trees?
46. Construct a tree for the given in-order and post-order traversals
In-order D G B A H E I C F
Post-order G D B H I E F C A
47. Give the Pre-order and In-order traversal of the tree given in following figure.
Page 2 of 4
48. Construct binary search tree for the following data
a. 10, 3, 15, 22, 6, 45, 65, 23,78, 34, 5.
b. 50, 60, 25, 40, 30, 70, 35, 10, 55, 65, 5
c. 40, 65, 25, 55, 10, 70, 30, 50, 15, 80, 75
d. 45, 56, 39, 12, 34, 78, 54, 67, 10, 32, 89, 810
e. 60, 15, 4, 30, 70, 65, 10, 95, 25, 34
Find its in-order, pre-order and post-order travesal
49. Define height of the binary tree. Define height balanced tree with its advantages.
Construct a height balanced binary tree(AVLtree) for the following data:
42, 06, 54, 62, 88, 50, 22, 32, 12, 33.
50. Define height balanced tree. Construct a height balanced binary tree(AVL tree) for the
following data
32, 16, 44, 52, 78, 40, 12, 22, 02, 23.
51. Why is Threaded binary tree required? Draw a right-in threaded binary tree for the
following tree.
52. Write an algorithm to perform traversal of Binary search tree.
53. Obtain an AVL tree by inserting one integer at a time in the following sequence.
150, 155, 160, 115, 110, 140, 120, 145, 130, 147, 170, 180. Show all the steps
54. First insert 10 and then insert 24. After these insertions, delete 37 and then delete 22 from the
following binary search tree. Draw the tree after each operation.
55. Insert 1, 29, 32 and 13 in the following Height balanced tree. For each insertion, draw
the balanced tree using AVL rotation.
Page 3 of 4
b. Consider a B-tree in which the maximum number of keys in a node is 5.What is the
minimum number of keys in any non-root node?
57. Write the characteristics of AVL tree.
58. What is the meaning of height balanced tree? How rebalancing is done in height balanced tree.
59. Define Graph and discuss its one application in real life.
60. Describe the following terms in reference to Graph:
Directed Graph, Undirected Graph, Weighted Graph, Neighbors, Degree, Path, Reachability,
Connected Graph, Cycles, Adjacency Matrix, Adjacency List
61. Consider the graph shown in below figure. Find depth-first and breadth first traversals of this graph
starting at A
62. Define spanning tree and minimum spanning tree. Find the minimum spanning tree of the graph
shown in figure.
63. Explain the breadth first search and depth first search tree traversal on the following graph.
Page 4 of 4