Beruflich Dokumente
Kultur Dokumente
Department of CA
HOMEWORK-1
Declaration:
I declare that this assignment is my individual work. I have not
copied from any other student’s work or from any other source except where
due acknowledgement is made explicitly in the text, nor has any part been
written for me by another person.
Student’s Sign:
Munish Sharma
Part-A
Q1:- Why structuring of data is required .Take one example problem and
discuss various problems that can be faced if wrong choice has been made
in selecting data structure for the problem.
Ans: - A data structure is a group of data elements grouped together under one
name. These data elements, known as members, can have different types and
different lengths.
Importance of Data Structuring
a. Data structure is important since it describes the types of operations we
can perform on the data and how efficiently they can be carried out.
b. It also describes how dynamic we can be in dealing with our data.
c. We determine which data structures to use to store our data only after we
have carefully analyzed the problem.
Example:-
The stack is a data structure that is used to perform the following operations: -
PUSH: For inserting new element in Data Structure.
POP: For deleting element from Data Structure.
TRAVERSE: For List out the elements of Data Structure.
If we want to place CD’s in a CD cover then we have to use the stack data
structure. The stack is used because we have to pick the last item placed first. If
we choose the wrong data structure then the following problems must be faced:
Ans: -
Abstract Data Type: - set of data values and associated operations that are
precisely specified independent of any particular implementation is known as
abstract data type.
Example:- an abstract stack data structure could be defined by two operations:
push, that inserts some data item into the structure, and pop, that deletes an
item from it. When analyzing the efficiency of algorithms that use stacks, one
may also specify that both operations take the same time no matter how many
items have been pushed into the stack, and that the stack uses a constant amount
of storage for each element.
Abstract data types are purely theoretical entities, used to simplify the
description of abstract algorithms, to classify and evaluate data structures, and
to formally describe the type systems of programming languages.
Ans: -
a.1):- Algorithm to delete an element from an array:-
Lets take NAME is an array with N elements and K is the position from where
we want to delete an element.
1. Start
2. Input array, item
3. Set item=NAME[K]
4. Repeat for I = K to N-1
a. NAME[I] = NAME[I+1]
[end of loop]
5. Set N = N-1
6. Exit
Q7:- For Q5, Write a module which finds the number of students who
have failed that is whose final grade is less than 40.
Ans: - Algorithm to the number of students who have failed whose grade
is less than 40
1. Start
2. Input n, array
3. Repeat steps ‘for’ I= 1 to n