Data Structure and Algorithms
Data Structure and Algorithms
iv) Which data structure is a pile in which items are added at one end and removed from the other?
A. Stack B. Queue C. List D. None of the above
vi) The postfix form of the expression (A+ B)*(C*D- E)*F / G is?
A. AB + CD*E - FG /** B. AB + CD* E - **FG /
C. AB + CD* E - *FG */ D. AB + CDE * - * F *G /
vii) A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9.The
insertion of next element takes place at the array index.
A. 7 B. 0 C. 9 D. 10
viii) The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is?
A. 600 B. 350 C. 650 D. 588
ix) What will be the maximum value of top, if there is a size of stack MAXSIZE is 5
A. 5 B. 4 C. 6 D. None of the above
x) Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?
a) Insertion Sort b) Quick Sort c) Heap Sort d) Merge Sort
xi) In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is?
a) log 2 n b) n⁄2 c) log 2 n – 1 d) n
xii) Inserting a new node after a given node in a doubly linked list requires
a) 2 pointers exchange b) no pointer exchange c) 4 pointers exchange d) 1 pointer exchange
2. What is Linked list? What are the advantages and disadvantages of linked list over an array? [2+3]
Ans: A linked list is a linear data structure, in which the elements are not stored at [5]
contiguous memory locations. The elements in a linked list are linked using pointers.
[2+3]
3. Write a C function to insert a node with specified value at the end of a singly linked list.
[4+1]
4. Define the ADT for Stack. Write the algorithm for Push and Pop operation in Stack.
5. Write a C function for selection sort and also calculate the time complexity for selection
sort.
[5]
[2+3]
[1+4]
[5]
6. Convert the following infix expression to postfix notation by showing the operator stack and output string [5]
after
reading each input token:
A * (B + D) / E - F * (G + H / K) ^ X
7. What is queue? What is the advantage of circular queue over queue?
8. What is circular queue? Write Q-insert algorithm for the circular queue.
[5]
9. Insert the following numbers into Max heap and Min heap:
[5]
39, 89 , 12 , 67 , 56 , 43 , 54 , 98 , 6 , 60 , 95 , 26
10. Sort the following array with explanation using quick sort method:
24 , 56 ,47 ,35 ,10 ,90 ,82 ,31, 67, 8, 76
Analyse its time complexity.
11. Convert the following infix expression to postfix expression by showing the operator stack and output string after
reading each input token:
A * B + C * ( D – E) – F / G
12. Write the algorithm and explain Binary Search with a suitable example.
Note: a stack is a particular kind of abstract data type or collection in which the principal (or only) operations on the
collection are the addition of an entity to the collection, known as push and removal of an entity, known as pop. The
relation between the push and pop operations is such that the stack is a Last-In-First-Out (LIFO) data structure. In a
LIFO data structure, the last element added to the structure must be the first one to be removed. This is equivalent to the
requirement that, considered as a linear data structure, or more abstractly a sequential collection, the push and pop
operations occur only at one end of the structure, referred to as the top of the stack.