0% found this document useful (0 votes)
5 views

Ds Notes Ch01

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Ds Notes Ch01

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Chapter 01

Basic of Data Structures


1. Data structure- Definition:
 Data may be organized in many different ways; the logical or mathematical
model of a particular organization of data is called a data structure.
 Data structure is the structural representation of logical relationships between
elements of data. In other words a data structure is a way of organizing data
items by considering its relationship to each other.
 Data structure mainly specifies the structured organization of data, by
providing accessing methods with correct degree of associativity. Data
structure affects the design of both the structural and functional aspects of a
program.
Algorithm + Data Structure = Program

 Data structures are the building blocks of a program; here the selection of a
particular data structure will help the programmer to design more efficient
programs as the complexity and volume of the problems solved by the
computer is steadily increasing day by day.

2. Types of data structures:


 Data structures are generally classified into primitive and non-primitive data
structures. Basic data types such as integer, real, character and Boolean are
known as primitive data structures. These data types consist of characters that
cannot be divided, and hence they are also called simple data types.
 The non-primitive data structure is the processing of complex numbers, very
few computer are capable of doing arithmetic on complex numbers, linked-
list, stacks, queue, trees and graphs are example of non-primitive data
structures.

 Primitive data structures:


 Integer: An integer is the basic data types which is commonly used for
storing negative as well as non-negative integer numbers. Example 38, -
38

 Real Number: The method used to represent real numbers in computer


is floating-point notation. In this notation, the real number is represented
by a number called a mantissa, times a base raised to an integer power
called an exponent. Example 20952 X 10-2 mantissa is 20952 and
exponent is -2.

 Character: Some data are storing character or string form. There are
different codes available to store data in character form such as BCD,
EDCDIC and ASCII.

 Boolean: Some data are represent in only two way like true-false, on-off
or flag set-flag reset. These kinds of data are considering Boolean type.
Based on the structure and arrangement of data, non-primitive data structures are
further classified into linear and non-linear.

 Linear Data Structure:


A data structure is said to be linear if its elements from a sequence or a linear list.
In linear data structures, the data is arranged in a linear fashion although the way
they stored in memory need not be sequential. Arrays, linked lists, stacks and
queues are example of linear data structures.

Arrays: Linear array mean a list of a finite number n of similar data elements
referenced respectively by a set of n consecutive numbers, usually 0,1,2,…..,n.
Linked List: Consider following fig 1.7 is example of linked lists. Although the
terms “pointer” and “link” are usually used synonymously. The term “pointer”
when an element in one list points to an element in a different list and to reverse
the term “link” for the case when an element in a list points to an element in that
same list.

Stacks: A stack also called last-in first-out (LIFO) system, is a linear list in
which insertions and deletions can be take place only at one end, called the top.
This structure is similar in its operation to a stack of dishes on a spring system.
Note that new dishes are inserted only at the stack and dishes can be deleted only
from the top of the stack.
Queue: A queue also called a first-in first-out (FIFO) system, is a linear list in
which deletion can be take place only at one end of the list, the “front” of the list
and insertions can take place only at the other end of the list, the “rear” of the list.
This structure operates in much the same way as a line of people waiting at the
bus stop. Another analogy is which automobiles waiting to pass through an
insertion-the first car in the first car through.

 Non-linear data structure:


A non-linear data structure means they not arranged in sequence. The insertion
and deletion of data is therefore not possible in a linear fashion. Trees and graphs
are examples of non-linear data structures.

Trees: Data frequently contain a hierarchical relationship between various


elements. The data structure which reflects this relationship is called a rooted tree
graph or, simply, a tree.
Graph: Data sometimes contain a relationship between pair of element which is
not necessarily hierarchical in nature. For example, suppose an airline flies only
between the cities connected by lines. The data structure which reflects this type
of relationship is called a graph.
3. Data Structure Operations:

4. Algorithms: Complexity, Time and Space complexity:


1. In the first stage, modeling, we try to represent the problem using an
appropriate mathematical model such as a graph, tree etc. At this stage, the
solution to the problem is an algorithm expressed very informally.

2. At the next stage, the algorithm is written in pseudo-language (or formal


algorithm) that is, a mixture of any programming language constructs and less
formal English statements. The operations to be performed on the various types
of data become fixed.

3. In the final stage we choose an implementation for each abstract data type and
write the procedures for the various operations on that type. The remaining
informal statements in the pseudo-language algorithm are replaced by (or any
programming language) C/C++ code.

Complexity:
Abstract Data Type:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy