Vous êtes sur la page 1sur 6

Lovely Professional University

Assignment -1
Data Structure

Submitted To –
Mr.Kiran Kumar Kaki

Submitted by-

Name:shreyats

Section:D1803

Semester :4rth
Part A
Ans 1.Structuring of data is required because data structure is a logical or
mathematical model of a particular arrangement or organization of data.It is a
particular way of storing data in computer’s memory so that it can be used easily
and efficiently. For example, B-trees are particularly well-suited for implementation
of databases, while compiler implementations usually use hash tables to look up
identifiers.

Ans 2.An Abstract Data Type is primarily a way of looking at data structure ,focusing
on what it can do rather than how it can be done . A stack is the most common
example of an abstract data type that can be implemented either using an array or
linked list .This demonstrates the abstract nature of stack as user can simply use
the push and pop operation without being concerned about internal data
representation (data structure )or internal of push and pop operation.

1. A specified interface is a collection of signature of operation that can be


invoked on an instance.

2. A set of axionms that define the semantics of the operation i.e.what the
operation do to instance of the ADT, but now.

Why we need to talk about ADTs in a data structure :

1. They serve as specification of requirement for the building blocks of solution


to algorithm problem.

2. Provide a language to talk on a higher level of abstraction.

3. ADTs encapsulate data structure and algorithm that implement them.

4. Separate the issue of correctness and efficiency.

Ans 3.The Application in which the data structure is used are:

a)Operating System
b)Numerical Analysis

c)Artificial Intelligence

d)Network Analysis

Ans 4. The complexity of an algorithm is a function f(n) that gives the running time
and memory space required by an algorithm for possessing the input data of size
n.The analysis of an algorithm in terms of time and space for possessing input data
is called as Algorithm Complexity.The Study of algorithm is necessary to determine
the amount of time and storage space an algorithm may require for
execution.Measuring an algorithm efficiency is important because your choice of
algorithm for a given application often has a great impact.ATMs,Life Support
System,Flight Reservation System all depend on efficient algorithms.

If an algorithm process large amount of data , it is observed


that there is a certain term in the complexity function f(n)that grow the faster. So
any other term that do not substantially contribute to the function ‘s magnitude
should be eliminated from the function .The resulting function so calculated gives
only an approximate time complexity of the original function .However this
approximation is sufficiently close to the original ,especially for a function that
processes large amount of data.This measure of time complexity of an algorithm
where we disregard certain terms of a function to express the efficiency of
algorithm is called Complexity Notation.

Ans 5.(i) Step 1. Repeat for i=k to n-1

Step 2. a[i]<-a[i+1] [Moving element with index i+1 upward by 1]

[end of loop]

Step 3. n<-n-1 [Reset the size of a to n-1]

Step 4. return

(ii) Step 1. I<-n [initialize counter]

Step 2.Repeat steps 3 and 4 while i>=k

Step 3. A[i+1]<-a[i] [Moves element with index I


downwards by 1]
Step 4. i<-i-1 [Decrease counter ]

[end of step 2 loop]

Step 5.A[k]<-item [Inserts element at kth position]

Step 6.n<-n+1 [Reset size of n+1]

Step 7.exit

Ans 6. Step 1.Enter the marks of m students in n no of tests while I<m and j<n

Step 2.Starts loop I while i<m

Step 3. sum 0[intialisation cunter]

Step 4. starts loop j whilej<n

Sum=sum+a[i][j]

J j+1;

Strep 5. avg=sum/n

Step 6. print avg

step 7. i i+1

Step 8. revise step 2 to 7 while i<m

Step 9. end

Ans 7. Step 1. repeat steps 2 for i=0 to i=m-1[number of passes]

Step 2. repeat steps 3 for j=0 to j<n-1[executes pass]

Step 3. repeat steps 4 for k=0 to k<n-j-1[execute pass]

Step 4. if(a[i][j]>a[i][j+1] then(comparing adjacent elements]

(a) t a[i][j]
(b) a[i][j] a[i][j+1]
(c) a[i][j+1] t

Answer 8: In this algorithm we take an array F for grade,which store the average of
student, five higher test score , the size of array F is 30.

In this algorithm we take an variable COUNT, which count the number of student
fail.
Algo -

STEP 1 – [initialize] set COUNT = 0;

STEP 2 – repeat for i: =1 to 30 by 1

If F[i]<60,then:

[i] set COUNT : =COUNT + 1

[end of if structure ]

[end of step 2 loop ]

STEP 3 –write : COUNT;

STEP 4 – EXIT;

Ans 9. STEP 1 – set S: = 0 and A: = 0;

STEP 2 – repeat Q: =1 to 30 by 1

S= S+LA[i]

If Q: = 30, then:

AV: = S/30.

[ end of if structure ]

[ end of loop of step 2 ]

STEP 3 – write : AV;

STEP 4 – EXIT;

Vous aimerez peut-être aussi