Unit 1 DSU
Unit 1 DSU
com/data-structure-
using-c-for-msbte-3k-scheme/
S. N. Exam
MSBTE Board Asked Questions Marks
Year
S -24
Define Abstract Data Type (ADT)
1 W – 22 02
S - 22
Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by
a set of values and a set of operations. The definition of ADT only mentions what
operations are to be performed but not how these operations will be implemented. It
Ans.
does not specify how data will be organized in memory and what algorithms will be
used for implementing the operations. It is called “abstract” because it gives an
implementation-independent view.
S -24
W – 23
List the operation that can be performed on data structure.
2 S – 23 02
W – 19
S - 19
Data structure operations:
• Insertion: Adding a new data.
• Deletion: Removing a data.
Ans • Sorting: Arranging the data in some logical order.
• Searching: Finding the location of data.
• Traversal: Accessing each data exactly once.
• Merging: Combining the data.
1. Array
The array is a type of data structure that stores elements of the same type. These are
the most basic and fundamental data structures. Data stored in each position of an
array is given a positive value called the index of the element. The index helps in
identifying the location of the elements in an array.
If supposedly we have to store some data i.e. the price of ten cars, then we can create a
structure of an array and store all the integers together. This doesn’t need creating ten
separate integer variables. Therefore, the lines in a code are reduced and memory is
saved. The index value starts with 0 for the first element in the case of an array.
2. Stack
The data structure follows the rule of LIFO (Last In-First Out) where the data last added
element is removed first. Push operation is used for adding an element of data on a
stack and the pop operation is used for deleting the data from the stack. This can be
explained by the example of books stacked together. In order to access the last book, all
the books placed on top of the last book have to be safely removed.
3. Queue
This structure is almost similar to the stack as the data is stored sequentially. The
difference is that the queue data structure follows FIFO which is the rule of First In-
First Out where the first added element is to exit the queue first. Front and rear are the
two terms to be used in a queue.
W - 23
Define the terms: Linear data structure and non-linear data
4 S -23
structure 02
S – 22
Explain linear and non-linear data structures
W - 18
Linear Data Structure:
Data structure where data elements are arranged sequentially or linearly where each and
every element is attached to its previous and next adjacent is called a linear data
Ans - structure. In linear data structure, single level is involved. Therefore, we can traverse all
the elements in single run only. Linear data structures are easy to implement because
computer memory is arranged in a linear way. Its examples are array, stack, queue, linked
list, etc.
Non-linear Data Structure:
Data structures where data elements are not arranged sequentially or linearly are
called non-linear data structures. In a non-linear data structure, single level is not
involved. Therefore, we can’t traverse all the elements in single run only. Non-linear data
structures are not easy to implement in comparison to linear data structure. It utilizes
computer memory efficiently in comparison to a linear data structure. Its examples
are trees and graphs.
Differentiate between linear and non-linear data structure. (any S -22
5 04
four points) S - 19
Its examples are: array, stack, While its examples are: trees and
6
queue, linked list, etc. graphs.
6 Give classification of data structure. W -19 02
A data structure is a storage that is used to store and organize data. It
is a way of arranging data on a computer so that it can be accessed and
updated efficiently.
int main()
{
int arr[100] = { 0 };
int i, x, pos, n = 10;
// element to be inserted
x = 50;
// insert x at pos
arr[pos - 1] = x;
return 0;
}
Output
1 2 3 4 5 6 7 8 9 10
1 2 3 4 50 5 6 7 8 9 10
Ans
Algorithm is a stepwise set of instructions written to perform a specific task.
9 Write ‘c’ program for deletion of an element from an array. W - 18 04
#include <stdio.h>
int main()
{
int array[100], position, c, n;
Ans
if ( position >= n+1 )
printf("Deletion not possible.\n");
else
{
for ( c = position - 1 ; c < n - 1 ; c++ )
array[c] = array[c+1];
Visit
https://shikshamentor.com/