0% found this document useful (0 votes)
91 views31 pages

Data Structure-: A. H. M. Saiful Islam Associate Professor and Chairman Department of Computer Science and Engineering

The tree diagram for the expression is: (7x + y) | | 5a -b | | 3 3 (b) The scope of the exponential operation 3 consists of the nodes 3 and the subtrees below it, which are the nodes 5a, -b and their children.

Uploaded by

Tamim Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
91 views31 pages

Data Structure-: A. H. M. Saiful Islam Associate Professor and Chairman Department of Computer Science and Engineering

The tree diagram for the expression is: (7x + y) | | 5a -b | | 3 3 (b) The scope of the exponential operation 3 consists of the nodes 3 and the subtrees below it, which are the nodes 5a, -b and their children.

Uploaded by

Tamim Islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Data Structure-

Introduction

A. H. M. Saiful Islam
Associate Professor and Chairman
Department of Computer Science and Engineering
Elementary Data Structure Organization

A data structure is basically a group of data elements that are put together
under one name, and which defines a particular way of storing and organizing
data in a computer so that it can be used efficiently.
Elementary Data Structure Organization
Example
Classification of Data Structures
CLASSIFICATION OF DATA STRUCTURES

Data structures are generally categorized into two classes: primitive and non-primitive data
structures.
Primitive and Non-primitive Data Structures
Primitive data structures are the fundamental data types which are supported by a
programming language. Some basic data types are integer, real, character, and boolean. The
terms ‘data type’, ‘basic data type’, and ‘primitive data type’ are often used interchangeably.
Non-primitive data structures are those data structures which are created using primitive
data
structures. Examples of such data structures include linked lists, stacks, trees, and graphs.
Non-primitive data structures can further be classified into two categories: linear and non-
linear data structures.
Linear and Non-linear Structures
If the elements of a data structure are stored in a linear or sequential order, then it is
a linear data structure. Examples include arrays, linked lists, stacks, and queues.
Linear data structures can be represented in memory in two different ways.
One way is to have to a linear relationship between elements by means of sequential
memory locations.
The other way is to have a linear relationship between elements by means of links.
However, if the elements of a data structure are not stored in a sequential order,
then it is a non-linear data structure. The relationship of adjacency is not maintained
between elements of a non-linear data structure. Examples include trees and
graphs.
Example
Example
Examples

Suppose a brokerage firm maintains a file where each record contains a customer’s name and his/her
salesperson as like as given in Fig. 1.4.
However, this may not be the most useful way to store the data.
 An integer used as a pointer requires less space than a name; hence saves space. Using data
representation in Fig. 1.5, the firm would have to search through the entire customer file.
Examples

One way to simplify such a search is to have the


arrows in Fig. 1.5 point the other way; each
salesperson would now have a set of pointers giving
the positions of his or her customers, as in Fig.1.6.

The main disadvantage of this representation is that


each salesperson may have many pointers and the
set of pointers will change as customers are added
and deleted.

Using this representation one can easily obtain the entire list of customers
for a given salesperson as well as one can easily insert and delete
customers.
Stack of dishes
Queue waiting for a Bus
Tree for expression:
OPERATIONS ON DATA STRUCTURES

Traversing It means to access each data item exactly once so that it can be processed. For
example, to print the names of all the students in a class.
Searching It is used to find the location of one or more data items that satisfy the given constraint.
Such a data item may or may not be present in the given collection of data items. For example,
to find the names of all the students who secured 100 marks in mathematics.
Inserting It is used to add new data items to the given list of data items. For example, to add
the details of a new student who has recently joined the course.
Deleting It means to remove (delete) a particular data item from the given collection of data
items. For example, to delete the name of a student who has left the course.
OPERATIONS ON DATA STRUCTURES

Sorting Data items can be arranged in some order like ascending order or descending order
depending on the type of application. For example, arranging the names of students in a class in
an alphabetical order, or calculating the top three winners by arranging the participants’ scores in
descending order and then extracting the top three.
Merging Lists of two sorted data items can be combined to form a single list of sorted data items.
Many a time, two or more operations are applied simultaneously in a given situation. For
example, if we want to delete the details of a student whose name is X, then we first have to
search the list of students to find whether the record of X exists or not and if it exists then at which
location, so that the details can be deleted from that particular location.
Operations
ADT
ADT (CONT.)
Algorithm and Asymptotic Notation
Exercises
1 Abul a. Suppose Daud is to be inserted into the array. How
2 Cefat many names must be moved to new locations.
3 Eunus b. Suppose Goffur is to be deleted from the array. How
4 Goffur many names must be moved to new location?
5 Joinob
6 Lokman
7 Poigum
8 Solomon
Exercises
FIRST

5 index Name Link

1 Robin 7
2 Cefat 8
3
4 Hasan 10
5 Badshah 2
6 Paira 1
7 Walid 0
8 Foysol 4
9
10 Lut 6

FIRST gives the location of the first name in the list and Link[k] gives the location of the
name following Name[k], with 0 denoting the end of the list.

Find the linear ordering of the names.


Exercises
Consider the algebraic expression (7x + y)(5a - b)3.

(a) Draw the corresponding tree diagram .


(b) Find the scope of the exponential operation. (The scope of a node v in a tree is the
subtree consisting of v and the nodes following v)

You might also like