Beruflich Dokumente
Kultur Dokumente
ASSIGNMENT 1
CSE 2050
Submitted to:
Sec-
C6801
Roll
No-RC6801B48
R.Id.-
10802195
Ques1 : Why structuring of data is required .Take one
example problem and discuss various problems that can
be faced if wrong choice has been made in selecting
data structure for the problem?
ANS:In computer science, a data structure is a way of storingdata in a computer
so that it can be used efficiently. Often a carefully chosen data structure will
allow the most efficient algorithm to be used. The choice of the data structure
often begins from the choice of an abstract data type. A well-designed data
structure allows a variety of critical operations to be
performed, using as few resources, both execution time and memory space,as
possible. Data structures are implemented using thedata types,references and
operations on them provided by a programming language.
Different kinds of data structures are suited to different kinds of applications,
and some are highly specialized to certain tasks. For example,B- tr ees are
particularly well-suited for implementation of databases, while routing tables rely
on networks of machines to function.In the design of many types ofpr ogr ams,
the choice of data structures is a primary design consideration, as experience in
building large systems has shown that the difficulty of implementation and the
quality and performance of the final result depends heavily on choosing the best
data structure. After
the data structures are chosen, thealgor ithms to be used often become
relatively obvious. Sometimes things work in the opposite direction – data
structures are chosen because certain key tasks have algorithms that work best
with particular data structures. In either case, the choice of appropriate data
structures is crucial. This insight has given rise to many formalised design
methods and programming languages in which data structures, rather than
algorithms, are the key organising factor. Mostlanguages feature some sort
ofmodule system, allowing data structures to be safely reused in different
applications by hiding their verified implementation details behind controlled
interfaces.Object- or ientedHYPE RL I NK
"http://www.search.com/reference/Programming" \o
"Programming"programming languages such as C++and Java in particular
useclasses for this purpose.
Consider an example where you have to find the maximum value in a set of
50 numbers; in this we can either use 50 variables or a data structure, such as
an array of size 50, to store the numbers. When 50 different variables are
used to store the numbers, the algorithm to determine the maximum value
among the numbers can be written as:
1. Accept 50 numbers and store them in num1, num2, num3, .. num50
2. Set max = num1 3. If num2 > max then: max = num2
4. If num3 > max then: max = num3:
5. If num50 > max then max = num50
6. Display max
On the other hand, when an array of size 50 is used, the algorithm can be
written as:-
1. Set max = num[0]
4. Display max
From the preceding two algorithms, it can be seen that the algorithm using an
array manipulates memory much more efficiently than the algorithm using 50
variables. Also, the algorithm using an array involves few steps and is therefore,
variables.
Mary
Jane
Diana
Susan
Karen
Edith
1. Set item=jane.
2. Repeat for J=1 to 5.
[End Of Loop.]
4.Exit.
3.
7.Exit.
7.Exit.
int st[60][7],b,c,d,avg;
int total;
clrscr();
for(b=1;b<=60;b++)
for(c=1;c<=6;c++)
cin>>D[b][c];
}
}
for(b=1;b<=60;b++)
cout<<"\nStudent:"<<s;
total=0;
for(c=1;c<=6;c++)
cout<<"\nTest:"<<t<<"\n";
if(st[s][t]<33)
{cout<<"Grade:F";
}
else if(st[b][c]>=33 && st[b][c]<60)
{cout<<"Grade:C";
}
else if(st[b][c]>=60 && st[b][c]<70)
{cout<<"Grade:B";
}
else if(st[b][c]>=70 && st[b][c]<80)
{cout<<"Grade:A";
}
else if(st[b][c]>=80 && st[b][c]<=90)
{cout<<"Grade:A+";
}
else if(st[b][c]>90)
{cout<<"Distintion";
}
}
cout<<"\n";
getch();
return 0;
QUES7: Find the final grade for each student where the
final grade is
average of the student’s five highest test scores
ANS:#include<iostr eam.h>
#include<conio.h>
int main()
{
int st[30][30],a,m,sc,total,avg;
int total;
clrscr();
for(a=1;a<=60;a++)
for(m=1;m<=6;m++)
cin>>st[a][m];
for(a=1;a<=60;a++)
cout<<"\nStudent:"<<s;
total=0;
for(m=1;m<=6;m++)
{total=total+st[a][m];
}cout<<"\n";
cout<<"\nTotal score:"<<total<<"\n";
if(total<200)
{
cout<<"Grade:F";
}else if ( total>=200 && total<360)
{
cout<<"Grade:C";
}else if(total>=360 && total<420)
{
cout<<"Grade:B";
}else if(total>=420 && total<480)
{
cout<<"Grade:A";
}else if(total>=480 && total<=540)
{
cout<<"Grade:A+";
}else if(total>540)
{cout<<"Distintion";
}
getch();
return 0;