P1 Lec Data Structure

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Data

Structure
Jorge F. Resurreccion

Prepared By
Lesson Overview

Data structures are that important;


they improve our quality of life and
even save lives on a regular basis and
make it easy for us to access and
work with the data we need in
appropriate and organized ways.

Data Structure
Lesson Outline

Area Where
What are Why Do We Types of
Why Data Data
Data Need Data Data
Structure? Structure is
Structures? Structure? Structure
Applied

Data Structure
Intended Learning Outcomes
• Define the meaning of Data Structures
• Explain why we need Data Structures
• Enumerate the different types of Data Structures

Data Structure
What are Data Structures?
• Data structure is a storage that is used to store and
organize data. It is a way of arranging data on a
computer so that it can be accessed and updated
efficiently.
• Data structures are methods of storing and organizing
data in a computer system so that operations can be
performed upon them more efficiently.
• When data is “unstructured,” it does not have a
defined data model or is not organized in a manner
that is conducive to operations or analysis.

Data Structure and Types


Why Data Structure?
• Knowledge about data structures help you understand the
working of each data structure. And, based on that you can
select the right data structures for your project.
• This helps you write memory and time efficient code.
• Data structures take the form of different layouts, each of
which is efficient for some operations but inefficient for
others.
– The goal of the programmer is to determine which data structures are suitable for the data
on hand so that that data can be leveraged to solve problem
• Depending on your requirement and project, it is important
to choose the right data structure for your project.
– For example, if you want to store data sequentially in the memory, then you can go for the
Array data structure

Data Structure and Types


Array Data Structure

Data Structure and Types


Why do we need data structures? https://quescol.com/data-structur e/data -struct ure-needs-types

• Data Structure is an approach of organizing data, storing


data and managing data so that we can access and modify it
efficiently.

– For example, Suppose we have some data of the students of class 4. As we know that every
students have name, age and roll number in general.

– If we consider a student whose name is “Pawan”, age is 17 and he is from class 4. Here
“Pawan” name is of String data, and 17 and 1 is integer data.

– If we have only one the data of single student then it is easy to manage and store. But what
about if we have thousands of students data?

– So for that purpose data structure concept is needed to handle the operations on that large
amount of data.

– Means we have to use array or linked list as per requirement to manage that much data and
perform any desired operation on it efficiently.

Data Structure
Why do we need data structures?
• Data structures are used in every program or software
system to arrange the data.
• Data structures are essential ingredients of many
efficient algorithms. It helps in the management of
huge amounts of data, such as a large integrated
collection of databases.
• Each Data Structure allows data/elements to be
stored in a specific manner in the memory.

Data Structure
Why do we need data structures?
• Data Structure helps in efficient data search and
retrieval.
• For specific problems, specific Data structures are
used.
• Data Structure allows managing a large amount of
data, such as large databases and indexing services
such as a hash table.
• Data structures organized the storage and retrieval of
data and information which is stored in both main
memory and secondary memory.

Data Structure
Area where data structure is applied
• In Numerical analysis
• In Operating System
• In Artificial intelligence
• In Compiler design
• In Statistical analysis package
• In DBMS
• In Simulation
• In Graphics Design

Data Structure
TYPES OF DATA STRUCTURE

9/3/2022
Types of Data Structure
• Data structures are divided into two categories:

✓ Linear data structure


1. Array
2. Stack
3. Queue
4. Linked List

✓ Non-linear data structure


1. Graph
2. Trees

Data Structure and Types


Linear data structures
• It is a type of data structure where the arrangement of the
data follows a linear trend.
• The data elements are arranged linearly such that the
element is directly linked to its previous and the next
elements.
• As the elements are stored linearly, the structure supports
single-level storage of data.
• The elements are arranged in sequence one after the
other.
• Since elements are arranged in particular order, they are
easy to implement.

Data Structure and Types


1. Array Data Structure
• Simply an array, is a data structure consisting of a
collection of elements (values or variables), each
identified by at least one array index or key and are
arranged in continuous memory.
• All the elements of an array are of the same type.

– The type of elements that can be stored in the form of arrays is determined by the
programming language.

Data Structure and Types Linear data structures


2. Stack Data Structure
• A stack is a linear data structure in which all the
insertion and deletion of data or you can say its values
are done at one end only, rather than in the middle.
• Stacks can be implemented by using arrays of type
linear.
• In stack data structure, elements are stored in the
LIFO principle. That is, the last element stored in a
stack will be removed first.

Data Structure and Types Linear data structures


LIFO Principle of Stack
• In programming terms, putting an item on top of the
stack is called push and removing an item is called
pop.

Data Structure and Types Linear data structures


Basic Operations of Stack
• There are some basic operations that allow us to
perform different actions on a stack.
➢Push: Add an element to the top of a stack
➢Pop: Remove an element from the top of a stack
➢IsEmpty: Check if the stack is empty
➢IsFull: Check if the stack is full
➢Peek: Get the value of the top element without
removing it

Data Structure and Types Linear data structures


3. Queue Data Structure
• Unlike stack, the queue data structure works in the
FIFO principle where first element stored in the queue
will be removed first.
• It works just like a queue of people in the ticket
counter where first person on the queue will get the
ticket first.

Data Structure and Types Linear data structures


Queue follows the First In First Out
(FIFO) rule
• the item that goes in first is the item that comes out first.

• In the above image, since 1 was kept in the queue before


2, it is the first to be removed from the queue as well. It
follows the FIFO rule.
• In programming terms, putting items in the queue is called
enqueue, and removing items from the queue is called
dequeue.

Data Structure and Types Linear data structures


Basic Operations of Queue
• A queue is an object (an abstract data structure - ADT)
that allows the following operations:
➢Enqueue: Add an element to the end of the queue
➢Dequeue: Remove an element from the front of the
queue
➢IsEmpty: Check if the queue is empty
➢IsFull: Check if the queue is full
➢Peek: Get the value of the front of the queue without
removing it

Data Structure and Types Linear data structures


4. Linked List Data Structure
• In linked list data structure, data elements are
connected through a series of nodes. And, each node
contains the data items and address to the next node.
• In computer science, a linked list is a linear collection
of data elements whose order is not given by their
physical placement in memory.
• Instead, each element points to the next.
• It is a data structure consisting of a collection of nodes
which together represent a sequence.

Data Structure and Types Linear data structures


Linked list Data Structure
• A linked list is a linear data structure that includes a
series of connected nodes. Here, each node stores the
data and the address of the next node. For example,

Data Structure and Types Linear data structures


END OF SESSION

9/3/2022

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