0 Up votes0 Down votes

20 views9 pagesNov 25, 2010

© Attribution Non-Commercial (BY-NC)

DOC, PDF, TXT or read online from Scribd

Attribution Non-Commercial (BY-NC)

20 views

Attribution Non-Commercial (BY-NC)

- scimakelatex.13505.koty
- Johnson Trotter Algorithm
- CHAPTER 1.pptx
- Scimakelatex.31866.Doe.smith.anon.Jane.john
- A Case for Object-Oriented Languages
- Sharif Paper
- scimakelatex.28237.MAriano+Melgarejo
- Election Algorithms
- TC
- B.tech JNTU Cp & Ds unit -1 & 2 Notes
- Scimakelatex.66623.Ooo.eeee.Jjj
- scimakelatex.25236.John+Reese
- IA Solved Paper Second Part 51 to 100
- digital application-ppt.pptx
- MAIN
- Decoupling Compilers From Gigabit Switches in E-Commerce
- Algorithms and Complexity
- Lecture 1
- A Methodology for the Extensive
- Notion Etymology - Google Search

You are on page 1of 9

Section: c6803

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 any

part been written for me by another person.

Student’s Signature :

Jitender kumar___________

Evaluator’s comments:

_____________________________________________________________________

Part-A

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 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 the data 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, the algorithms 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.

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

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

2. Repeat step3 varying i from 1 to 49

3. If num[i] > max then: max = num[i]

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, easier to understand and implement as compared to the

algorithm that uses 50 variables.

ANS: The implementation of a data structure usually requires writing a set of procedures that

create and manipulate instances of that structure. The efficiency of a data structure cannot be

analyzed separately from those operations.This observation motivates 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 cost).

ANS:A data structure is used for the storage of data in computer so that data can be used

efficiently. For the organization of mathematical and logical concepts data structure provides

a methodology. With the proper selection of data structure you can also get efficient

algorithm. With very few resources like memory space and time critical operations can be

carried out with a well designed data structure. The major use of data structure is its

implementation in the programming language.

Moreover, there are different kinds of data structures and they have

different uses. Some data structures are used for specialized tasks like B-

trees are used for the implementation of databases and networks of

machines use routing tables.

Area in which data structures are applied is given below:

1)Compiler Design

2)Operating System,

3) Database Management System,

4)Statistical analysis package,

5)Numerical Analysis,

6)Graphics,

7)Artificial Intelligence,

8) Simulation

with suitable examples.

ANS:In the study of complexity of algorithm,most attention has been given to bounding the

number of primitive operations(for examples

comparons) needed to solve a problem.

However, when working with data materials so large that they will not fil into internal

memory, the amount of time neeed to transfer data between the intenam memoer and the

external storage(the number of I/O operation) can easily dominate the overall execution time.

quality of algorithms, especially the specific amount of a certain resource an algorithm needs.

Examples of such resourceswould be time or memory storage. Nowadays, memory storage is

almost a non- essential factor when designing algorithms but be aware that several systems

still have memory constraints, such as Digital Signal Processors in embedded systems.

Different algorithms may complete the same task with a different set of instructions in less or

more time, space or effort than other. The analysis and study of algorithms is a discipline in

Computer Science which has a strong mathematical background. It oftenrelies on theoretical

analysis of pseudo-code.

To compare the efficiency of algorithms, we don't rely on abstract measures such as thetime

difference in running speed, since it too heavily relies on the processor power and other tasks

running in parallel. The most common way of qualifying an algorithm is theAsymptotic

Notation, also called Big O .

specific amount of a certain resource an algorithm needs. Examples of such resources would

be time or memory storage. Nowadays, memory storage is almost a non-essential factor when

designing algorithms but be aware that several systems still have memoryconstraints, such as

Digital Signal Processors in embedded systems.

Different algorithms may complete the same task with a different set of instructions inless or

more time, space or effort than other. The analysis and study of algorithms is a discipline in

Computer Science which has a strong mathematical background. It oftenrelies on theoretical

analysis of pseudo- code.

To compare the efficiency of algorithms, we don't rely on abstract measures such as thetime

difference in running speed, since it too heavily relies on the processor power and other tasks

running in parallel. The most common way of qualifying an algorithm is the Complexity

Notation, also called Big O.

bound for the magnitude of afunction in terms of another, simpler

function.This means that for x > k, when x tends to infinity, the value f(x)

will always be inferiorto C *g(x) (with C a constant).

The idea behind this notation is that it allows us to qualify to efficiency of an algorithm by

telling us how often a certain algorithm will execute operations before terminating.

Part-B

1. Consider the array NAME

1.NAME

Mar

y

Jane

Dia

na

Sus

an

