This action might not be possible to undo. Are you sure you want to continue?

Rani geetika Date of submission: 2/3/2010 Student roll no: B44 Section no: E1802 Course code CSE-205

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: DEEPAK PANWAR

Evaluator’s comments: Marks obtained _____________________ ______________________________ Content of home work should start from this page only: out of

ASSIGNMENT - 1

Q1 ANS:Every application designed using computers need to manage and process data which is considered as the key component for application’s existence. If any application involves processing of small amount of data then performance of various operations involved in manipulating data may hardly be affected by the way data is organized or stored in memory. However, if an application involves manipulation of large and complex data then the performance of various operations involved will differ in the way how data is stored and organized. Then to solve this type of problem we use the data structuring. Let us consider an example of a company in which you have to organize information of the company’s employees and perform various operations on them. One way to organize this information is to make a list of name of all employees alphabetically with their designation. Using such structure of data, we quickly locate an employee’s information using its name. Had the employee information not being organized alphabetically, it would be very difficult to locate and retrieve any employee information quickly. But this representation does not depict the relationship between employees. As it is not clear which clerk works under which manager and so on. So, in order to depict relationship between employee, you can add another field ‘BOSS’ which corresponds to immediate head of an employee. This has some problem like this, 1. Locating the president of the company. 2. Names of the clerks working under particular manager etc.

ANS2. The implementation of a data structure usually requires writing a set of procedure that create and manipulate the instances of that structure. The efficiency of data structure can’t be analyzed separately from those operations. This observation moves the theoretical concept of an Abstract Data Type, a data structure that is defined indirectly by the operations that may be performed on it, and the mathematical properties of those operations (Including their Space and Time costs) By the term abstract we identify the essential feature without considering detailed specification or implementation. There are several eg. of Abstract data types and stack and queues are common among those. The basic operation of stack and queue are as shown below. STACK PUSH AND POP 1 2 3 ENQUEUE AND DEQUEUE 3 2 FRONT 1 REAR TOP

QUEUE

Note that each of above ADTs has two parts (a) a particular data structure and (b) operations applied on the data structure. We call these data type abstract because we have said nothing about how they are implemented.

Q3

ANS:-Data structure are used in various diverse field of computer science, such as : Statistical analysis package Operation System Graphic Artificial intelligence Network Analysis Numerical Analysis Computer Design Simulation

These all can be used for different purposes depending on the need.

Q4 ANS: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.

The complexity of an algorithm is a function f(n) that gives the running time and memory space required by an algorithm for processing the input data of size n. the concept of algorithm complexity was developed by Juris Hart Manis and Richard E. Sterns. Eg. Void matrixmul(int A[] [], int B[] [], int C[] [], int n, int m) { For(int i=1;i<=n;i++) For (int j=1;j<=n;j++) {C[i] [j]=0; For (int k=1;k<=n;k++) { C[i][j]+=A[i][k]*B[k][j]; } return 0; } This function multiples two matrices A,B each of order nxn and stores the result in matrix C of order nxn. Time complexity of this function is, 2+3n+4n2+3n3 Then its big O notation will be expressed by O(n3) order of n3. Because the notation uses capital letter O to denote the order, it is called Big O notation.

Q5 ANS:-Algorithm for deletion 1. Repeat for I=k to N-1 DELETE OR K=JANE] [K=NAME WHICH WE WANT TO

A[I] A[I+1] upward by 1] [end of loop] 2. N 3. RETURN N-1

[Move element with index I+1

[RESET the size of A to N-1]

Algorithm for INSERTION 1. I N[Initialize Counter] [K=POSITION OF WHERE WE

2. Repeat Steps 3 and 4 while I>=k THE ELEMENT INSERT THE ABC] 3. A[I+1] A[I] downwards by 1] 4. I

[Moves elements with index I

I-1 [Decrease Counter ]

[end of step 2 loop] 5. A[K] 6. N 7. EXIT ITEM [Inserts element at Kth position] N+1 [Reset size to N+1]

ANS 6 :- Algorithm for finding average grade for each test. 1. Repeat for I:= 1 to 6

2. 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.

Q7ANS:-I

1)

SUM 0,a[k]0

2) Repeat Step for I=1to 30 [Outer loop] 3) Repeat Step for j=1to 6 [Inner loop] 4) Repeat Steps 5for I=1to5 5) Repeat Step 6for j=1to5-I 6) If(a[j]>a[j+1])then[comparing adjacent elements]

7) 8) 9)

TEMPA[J] A[J]A[J+1] A[J+1]TEMP [End of the if loop] [End of the step 2 loop] [End of step 1 loop]

10)

Return

11) 12) 13) 14)

Repeat Steps 6 for I=1 to 5 sum=sum+A[I] average=sum/5 if(average>=60)then

gradeA 15) Exit

Q8ANS:- 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. average=sum/6; 6.if(average>=60)then Gradepass Else Gradefail count++ [End the if loop] [End the inner loop] [End the outer loop] 7.Return

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

assignment

assignment

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd