You are on page 1of 4

Q1: Data structuring is required for the following reasons: 1. 2. 3. 4. 5. 6. It arranges similar data together.

Removes complexities as much as possible. Saves time and memory space. Improves efficiency Complex calculations in complex programs are made easier. Helps remove the conflicts arising between the data in a program.

There is a need to choose the right type of structure for the data because choosing a wrong type may lead to the disorganisation of data. The user may not be expert in programming, and as such, choosing a wrong data structuring will lead to add the complexity in his usage. Hence, our program would be less efficient and consume more space too. For example: we are saving the records of students. We have to save name and marks of about 100 students. The correct data structuring required would be to save them in arrays of name, roll no, and marks respectively, But if we choose to save them in each variable, there would be 100 variables for name, another 100 for roll no and yet another 100 for marks. This would increase the space consumption of the program. It will make it more complex. And even the programmer himself would get confused in keeping a track of so many variables. The program execution would take much more time. Hence, choosing a wrong type of data structuring leads up to the messing up of things in a program.

Q2: In data structures, abstract data type may be defined as the set of rules for definition, operations performed, and executions possible on a certain data type. Each data type can be defined by its input and output. In simple words, Abstract data types are a set of rules which define the validity of each and every action that a programmer performs on a certain data type.

Q3: Data structure holds great importance in countless fields of applications. The chief of them are: 1. 2. 3. 4. 5. Q4: The algorithm complexity is defined as the mathematical function M=f(n). This function gives the following values. 1. 2. Running time of program Storage space requirement of the program. In banking softwares. Keeping records of institutions. In engineering, designing and analysing softwares. In search engines. In library softwares.

The algorithm complexity may give any one or both of these valules. The n given in the above expression is simply the size of the input data. So we can say that algorithm complexity is the function which defines the proportionality of the time/space requirement of the output of a program in accordance with the size of the data input. Complexity notations: there are generally two cases in the complexity theory: 1. Worst case: when the value of M is maximum for any input. i.e. M=f(n)=n

2.

Average case: when the value of M is any expected value. M=f(n)=n1p1+n2p2+........+nkpk Where p stands for probability of a possible input, and n is size of that input.

Part B Q5: (1) To delete any element from an array DATA of n elements from the kth location in general: Step1: set i=k Step2: repeat steps 3&4 while i<n Step3: set DATA[i]=DATA[i+1] Step4: set i=i+1 Step5:set n=n-1 Step6: exit

To delete the element JANE from the array NAME: array has 6 elements stored on locations NAME[0] to NAME[5]. Jane in on location NAME[1]. Step1: set i=1, n=6 Step2: repeat steps 3&4 while i<n Step3: set NAME[i]=Name[i+1] Step4: set i=i+1 Step5:set n=n-1 Step6: exit (2) To insert an element in array DATA on kth location in general: Step1: set i=n Step2: repeat steps 3&4 while i>=k Step3: set DATA[i+1]=DATA[i] Step4: set i=i-1 Step5: set DATA[k]=element Step6: set n=n+1 Step7:exit To insert ABC into the array NAME on the location k : Step1: set i=5, n=5 Step2: repeat steps 3&4 while i>=k Step3: set NAME[i+1]=NAME[i] Step4: set i=i-1 Step5: set NAME[k]=ABC Step6: set n=n+1 Step7:exit

Q 6: average grade for each test

# include<iostream.h> # include<conio.h> void main() { clrscr(); float marks[30][6],sum,avg; for(int i=0;i<30;i++) {

cout<<\n please enter the marks of student no<<(i+1); for(int j=0;j<6;j++) { cin>>marks[i][j]; } } for(j=0;j<6;j++) { for(i=0;i<30;i++) { sum=sum+marks[i][j]; } avg=sum/30; cout<<\n\n the average grade for test no<<(j+1)<<is:<<avg<<endl; avg=0; sum=0; } getch() } Q7: Find final grade of each student: # include<iostream.h> # include<conio.h> void main() { clrscr(); float marks[30][6],fgrade[30],sum,n,temp=100; for(int i=0;i<30;i++) { cout<<\n please enter the marks of student no<<(i+1); for(int j=0;j<6;j++) { cin>>marks[i][j]; } } for(i=0;i<30;i++) { for(j=0;j<6;j++) { if(marks[i][j]<temp) { temp=marks[i][j]; n=j; } while(j!=n) {sum=sum+marks[i][j]; } } fgrade[i]=sum/5; cout<<\n Final grade of student no<<i+1<<is:<<fgrade[i]<<endl; sum=0; } getch() }

Q8: Module to find the number of failing students: {

int n=0; for(i=0;i<30;i++) { if(fgrade[i]<60) n++; } cout<<\n No of students failed=<<n; getch(); } Q9: Module to find the average of the final grades: { float sum=0,avg=0; int (i=0;i<30;i++) { sum=sum+fgrade[i]; } avg=sum/30; cout<<\n Average of final grades is:<<avg; getch(); }

You might also like