UNIT 3.pptx-Data Structures definition with examples

Papitha7 23 views 31 slides Oct 10, 2024
Slide 1
Slide 1 of 31
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31

About This Presentation

Data structures are the fundamental building blocks of computer programming. They define how data is organized, stored, and manipulated within a program. Understanding data structures is very important for developing efficient and effective algorithms.

In this tutorial, we will explore the most com...


Slide Content

DATUM DATA SINGLE VALUE singular of data MULTIPLE VALUE Plural of datum /data

Basic Terminologies DATA : Data are simply values or sets of values DATA ITEMS : Data items refers to a single unit of values Group items : Data item divided into sub-items Ex: Name divided into three - first name, middle name and last name Elementary items : Data items that are not able to divide into sub-items Ex: PAN Number , Bank account number etc….

DATA TYPE : Kind of data that may appear in computation Ex: In C - int , float, char, double, long double, Boolean ,etc. a=2 ……… integer data type b=3.5 ……. Floating data type c=a ………… character data type VARIABLE: Variable is a symbolic name given to the value/ data a=2 ……… a - is a variable name for a data

ENTITY : Something that has certain attributes ( additional information about entity ) or properties which may be assigned values. Ex: Employee of an organization, Attributes of Employee  Name = John ,Age=23, Gender = Male, Employee No= 33 ENTITY SET : Entity with similar attributes ( e.g all employees of an organization ) RECORD : Collection of field values of a given entity Name Age Gender Employee No John 23 Male 33 Babu 25 Male 34 chitra 22 Female 35

FIELD: Is a single elementary unit of information representing an attribute of an entity field value FILE : Collection of records of the entities in a given entity set Classification of Records : According to length 1. Fixed-length records : Records contain the same data items with same amount of space assigned to each data item 2.Variable-length records: file records with different length Name Age Gender Employee No John 23 Male 33 Babu 25 Male 34 chitra 22 Female 35

Data Structures-Definition Data structure is the organization of the data in a way so that it can be used Efficiently

TYPE OF DATA STRUCTURE

Primitive Data Types Each variable has a specific data type It tells -  size, range  and the  type  of a value that can be stored in a variable There are 4 basic primitive data types integer  data types, such as short, int , long floating-point  data types, such as float, double character  data type, such as char Pointer

Integer data type allows a variable to store numeric values The storage size of integer is 2 byte, Ex: a=2 Character data type allows a variable to store only one character Storage size of character data type is 1 byte, Ex: a=g Float data type allows a variable to store decimal values Storage size of float data type is 4, Ex: a=2.34

Pointer : Special type of variables that are used to store address of another variable rather than values This variable can be of type int , char or any other  pointer

Non- Primitive Data Types

Based on arrangement , Classification of data structure are Linear Data structures Non-Linear Data structures Linear Data structures : Arranging the elements in Linear fashion Ex: Stacks , Queue and Lists Non-Linear Data structures: Representing the elements in Hierarchical order. Ex: Trees ,Graphs

Linear Data structures : Arranging the elements in sequence fashion Ex: Name of the students Non-Linear Data structures: Representing the elements in Hierarchical order. Ex: Trees ,Graphs Anu Abirami Arun Babu Balaji Gowtham

Linear Data structures

Array- kind of data structure that can store a fixed-size sequential collection of elements of the same type Consider array size 9

LIST Linear data structure, Where each node connected together via links –pointer But data are not stored at contiguous memory locations

Based on Characteristic , Classification of data structure are Static data structure : size of the structure is fixed The content of the data structure can be modified but without changing the memory space allocated to it Ex : Array size of array is 5 Dynamic data structure : size of the structure in not fixed Can be modified during the operations performed on it Designed to facilitate change of data structures in the run time Ex: List 1 2 3 4 5

DIFFERENCE BETWEEN ARRAY AND LINKED LIST Arrays   linked list Size of any array is fixed Size of a list is variable It is necessary to specify size of array during declaration It is not necessary to specify size of list during declaration Process of Insertion and deletions is difficult Process of Insertion and deletions is easy It occupies less memory than a linked list  It occupies more memory –because it store additional address field for each data

STACK Stack is an ordered collection of elements Insertions and deletions are restricted to one end called top

QUEUE Queue is an ordered collection of elements Insertions and deletions are restricted to one end data are added - rear end [last],deleted - front end [first]

Non-Linear Data structures

TREE A tree is a non-linear data structure Which represents hierarchical relationship between individual data items

GRAPH A graph is a non-linear data structure Data represents less relationship between its adjacent elements. There is no hierarchical relationship between the adjacent elements in case of graphs

Data Structure Operations

Abstract Data Type An ADT is a collection of data and  associated operations for manipulating that data It not shows the Implementation part

Basic Operations on Data Structures Creation – Creating a new DS Insertion   − Add a new data in the existing DS Deletion  − Delete an existing data item from the DS Traversal  − Access each data item exactly once so that it can be processed Searching  − Find out the location of the data item if it exists in the DS Sorting  − Arranging the data items in some order

Merging: Combining the data items of two files into single file Updation : Updating the current value in the DS with some new value  isEmpty ( ): It tests whether the DS is empty isFull ( ): It tests whether the Memory is Full isFirst ( ): It returns first element of the data structures isLast ( ): It returns last element of the data structures

Analysis of an Algorithm

Efficiency Efficiency of DS is always measured in terms of TIME and SPACE An ideal DS that takes least possible running time and consumes least memory space
Tags