Upload
rajan-sharma
View
212
Download
0
Embed Size (px)
Citation preview
If there are images in this attachment, they will not be displayed. Download the original attachment
Annexure
Homework type/no Assignment 1 Course code CSE-205
Course instructor: Mr.DEEPAK Kumar
Date of allotment: Date of submission: 27/2/2010
Student roll no: A12 Section no: D1803
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 acknowledgment is made explicitly in the text, nor has been written for me another person.
Student’s signature: shyam keshri
Evaluator’s comments:
Marks obtained _____________________ out of ______________________________
Content of home work should start from this page only:
ASSIGNMENT – 1
Ans 1.because it can store the data in computer memory so that it can used easily and efficiently .the choice of good data structure make it possible to perform a variety of critical operation effectively .an efficient data structure uses minimum memory space and execution time to process the structure as possible ..
Example- 1. loc 1,min a[1]
2.Repeat step 3 for i=2 to N
3. if a[i]< MIN then
LOC =I,min a[i]
4.write loc, min
5.exit
If we will not used the if structure then whole program will be error .
So overcome that type of problem we used selecting data structure..
Ans 2.An abstract data type is primarily a way of looking at a data structure ,focusing on what it can do rather then how it can be done ,a stack is the most comman example of an abstract data type that can be implemented either using array or link list .no matter how stack is implemented ,what is important in a stack is the push and pop operation and how they are used to implemented theses operation s.
This demonstrate the abstract nature of stack as user can simply use the push and pop operation without being concern about stack internal data representation or internal logic of push and pop operation …..
Ans 3. Data structure are used in various application areas…
1. Operation system
2. Numerical analysis
3.Artificial intelligence
4.Simulation
5.network analysis
6.computer desin
7.graphics
ANS 4 - An algorithm is a well defined list of steps for solving a particular problem. So algorithm complexity may be defined as :- the complexity of an algorithm is the function which gives the running time and /or space in term of the input size. Each of our algorithm will involve a particular data structure. Sometime the choice of data structure involves a time space tradeoff: by increasing the amount of space for storing the data , one may be able to reduce the time needed for processing the data , or vice versa. We illustrate these ideas with 2 example.
Consider a membership file containing data like name and telephone no of members. And we want to find a particular record. One way to do this is to linearly search through the file i.e. apply the following algorithm.
Linear search that is compare each record of file one at a time until finding the given and required data. Assuming that each name likely to be picked, it is intuitively clear that average no of comparison for a file with n records is equal to n/2. That is, the complexity of linear search algorithm is given by C(n)=n/2.
Whereas complexity of the binary search algorithm is given by C(n)=log2n.
ANS 5 :- INSERTING INTO AN ARRAY
Insert (LA,N,K,ITEM) . Here LA is a linear array with N elements and K is a positive integer such that K<=N. This algorithm inserts an element ITEM into the Kth position in LA.
1. Set J: =N.2. Repeat step 3 and 4 while J>=K .3. Set LA[ J+1] := LA[J].4. Set J := J-1.5. Set LA[K] := ITEM.6. Set N := N+1.7. Exit.
DELETING FROM A LINEAR ARRAY
Delete (LA,N,K,ITEM). Here LA is a linear array with N elements and K is a positive integer such that K<=N. This algorithm delete the Kth element from LA.
1. Set ITEM: =LA[K].2. Repeat for J=K to N-1 .3. Set LA[J] :=LA [J+1]4. Set N := N-1.5. Exit.
ANS 6 :- Algorithm for finding average grade for each test.
1. Repeat for I:= 1 to 62. Set SUM: = 0.3. Repeat for J=1 to 30
SUM= SUM+TEST[ J ].
(End of inner loop)
4. AVG=SUM / 30.
(end of outer loop)
5. EXIT.
ANS 7:- Algorithm for finding final average grade for each student
(Consider list to be in ascending order)
1. Repeat for I:= 1 to 302. Set SUM: = 0.3. Repeat for J=2 to 6
SUM= SUM+TEST[J].
(End of inner loop)
4. AVG=SUM / 5.
(end of outer loop)
5. EXIT.
ANS 8:- Algorithm for find the number of student who have fail that is whose final grade is less than 60.
(Consider list to be in ascending order)
1. Repeat for I:= 1 to 302. Set SUM: = 0 and count =0.3. Repeat for J=1 to 6
SUM= SUM+TEST[J].
(End of inner loop)
4. AVG=SUM / 5.
5. If( AVG < 60 )6. Add 1 to count.
(end of outer loop)
7. Print count.
Q9.
Q9 ANS:- solution
1. SUM 0
2. Repeat Step 3for I=1to 30 [Outer loop]
3. Repeat Step 4for j=1to 6 [Inner loop]
4. Sum=sum+a[j]
5. Percentagesum/6
6. A[i]=percentage
[End of inner loop]
[End of outer loop]
7. Repeat Step 8 for I=1to 30
8. Sum=sum+A[i]
9. avgerage=sum/30
[End of the loop]
10. if(average>=60)then
GradeA
Else
GradeB
[End of the if loop]
10. Return