Kar

en

Edit

h

also delete jane from the array NAME.

also add ‘ABC’ into the array NAME.

Here LA is an linear array with n elements and k is an positive integer

such that k<=n.This algorithm deletes the kth itemfrom LA.

1. Set item=LA[k].

2. Repeat for J= k to n-1 :

[Move J+1st itemupward] Set A[J] := A[J+1].

[End Of Loop.]

3.[Reset the number n of elements in A] Set n := n-1.

4. Exit.

Delete jane from the array NAME.

HereName[0]=Marry,Name[1]=jane,Name[2]=Diana,Name[3]=Susan,Name[4]=Karen,Name

[5]=Edith.

Steps of algorithm to delete jane from Name array:-

1. Set item=jane.

2. Repeat for J=1 to 5.

[Move J+1st item Upward] Set A[J]:=A[J+1].

[End Of Loop.]

3.[Reset the number of element in A] set n=5.

4.Exit.

also add ‘ABC’ into the array NAME.

(Deleting an item from an Array) DELETE (LA,n,k,ele).

Here LA is an linear array with n elements and k is an positive integer such that k<=n.This

algorithm deletes the kth itemfrom LA.

1. Set item=LA[k].

2. Repeat for J= k to n-1 :

[Move J+1st itemupward] Set A[J] := A[J+1].

[End Of Loop.]

3.[Reset the number n of elements in A] Set n := n-1.

4. Exit.

Algorithm to insert ABC in Array at 7th Position.

2.Repeat Steps 3 and 4 while J>=6.

3.[Move Jth element downward] Set A[J+1] := A[J].

5.[Insert Element.] Set A[k]=item.

6.[Reset n.] Set n=7.

7.Exit.

Q. 6: Each student of a class of 30 students takes 6 test in which scores ranges from 0 to

100 .Suppose the test Scores are stored in 30*6 array test. Find the average grade for

each test

ANS: #include<iostream.h>

#include<conio.h>

int main()

