DS Assignment 1
DS Assignment 1
Short Questions:-
1. Define data structure.
2. Define algorithm.
3. List out areas in which data structures are applied.
4. List out structure of algorithm.
5. List out properties of algorithm.
6. List out the steps involved in the development of an algorithm.
7. Define Abstract Data Type.
8. List out the classification of data structure.
9. What is linear/primitive data structure?
10. What is non-linear/non-primitive data structure?
11. Gives the names of linear data structure.
12. Gives the names of non-linear data structure.
13. Which are the operations performed on data structure?
14. How to measure the performance of algorithm?
15. What is time complexity?
16. Define space complexity.
17. When empirical testing is used?
18. What is the use of theoretical testing?
19. What is average, best and worst case complexity?
20. Define O notation of time complexity.
21. List out the notation that used to express time complexity of algorithm.
Long Questions:-
1. Explain the classification of data structure.
2. Explain various operations performed on data structures.
3. Write a short note on abstract data type.
4. Explain the properties of algorithm.
5. Explain the steps for the development of algorithm.
6. Differentiate between linear and non-linear data structure.
7. What do you mean by algorithm? Give example.
8. Explain efficiency of algorithm.
9. Write a short note on asymptotic notations.
10. Distinguish between best, worst and average case complexities of an algorithm.
11. What do you mean by Time and Space complexity and how to represent these complexity?
12. Explain the concept of data type.
13. Find the complexity of following
code. for (int i = 0; i < n; i++) {
for(int j=I;j<n;j++)
cout<<j
}
14. Find the total frequency count of following
code.
for send=1 to n do
for receive =1 to send do
for ack=2 to receive do
message=send-(receive+ack) ack=ack-1
send=send+1
end
end
end
15. Find the total frequency count of following code.
i=2n
for j=1 to i
for k=3 to j
n=n+1
end
end
20. The time complexity of the algorithm in a best case would be expressed as
a. O(1)
b. O(n)
c. O(n2)
d. O(n+1)
Arrays
Short Questions:-
1. Define array.
2. List out application of Array.
3. Which operation is supported by an array ADT?
4. What will happen in a C++ program when you assign a value to an array element whose subscripts
exceed the size of array?
5. What is the index number of the last element of an array with 20 elements?
6. List out the operations performed on Array.
7. Give the number of elements in array a[1:5].
8. Give the number of elements in array a[1:5,1:4,1:3].
9. Give the number of elements in array A[3][2].
10. What is row major order?
11. What is column major order?
12. Write formula to calculate address of elements in one-dimensional array.
13. Write formula to calculate address of elements in two-dimensional array.
14. Write formula to calculate address of elements in three-dimensional array.
15. Define sparse matrix.
16. Define order-list matrix.
17. If the starting address of array a[-2,23] is 100 then what will be the address of 16th element?
18. If the starting address of array a[1:5,1:6] is 100 then what will be the address of a[3,4] element?
19. If the starting address of array a[1:5,1:6,1:4] is 100 then what will be the address of a[3,4,5] elem ent?
20. Write any one difference between row major and column major.
What are the disadvantages of array
Long Questions:-
1. What is an array? Which operations can be performed on Array? Explain with example.
2. How to calculate number of elements in one dimensional array? Explain with example.
3. How to calculate number of elements in two dimensional arrays? Explain with example.
4. How to calculate number of elements in three dimensional arrays? Explain with example.
5. Explain one-dimensional array. How one dimensional array can be represented in memory?
6. Explain two-dimensional array. How two dimensional arrays can be represented in memory?
7. Explain three-dimensional array. How three dimensional arrays can be represented in memory?
8. Explain any one method to calculate memory location for different position in two-dimensional array.
9. What are the applications of an array? Explain each with examples.
10. Explain sparse matrix. What are the benefits of the sparse matrix?
11. Explain order-list matrix. What are the benefits of the order-list matrix?
12. Write an algorithm for insert and delete operation in array.
13. Write an algorithm to implement sparse matrix.
14. Write an algorithm to search element in array.
15. Write program to insert element at position of user choice.
16. For the following array A, compute
Array: A
Column Index: 0:5
Base address: 100
Size of memory location: 4 bytes Row Index: 0:15
a. the dimension of A
b. the space occupied by A in the memory
c. the address of A[7,2]
17. Distinguish between the row major and column major ordering of an array.
18. Suppose A is linear array with n numeric values. Write procedure which finds the average of the values
in A.
19. Write a program to find second highest value from array elements.
20. Write a program to delete an element of array at position of user choice.
Multiple Choice Questions:-
1. Which of the following linear Data Structure?
a. Array b. Structure c. Tree d. Long
2. Consider following
code:
#include<iostream
.h> int main()
{ int a[10];
A[0]=10; A[1]=4; A[3]=15;
cout<<A[2+1];
}
What will be the output of following code?
a. NULL b. 10 c. 4 d. 15
3. Which are the correct array initialization
statements? a. int A[3]={1,2,3};
b. int A[3]={123};
c. int A[3]=”123”;
d. All
4. Which of the following statements are wrong statements?
a. Array is primitive data structure.
b. Every element of array must be same.
c. In array, Insert element is called push operation.
d. All
5. Which are the applications of array?
a. Sparse matrix
b. Ordered list
c. Both a & b
d. none
6. Which among the following pairs of operations is supported by an array ADT?
a. Store and Retrieve
b. Insert and Delete
c. Copy and Delete
d. Append and Copy
7. The number of elements in array Array[1:u] is
given by
a. (1 - u)
b. (u)
c. (u – 1 + 1)
d. (u – 1 - 1)
8. The number of elements in array Array[l1:u1, l2:u2] is
given by
a. (u1- l1 – 1)(u2 – l2 - 1)
b. (u1*u2)
c. (u1 – l1)(u2 – l2)
d. (u1- l1 + 1)(u2 – l2 + 1)
9. The number of elements in array Array[l1:u1, l2:u2, l3:u3] is
given by
a. (u1- l1 – 1)(u2 – l2 - 1) (u3 – l3 - 1)
b. (u1*u2*u3)
c. (u1 – l1)(u2 – l2)(u3-l3)
d. (u1- l1 + 1)(u2 – l2 + 1)(u3 – l3 + 1)
10. For the array A[1:u1, 1:u2] where α is the base address, A[i,1] has its address
given by
a. (i – 1)u2
b. α + (i – 1)u2
c. α + i * u2
d. α + (I – 1) * u1
Long Questions:-
1. Write short note on linked list.
2. Explain operation of singly linked list with algorithm.
3. Explain circular linked list.
4. What are the advantages of circular linked list over singly linked list?
5. Write pseudo code to add node at the end in circular linked list.
6. Explain doubly linked list with advantage and disadvantage of it.
7. Write a pseudo code to delete a node from doubly linked list.
8. Explain operation of doubly linked list with algorithm.
9. Write short note on multiply linked lists.
10. Explain application of linked list.
11. Write short note on polynomial manipulation.
12. Write short note on sparse matrix.
13. Explain operation of linked stack and linked queue.
14. Write algorithm for push/pop operation on a linked stack.
15. What are merit of linked stack and queues over their sequential counterparts?
16. How are push and pop operations implemented on a linked stack?
17. Write algorithm for insertion/deletion operation on a linked queue.
18. Write short note on Dynamic memory management.
19. Explain application of linked stack and linked queue.
20. Write a pseudo code for implementing stack using linked list.
21. Write a pseudo code for implementing queue using linked queue