100% found this document useful (1 vote)
54 views5 pages

DS2022

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
54 views5 pages

DS2022

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Group A (Choose the correct alternative):

1. i) Which data structure is defined as a collection of similar data elements?


o Answer: a) Arrays
2. ii) Which function places an element on the stack?
o Answer: b) Push
3. iii) How do you initialize an array in C?
o Answer: b) int arr(3) = {1,2,3};
4. iv) Reverse Polish notation is the other name of?
o Answer: c) Postfix expression
5. v) A normal queue, if implemented using an array of size MAX_SIZE, gets full
when?
o Answer: a) Rear = MAX_SIZE - 1
6. *vi) What is the value of the postfix expression 6 3 2 4 + – ?
o Answer: d) -18
7. vii) What is the maximum number of swaps that can be performed in the
Selection Sort algorithm for 'n' number of elements?
o Answer: c) nnn
8. viii) If TOP=MAX-1, then the stack is?
o Answer: a) full
9. ix) Which of the following traversal outputs the data in sorted order in a BST?
o Answer: b) Inorder
10. x) An array consists of n elements. We want to create a heap using the elements.
The time complexity of building a heap will be in order of?
o Answer: b) O(n⋅log⁡n)O(n \cdot \log n)O(n⋅logn)
11. xi) Pushing an element into a stack already having five elements and a stack size
of 5, then the stack becomes?
o Answer: a) Overflow
12. xii) In the given connected graph G, what is the value of rad(G) and diam(G)?
o Answer: d) 2,3

Group A (Fill in the blanks):

1. i) A tree is _______ data structure.


o Answer: hierarchical
2. ii) The clrscr() function is kept in _______ header file.
o Answer: conio.h
3. iii) A tree node that has no children is called a _______ node.
o Answer: leaf
4. iv) Breaking a program into several functions is called _______.
o Answer: modular programming
5. v) The #define pi 3.14 is a _______ statement.
o Answer: preprocessor
6. vi) Adding an element in a queue is called _______ operation.
o Answer: enqueue
7. vii) The pointer without a data type is _______.
o Answer: void pointer
8. viii) A loop inside another loop is called _______.
o Answer: nested loop
9. ix) _______ stores the non-homogeneous data elements.
o Answer: structure

1. x) Process of removing an element from stack is called _______.


o Answer: Pop
2. xi) Circular Queue is also known as _______.
o Answer: Ring Buffer
3. xii) In the stack, if a user tries to remove an element from the empty stack, then
it is called _______.
o Answer: Underflow
4. xiii) The complexity to delete a node from the end of the linked list is _______.
o Answer: O(n)
5. xiv) _______ is the logical container of a data item.
o Answer: Data Structure
6. xv) The height of a binary tree is the maximum number of edges in any root to
leaf path. The maximum number of nodes in a binary tree of height h is _______.
o Answer: 2h+1−12^{h+1} - 12h+1−1
7. xvi) The malloc function returns _______ when the allocation fails.
o Answer: NULL

Group A (Answer the following questions):

1. i) What is FIFO?
o Answer: FIFO stands for "First In, First Out," a principle in which the first
element added is the first one to be removed. Used in queue structures.
2. ii) What is a leaf node?
o Answer: A leaf node is a node in a tree data structure that has no children.
3. iii) What is BST?
o Answer: BST stands for "Binary Search Tree," a tree data structure in which
each node has at most two children, and each node’s left subtree contains
values less than the node, while the right subtree contains values greater than
the node.
4. iv) Memory space for an array is allocated in compile-time or in run time?
o Answer: Compile-time (for static arrays)
5. v) Define De-Queue.
o Answer: A De-Queue (Double-ended Queue) is a data structure where
elements can be added or removed from both ends.
6. vi) What is Backtracking?
o Answer: Backtracking is a problem-solving technique that involves searching
through all possible solutions to find a valid solution, often by undoing
choices when a dead end is reached.
7. vii) Explain about dummy header.
o Answer: A dummy header is a node at the beginning of a data structure (such
as a linked list) that does not hold meaningful data but simplifies code by
acting as a placeholder.
8. viii) Write the method of Bubble sort.
o Answer: Bubble Sort repeatedly steps through the list, compares adjacent
elements, and swaps them if they are in the wrong order. This process repeats
until the list is sorted.
9. ix) What is the difference between a PUSH and a POP?
o Answer: PUSH adds an element to the top of a stack, whereas POP removes
an element from the top of a stack.
10. x) What is a degree of a node of a tree?
o Answer: The degree of a node in a tree is the number of children it has.
11. xi) Write the full form of MST.
o Answer: Minimum Spanning Tree
12. xii) What are the disadvantages of linked list?
o Answer: Disadvantages of a linked list include higher memory usage due to
pointers, slower access times compared to arrays, and potential complexity in
code when performing certain operations.
13. xiii) Define queue full condition.
o Answer: In a circular queue, the full condition is when (rear + 1) %
MAX_SIZE == front.
14. xiv) What is rear of a queue?
o Answer: The rear of a queue is the position where the most recent element
was added.