{

int st[60][7],b,c,d,avg;

int total;

clrscr();

cout<<"\nenter marks of students:";

for(b=1;b<=60;b++)

{cout<<"\n enter marks for student : "<<s;

for(c=1;c<=6;c++)

{

cout<<"\nenter marks of test "<<t<<":";

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;

}

Q.7: Find the final grade for each student where the final grade is average of the

student’s five highest test scores

ANS:

#include<iostream.h>

#include<conio.h>

int main()

{

int st[30][30],a,m,sc,total,avg;

int total;

clrscr();

cout<<"\nenter marks of students:";

for(a=1;a<=60;a++)

{cout<<"\n enter marks for student : "<<s;

for(m=1;m<=6;m++)

{

cout<<"\nenter marks of test "<<t<<":";

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;

}

Q. 8: For Q6 Write a module which finds the number of students who have fail that is

whose final grade is less than 60.

ANS:

#include<iostream.h>

#include<conio.h>

int main()

{

int st[30][30],a,m,sc,avg,ctr=0;

int total;

clrscr();

cout<<"\nenter marks of students:";

for(a=1;a<=5;a++)

{

cout<<"\n enter marks for student : "<<s;

for(m=1;m<=6;m++)

{

cout<<"\nenter marks of test "<<t<<":";

cin>>st[a][m];

}

}

for(a=1;a<=5;a++)

{

cout<<"\nStudent:"<<s;

total=0;

for(m=1;m<=6;m++)

{

total=total+st[a][m];

}if(total<60)

{

ctr++;

}

cout<<"\nTotal score:"<<total<<"\n";

}

cout<<"\n"<<ctr;

getch();

return 0;

}

ANS:

#include<iostream.h>

#include<conio.h>

int main()

{

int st[30][30],a,m,sc,avg,ctr=0;

int total;

clrscr();

cout<<"\nenter marks of students:";

for(a=1;a<=5;a++)

{

cout<<"\n enter marks for student : "<<s;

for(m=1;m<=6;m++)

{

cout<<"\nenter marks of test "<<t<<":";

cin>>st[a][m];

}

}

for(a=1;a<=5;a++)

{

cout<<"\nStudent:"<<s;

total=0;

for(m=1;m<=6;m++)

{

total=total+st[a][m];

avg=total/6;

}

cout<<"\nTotal score:"<<total<<"\n";

cout<<"\nAVG:"<<avg;

}

getch();

return 0;

}

- scimakelatex.13505.kotyUploaded byLK
- Johnson Trotter AlgorithmUploaded byPrajwal Halwai
- CHAPTER 1.pptxUploaded bySyarifuddin Sumaidi
- Scimakelatex.31866.Doe.smith.anon.Jane.johnUploaded bymdp anon
- A Case for Object-Oriented LanguagesUploaded byPamela Lindsey
- Sharif PaperUploaded by李舜臣
- scimakelatex.28237.MAriano+MelgarejoUploaded byGonzalo Gonzales
- Election AlgorithmsUploaded byyudha_mulya
- TCUploaded byLaxman Thapa
- B.tech JNTU Cp & Ds unit -1 & 2 NotesUploaded byNagender Andugula
- Scimakelatex.66623.Ooo.eeee.JjjUploaded bycristian.carmen2426
- scimakelatex.25236.John+ReeseUploaded byJohn Turkleton
- IA Solved Paper Second Part 51 to 100Uploaded bygajen_yadav
- digital application-ppt.pptxUploaded byMohd Salahuddin
- MAINUploaded byswatfacey
- Decoupling Compilers From Gigabit Switches in E-CommerceUploaded byGath
- Algorithms and ComplexityUploaded byChristopher Advincula
- Lecture 1Uploaded byJay Ng
- A Methodology for the ExtensiveUploaded byxxx
- Notion Etymology - Google SearchUploaded byRavi Umraniya
- W5 Queueing TheoryUploaded byAngel
- KHoaUploaded byThang M. Hoang
- Modular, Wearable Symmetries for 80211BUploaded byAuthor
- Practical 1Uploaded bySarvesh Shinde
- spaUploaded byapi-236544093
- LoftTart Symbiotic TheoryUploaded byYarid Rodriguez
- Cabrera-Act1.docxUploaded byKenneth Princillo
- Layout PoEx ExerptUploaded bytiffzerby
- Constructing Vacuum Tubes and Model CheckingUploaded bycjabcd1234
- Video Card and Sound CardUploaded bySean Campbell

- data structure4Uploaded byjitenderthakur490
- PHYsics of sensor 802 hw2Uploaded byjitenderthakur490
- PHYsics of sensor 802 hw1Uploaded byjitenderthakur490
- PHYsics of sensor802 hw03Uploaded byjitenderthakur490
- data structure HW2Uploaded byjitenderthakur490
- Dat Structure Homework3Uploaded byjitenderthakur490
- TP_ANALOGUploaded byjitenderthakur490
- Roll No 3 AnalogUploaded byjitenderthakur490
- jitenderUploaded byjitenderthakur490
- jitenUploaded byjitenderthakur490
- 14820_homework 04Uploaded byjitenderthakur490

- A Comparative Study on Vodafone & Airtel Marketing Research 2012Uploaded byAjit Singh Rathore
- Intelliremote User ManualUploaded bycasperll
- Data Dictionary - FAQs - ABAP Development - SCN WikiUploaded byPrashant Adhikari
- ccna2-chapter9Uploaded byantidote88
- ht70x_usermanual_english.pdfUploaded byMitsuha De Arrvaz
- Chapter 4 - Selection StructureUploaded bysemuty92
- Design ProcessUploaded byRobert Kerr
- The Term of Multimedia is Consists Of2Uploaded byFarhan Sheikh Muhammad
- Autodesk Inventor - Sheet Metal Punch ifeaturesUploaded byNdianabasi Udonkang
- Advances in Grid Computing.pdfUploaded byyasir2000
- Ewm700 Mit Demo Ruf WopUploaded byJayakumar
- D96139GC30_ag.pdfUploaded byrana1812
- TCI6636K2H_DatamanualUploaded bybondsebastian
- SequenceUploaded byHerz Richtig
- oops mod1.pdfUploaded byThanu Shree
- cv.pdfUploaded byTejaswini T Manjunath
- Call Center Operations Improvement Business Case - Sample PresentationUploaded byChamil Hettiarachchi
- Microsoft Protocol to Patent Map Courtesy of CentrifyUploaded byvsupport
- CCNA Cyber Ops (Version 1.1) - Chapter 9 Exam Answers Full.pdfUploaded byRawan Alharbi
- Sbo401 Ds Tdp Ext Cust EnUploaded byGuilherme C P
- Clusternode TrainingUploaded byKetan Varia
- Lect03 Qual MetricsUploaded byorengeneral
- 2012t1corestudentapps.pdfUploaded byIvan Flores
- 10 - zw_icip_2002_norefjpeg.pdfUploaded byCelana Boxer
- Ntp Status CpciUploaded byK.m.khizir Ahmed
- SRB Kluh Corporate ProfileUploaded byarif_abdin
- and1_padUploaded byPatel Alpesh
- unit-1Uploaded byNeeru Chaudhary
- Performance and Availability Reporting with CCMS and Business Intelligence OverviewUploaded byRavindra Chowdary Gokina
- RM ThesisUploaded bym_rashed

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.