[go: up one dir, main page]

0% found this document useful (0 votes)
962 views7 pages

Unit 1 DSU

Uploaded by

devalepavan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
962 views7 pages

Unit 1 DSU

Uploaded by

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

https://shikshamentor.

com/data-structure-
using-c-for-msbte-3k-scheme/

313301 – Data Structure (Sem III)


As per MSBTE’s K Scheme
CO / CM / IF

Unit I Introduction on to Data Structure Marks - 04

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.

3 Explain linear data structure with any three types. S -24 04

Ans Linear data structures :


If elements forms a sequence, then it is called as a linear data structure.
e.g. – arrays, stacks, queues, linked list
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
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.

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

Sr. No. Linear data structure Non-linear data structure

In a linear data structure, data


elements are arranged in a In a non-linear data structure, data
1 linear order where each and elements are attached in
every element is attached to hierarchically manner.
its previous and next adjacent.
Ans Whereas in non-linear data
In linear data structure, single
2 structure, multiple levels are
level is involved.
involved.
Its implementation is easy in While its implementation is complex
3 comparison to non-linear data in comparison to linear data
structure. structure.
In linear data structure, data While in non-linear data structure,
4 elements can be traversed in a data elements can’t be traversed in a
single run only. single run only.
In a linear data structure, While in a non-linear data structure,
5 memory is not utilized in an memory is utilized in an efficient
efficient way. way.

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.

Write C program for performing following operations on array :


7 S -19 04
insertion, display.

// C Program to Insert an element at a specific position in an Array


Ans
#include <stdio.h>

int main()
{
int arr[100] = { 0 };
int i, x, pos, n = 10;

// initial array of size 10


for (i = 0; i < 10; i++)
arr[i] = i + 1;
// print the original array
for (i = 0; i < n; i++)
printf("%d ", arr[i]);
printf("\n");

// element to be inserted
x = 50;

// position at which element


// is to be inserted
pos = 5;

// increase the size by 1


n++;

// shift elements forward


for (i = n - 1; i >= pos; i--)
arr[i] = arr[i - 1];

// insert x at pos
arr[pos - 1] = x;

// print the updated array


for (i = 0; i < n; i++)
printf("%d ", arr[i]);
printf("\n");

return 0;
}

Output
1 2 3 4 5 6 7 8 9 10
1 2 3 4 50 5 6 7 8 9 10

8 Define the term algorithm. W - 18 02

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;

printf("Enter number of elements in array\n");


scanf("%d", &n);

printf("Enter %d elements\n", n);

for ( c = 0 ; c < n ; c++ )


scanf("%d", &array[c]);

printf("Enter the location where you wish to delete element\n");


scanf("%d", &position);

Ans
if ( position >= n+1 )
printf("Deletion not possible.\n");

else
{
for ( c = position - 1 ; c < n - 1 ; c++ )
array[c] = array[c+1];

printf("Resultant array is\n");

for( c = 0 ; c < n - 1 ; c++ )


printf("%d\n", array[c]);
}
return 0;
}
Thank You
https://shikshamentor.com/data-structure-using-c-for-
msbte-3k-scheme/

Visit
https://shikshamentor.com/

You might also like