Chapter 1 Introduction
Chapter 1 Introduction
INTRODUCTION
“Those who wise succeed must ask the right preliminary questions”. – Aristotle
I
n Computer Science, one of the core fields that belongs to its
foundations, with the design, analysis, and implementation of K E Y F E A T U R E S
algorithms for the efficient solutions of the problem Data and Information
concerned. The data structure is one of the subjects that
Data Structure
intrinsically connected with the design and implementations of
efficient algorithms. Data Type
The subject ‗Data Structure‘ deals with the study of methods, Abstract Data Type
techniques, and tools to organize or structure data in computer
Classification of Data Structure
memory.
Now before defining Data Structure, we should know ― what is data?‖ and ―
what is the difference
between data and information?‖
Data and Information
Data is a plural of datum, which is originally a Latin noun meaning ― something given.‖
The Oxford dictionary meaning of data is:
i) Facts or statistics used for reference or analysis.
ii) The quantities, characters or symbols operated by a computer.
For our purpose, the second meaning is more important. Therefore, we can say that:
The data represent quantities, characters, or symbols on which operations are performed by
a computer, stored and recorded on either magnetic, optical, or mechanical recording media, and
transmitted in the form of digital electrical signals.
Definition: Data is the basic entity or fact that is used in a calculation or manipulation process.
Data is commonly processed by some stages. Unprocessed data or raw data is a collection of
numbers, characters, that may be considered as an input of a stage and processed data is the output of
the stage.
There are two types of data, such as numerical and alphanumerical data. Data may be a single
value or a set of values and it is to be organized in a particular fashion. This organization or structuring
of data will have a profound impact on the efficiency of the program.
Most of the individuals consider that the terms "Data" and "Information" are interchangeable and
mean the same thing. However, there is a distinct difference between the two words. Data are raw
facts without context, whereas Information is data with context. Data are an abstraction of Information
in a problem-solving system. Data requires interpretation to become an Information.
Data can be any character, text, words, number, pictures, sound, or video and if not put into
context means nothing to a human or computer. For example, 10409 is a data, whereas information
1.2 | Data Structures and Algorithms with C
may be 1/04/09-the date of birth of Avinaba, 10409 a zip code of somewhere or Rs. 10409 is the salary
of someone.
Raw Data Information
Processing
Figure 1.1: Data and Information
Representation of Data
Almost all the high-level languages, e.g. FORTRAN, COBOL, C, Pascal, C++, Java, etc. allow data to
be represented in computer memory of mainly two types:
i) Numerical Data
ii) Alphanumerical Data
Most of the high-level languages classified numerical data into two types:
i) Integer
ii) Floating-point
In C language, the following Data types are used to represent numerical data.
Table 1.1: Ranges of numerical data types
Character
The characters may be alphabets, digits, special characters and white spaces. In C language, characters
are represented by char data type and one-byte memory space is used for storing the same. The ASCII
format has been used in C language to represent the characters. While storing character ‗C‘ in the
computer, ASCII value 67 is stored in memory.
String
The string is a sequence of characters may consist of any number and any combination of characters.
The characters may be alphabets, digits, special characters and white spaces. In C language, the string
can be defined as an array of character terminated with a null character.
Data Type
Generally, computer programs do exist for a single purpose: how to process data. The type of data, the
format of data that is going to be returned and the correctness of the processing are the primary
concerns of a computer program. When a program is written, how the computer handles the data
internally is usually a secondary concern.
Definition: A data type refers to the type of data that variables hold.
Now, depending on the representation of different forms of data, different data types are used. The
data types are names given to a set of variables, which have common properties. A data type refers to
the type of data that variables hold.
Data types
Data
Structure
Non -
Primitive
primitive
Non -
int float char pointer Linear
Linear
Operation Description
Allocation of memory for the data structure, the creation of data structure
Creation
may take place either during compile-time or during run-time.
Insertion Insert a data item in the data structure.
Deletion Delete a data item from the data structure.
Traversing Accessing and processing each data item of the data structure exactly once.
Searching Find the location of the key value within the data structure.
Arranging all the data items in a data structure either in ascending or in
Sorting
descending order or in lexicographical order (for Strings).
Merging Combining the data items of two different sorted lists into a single sorted list.
Linked List
A linked list is an ordered collection of finite homogeneous data elements called node where the linear
order is maintained by means of links or pointers. In linked list, data items may be scattered arbitrarily
all over the memory. In a linked list, there is no relationship between the addresses of elements; each
element of a linked list must store explicitly the address of the element, next to it.
Tree
The tree is a non-linear data structure. A Tree may be defined as a non-empty finite set of nodes, such
that
i) There is a specially designated node called the root,
ii) The remaining nodes are partitioned into zero or more disjoint trees T 1, T2, … Tn are called the
subtrees of the root R.
Graph
The graph is another non-linear data structure. A Graph G is defined as an ordered set G = (V, E),
consists of finite non-empty set of objects V, where V (G) = {v1, v2, v3, … vn} called vertices (or nodes
or points) and another set E where E (G) = {e1, e2, e3, …em} whose elements are called edges, that
connects these vertices.
Summary
Data is the basic entity or fact that is used in the calculation or manipulation process.
Data are raw facts without context, whereas information is data with context.
Data Structure is defined as a mathematical or logical model of the particular organization of data
items in computer memory so that it can be used efficiently.
An Abstract Data Type (ADT) describes the data objects, which constitute the data structure, and
the fundamental operations supported on them.
Exercises
1. What are the differences between linear and non-linear data structures?
2. What are the operations can be performed on data structures?
3. What is an Abstract Data Type? What do you mean by a Dynamic Data Structure?
4. Choose the correct alternatives for the following:
i) Which of the following data structure is a linear data structure?
a) Trees b) Graphs c) Arrays d) None of these
ii) The operation of processing each element in the list is known as
a) Sorting b) Merging c) Inserting d) Traversal
iii) Finding the location of the element with a given key in the list is known as
a) Traversal b) Searching c) Sorting d) None of these
iv) Representation of data structure in memory is known as
a) Recursion b) Abstract data type c) Storage structure d) File structure
v) An ADT is defined to be a mathematical model of a user-defined type along with the collection
of all__________operations on that model
a) Cardinality b) Assignment c) Primitive d) Structured
*****