Group B (Answer the questions - Any six):

1. i) What is complete binary tree?


o Answer: A complete binary tree is a binary tree in which all levels are fully
filled except possibly the last, and the last level has all nodes as left as
possible.
2. ii) Write prefix form of the expression: (A+B*C)-(D/E)
o Answer: - + A * B C / D E
3. iii) What do you understand by radix sort?
o Answer: Radix sort is a non-comparative integer sorting algorithm that sorts
data by processing each digit or place value, starting from the least significant
digit to the most significant.
4. iv) Write two applications of queue.
o Answer: Applications of a queue include:
 Task scheduling in operating systems.
 Managing print jobs in a printer spooler.
5. v) 10, 5, 1, 7, 40, 50 is given preorder traversal of a binary search tree. Find out
the post-order traversal of the same tree.
o Answer: 1, 7, 5, 50, 40, 10
6. vi) What is doubly linked list?
o Answer: A doubly linked list is a linked list in which each node has a
reference to both the previous and next nodes, allowing traversal in both
directions.
7. vii) What is hashing?
o Answer: Hashing is a technique used to uniquely identify a specific data
record from a data structure by using a hash function to convert a key into a
unique index.
8. viii) What is quick sort?
o Answer: Quick Sort is a sorting algorithm that uses the divide-and-conquer
approach, choosing a pivot element to partition the array into two sub-arrays
and then recursively sorting them.
9. ix) What is sparse matrix?
o Answer: A sparse matrix is a matrix in which most of the elements are zero,
and efficient storage techniques are used to save space.
10. x) Give infix notation with an example.
o Answer: Infix notation is where operators are written between the operands.
Example: A + B * C
11. xi) What do you understand by stack underflow and stack overflow?
o Answer: Stack underflow occurs when attempting to pop from an empty
stack, while stack overflow happens when trying to push onto a full stack.
12. xii) What is collision resolution technique?
o Answer: Collision resolution techniques are methods used in hashing to
handle cases where multiple keys map to the same index. Examples include
chaining and open addressing.

Group C (Answer the question - Any one):

1. a) What is Data Structure? Write down the differences between linear and
nonlinear Data Structures?
o Answer: Data Structure is a way of organizing data in a format that enables
efficient access and modification. Linear Data Structures (e.g., arrays, linked
lists) store data in a sequential manner, while Nonlinear Data Structures
(e.g., trees, graphs) store data in a hierarchical or interconnected manner,
allowing multiple paths to access data.

OR

2. b) What is ADT? Explain with a suitable example.


o Answer: An Abstract Data Type (ADT) is a data type defined by its behavior
rather than its implementation. Example: Stack ADT supports operations like
push and pop without specifying how they’re implemented.

OR

3. c) Define a graph. Explain different representation of graph.


o Answer: A graph is a collection of nodes (vertices) and edges connecting
pairs of nodes. Representations include:
 Adjacency Matrix: A 2D array where each cell (i, j) indicates if an
edge exists between nodes i and j.
 Adjacency List: Each node has a list of nodes it's connected to, which
is memory efficient for sparse graphs.

Group C (Answer the question - Any one):

1. a) Explain Priority queue and its types. What will be the value of A(1,5) by using
Ackermann function?
o Answer: A Priority Queue is a data structure where each element has a
priority assigned to it, and elements with higher priority are dequeued before
those with lower priority. Types include:
 Min-Heap: Smallest element has highest priority.
 Max-Heap: Largest element has highest priority.

Ackermann function: A(1,5)=13A(1,5) = 13A(1,5)=13

OR

2. b) Write an algorithm to insert a node in an AVL tree.


o Answer:

Step 1: Perform standard BST insertion for the new node.


Step 2: Update the height of the ancestor nodes.
Step 3: Check the balance factor of each ancestor node.
Step 4: If any node becomes unbalanced, perform appropriate
rotation:
- Left Left Case
- Right Right Case
- Left Right Case
- Right Left Case
Step 5: Return the root of the modified subtree.

You might also like