BCA Data Structures Notes
BCA Data Structures Notes
IIIIII
a[O]a[l]a[2]a[3]a[4]
3
memoryrepresentation
1.2
Figure1.2
StorageRepresentationOfData
THENEEDFORDATA STRUCTURES
One of the tools that beginers often take for granted is the high-level language in which they
write their programs. Since most of us first learn to program in a language like C. we do not appreciateits
branching and looping structures and built-in data structures until we are later introduced to language
that do not have these features.
In the first semester(C programming). we decided to use an array of structure to store our data.
But what is an array? What is a structure? C. as well as many other hig-level programming langauges.
provides arrays and structure as built-in data structures. As a C programming. you can use these tools
without concern about their implementation. much as a car driver can use a car without knowing about
automobile technology.
However, there are many interesting and useful ways of structuring data that are not provided in
general-purpose programming languages. The programmer who wants to use these structures must build
them. Inthisbook,wewilllookin detailfourusefuldatastructures:stacks,queues,listsandbinarytrees. We will
decribe each of these structures and design algorithms to manipulate them. We will build them using the
tools that are available in the C language. Finally, we will examine applications where each is
appropriate.
First,however, we will develop a definition of data structure and an approach that we can use to
examine data structures. By way of example, we will apply our definition and approach to familiar Cdata
structures: the one dimensional array, the two dimensional array, and the structure.
The two important goals of data structures are first to identify the representation of abstract
entities and then to identify the operations. which can be performed with them. The operations help us to
determine the class of problems, which can be solved with these entities.
4Introductiontodatastructures
The choice of data model depends on two considerations. First. it must be rich
enough instructureto showtheactual relationshipsofdatainreal world.Ontheother hand, the
structure should be simple enough so that one can efficiently process the data when
necessary. Data structure is nothing but arrangement of data and their relationship and the
allowed operations. One can use simple data structure to build complex data structures.
Data structures are fundamental to computer programming in any language. As
progranuners work on algorithm development and problem analysis. they make crucial
decisions about data structures. A data structure is a representation of the data in the
program. Theproper construction ofa programisinfluencedbythechoice of datastructure.
which is used. A datastructure is a systematic wayof organizingand accessingdata, and an
algorithm is a step- by-step procedure for perfonIling some task ina tillite amount of time.
These concepts are central in computing.
1.3GOALSOFDATA STRUCTURES
Thegoalsof datastructurescanbedesignedtoanswercertainquestionssuchas
1.Doesthedatastructuredowhatitissupposedto do?
,,2.Doestherepresentationworkaccordingtotherequirementspecification,ofthetask?
~3.Isthereaproperdescriptionoftherepresentationdes;cribinghowtouse.it andhowit works?
I
Theabovequestionswhenansweredcreatethe-fundamentalgoalsthatareusedin designing
descriptions of data structures. some of them are
1.Correctness
i 2. Efficiency .,
,
.,3.Robustness,; 4.Adaptability
5. Reusability
Useful data structure and their operations also need to be efficient. That is, they
should be fast and not use more of the computer's resources. such as memory space. than
required. In a real-time situation, the speed of a data structure
~ operation can make the difference between success and failure, a difference that can often be quite
important.
,
--'"~"