0% found this document useful (0 votes)
49 views

Assignment - 1: Declaration

The document contains 8 questions and answers regarding algorithms and data structures. 1) The first 3 questions discuss data structures, abstract data types, and applications of data structures. 2) The next 4 questions provide algorithms for inserting/deleting elements from arrays, calculating average grades for tests/students, and finding number of failing students. 3) The last question provides an algorithm to calculate the average grade of 30 students over 6 tests and determine their final grade.

Uploaded by

Rajan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Assignment - 1: Declaration

The document contains 8 questions and answers regarding algorithms and data structures. 1) The first 3 questions discuss data structures, abstract data types, and applications of data structures. 2) The next 4 questions provide algorithms for inserting/deleting elements from arrays, calculating average grades for tests/students, and finding number of failing students. 3) The last question provides an algorithm to calculate the average grade of 30 students over 6 tests and determine their final grade.

Uploaded by

Rajan Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

If there are images in this attachment, they will not be displayed.

Download the original attachment Annexure Homework type/no Assignment 1 205 Course instructor: Mr.DEEPAK Kumar Date of allotment: 27/2/2010 Student roll no: A12 Date of submission: Section no: D1803 Course code CSE-

Dec arati!n" I declare that this assignment is my individual work. I have not copied from any other student s work or from any other source e!cept where due acknowledgment is made e!plicitly in the te!t" nor has been written for me another person. Student s signature: shyam keshri #valuator s comments: $arks 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 e!ecution time to process the structure as possible .. #!ample& '. loc '"min a(') *.+epeat step , for i-* to . ,. if a(i)/ $I. then 01C -I"min a(i) 2.write loc" min 3.e!it 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.4n 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 e!ample 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. 5his 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 6.. Ans 3. Data structure are used in various application areas6 '. 1peration system *. .umerical analysis ,.4rtificial intelligence 2.Simulation

3.network analysis 7.computer desin 8.graphics A#S $ - 4n algorithm is a well defined list of steps for solving a particular problem. So algorithm comple!ity may be defined as :& the comple!ity of an algorithm is the function which gives the running time and /or space in term of the input si9e. #ach 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. :e illustrate these ideas with * e!ample. Consider a membership file containing data like name and telephone no of members. 4nd we want to find a particular record. 1ne way to do this is to linearly search through the file i.e. apply the following algorithm. 0inear search that is compare each record of file one at a time until finding the given and re;uired data. 4ssuming that each name likely to be picked" it is intuitively clear that average no of comparison for a file with n records is e;ual to n/*. 5hat is" the comple!ity of linear search algorithm is given by C<n=-n/*. :hereas comple!ity of the binary search algorithm is given by C<n=-log *n.

A#S 5 "- %#SE&'%#( %#') A# A&&A* Insert <04".">"I5#$= . Here 04 is a linear array with . elements and > is a positive integer such that >/-.. 5his algorithm inserts an element I5#$ into the >th position in 04. '. *. ,. 2. 3. 7. Set ?: -.. +epeat step , and 2 while ?@-> . Set 04( ?A') :- 04(?). Set ? :- ?&'. Set 04(>) :- I5#$. Set . :- .A'.

8. #!it.

DE+E'%#( ,&)M A +%#EA& A&&A* Delete <04".">"I5#$=. Here 04 is a linear array with . elements and > is a positive integer such that >/-.. 5his algorithm delete the >th element from 04. '. *. ,. 2. 3. Set I5#$: -04(>). +epeat for ?-> to .&' . Set 04(?) :-04 (?A') Set . :- .&'. #!it.

A#S - "- 4lgorithm for finding average grade for each test. '. +epeat for I:- ' to 7 *. Set SB$: - C. ,. +epeat for ?-' to ,C SB$- SB$A5#S5( ? ). <#nd of inner loop= 2. 4DE-SB$ / ,C. <end of outer loop= 3. #FI5.

A#S 7"- 4lgorithm for finding final average grade for each student <Consider list to be in ascending order= '. +epeat for I:- ' to ,C

*. Set SB$: - C. ,. +epeat for ?-* to 7 SB$- SB$A5#S5(?). <#nd of inner loop= 2. 4DE-SB$ / 3. <end of outer loop= 3. #FI5.

A#S 8"- 4lgorithm for find the number of student who have fail that is whose final grade is less than 7C. <Consider list to be in ascending order= '. +epeat for I:- ' to ,C *. Set SB$: - C and count -C. ,. +epeat for ?-' to 7 SB$- SB$A5#S5(?). <#nd of inner loop= 2. 4DE-SB$ / 3. 3. If< 4DE / 7C = 7. 4dd ' to count. <end of outer loop= 8. Grint count.

HI. 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] !. "er#enta$esum%6 6. &[i]=per#enta$e ['n( of inner loop] ['n( of outer loop] ). Repeat Step * for I=1to 30 *. Sum=sum &[i] +. a,$era$e=sum%30 ['n( of t-e loop] 10. if.a,era$e/=600t-en 1ra(e& 'lse 1ra(e2 ['n( of t-e if loop] 10. Return

You might also like