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

Basic Concepts of Data Structures

The document provides an overview of data structures, including their definitions, classifications, and the importance of organizing data efficiently. It distinguishes between primitive and non-primitive data structures, explaining linear structures like arrays, linked lists, stacks, and queues, as well as non-linear structures like graphs and trees. Additionally, it covers algorithms, their characteristics, and the significance of designing algorithms for problem-solving.

Uploaded by

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

Basic Concepts of Data Structures

The document provides an overview of data structures, including their definitions, classifications, and the importance of organizing data efficiently. It distinguishes between primitive and non-primitive data structures, explaining linear structures like arrays, linked lists, stacks, and queues, as well as non-linear structures like graphs and trees. Additionally, it covers algorithms, their characteristics, and the significance of designing algorithms for problem-solving.

Uploaded by

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

Basic Concepts of Data

Structures
Data Structure

Branch of Computer Science

Structural representation of logical


relationship between data elements
Hierarchy of Data

Data

Record

File

Database
Other Terminology
➢Group Items - Data items which have
subordinate data items are called Group
item
➢Attribute and Entity - An entity represents
the class of certain objects. it contains
➢various attributes. Each attribute
represents the particular property of that
entity
Why do we need Data
Structure?
• It gives different level of organizing data
• It explains how data can be stored and
accessed
• It provides operation on group of data,
such as adding an item, inserting an item,
sorting items, deleting an item, and
updating items
Why do we need Data
Structure?
• It provides a mean to manage huge
amount of data efficiently
• It provides fast searching and sorting
a data
Goals of Data Structure

Correctness Time Space


Complexity Complexity

Figure 1. Goals of Data Structure


Classification of Data Structures

Figure 2. Classification of Data Structure


Primitive Data Structure
• Primitive data structures consist of the
numbers and the characters which are built in
programs. These can be manipulated or
operated directly by the machine level
instructions. Basic data types such as integer,
real, character, and Boolean come under
primitive data structures. These data types are
also known as simple data types because
they consist of characters that cannot be
divided
Non-Primitive
• Non-primitive data structures are those
that are derived from primitive data
structures. These data structures cannot
be operated or manipulated directly by the
machine level instructions. They focus on
formation of a set of data elements that is
either homogeneous (same data type) or
heterogeneous (different data type).
Non-Primitive: Linear Data Structure

• A data structure that maintains a linear


relationship among its elements is called a
linear data structure. The data is arranged
in a linear. But in the memory, the
arrangement may not be sequential.
Linear: Arrays
• Array, in general, refers to an orderly
arrangement of data elements. Array is a
type of data structure that stores data
elements in adjacent locations. Array is
considered as linear data structure that
stores elements of same data types.
Hence, it is also called as a linear
homogenous data structure
Example
int Num [5] = { 26, 7, 67, 50, 66 };

0 1 2 3 4
Num 26 7 67 50 66

Figure 3. One-dimensional array


Classification of Arrays
• One-dimensional Array: It has only one row of
elements. It is stored in ascending storage
location.
• Two-dimensional Array: It consists of multiple
rows and columns of data elements. It is also
called as a matrix.
• Multidimensional Array: Multidimensional arrays
can be defined as array of arrays.
Multidimensional arrays are not bounded to two
indices or two dimensions. They can include as
many indices as required.
Arrays

Advantages Disadvantages
Linear: Linked-list
• A linked list is a data structure in which
each data element contains a pointer or
link to the next element in the list. Through
linked list, insertion and deletion of the data
element is possible at all places of a linear
list. Also in linked list, it is not necessary to
have the data elements stored in
consecutive locations. It allocates space for
each data item in its own block of memory.
Linear: Linked-list
• Thus, a linked list is considered as a chain
of data elements or records called nodes.
Each node in the list contains information
field and a pointer field. The information
field contains the actual data and the
pointer field contains address of the
subsequent nodes in the list
Linear: Linked-list

Figure 4. Singly Linked-lists


Linked-lists

Advantages Disadvantages
Linear: Stacks
• A stack is a linear data structure in which
insertion and deletion of elements are
done at only one end, which is known as
the top of the stack. Stack is called a last-
in, first-out (LIFO) structure because the
last element which is added to the stack is
the first element which is deleted from the
stack.
Linear: Stacks

Figure 5. Stacks
Stacks

Advantages Disadvantages
Linear: Queues
• A queue is a first-in, first-out (FIFO) data
structure in which the element that is
• inserted first is the first one to be taken
out. The elements in a queue are added at
one end called the rear and removed from
the other end called the front. Like stacks,
queues can be implemented by using
either arrays or linked lists
Linear: Queues

Figure 6. A Queue
Non-linear: Graphs
• A graph is also a non-linear data structure.
In a tree data structure, all data elements
are stored in definite hierarchical structure.
In other words, each node has only one
parent node. While in graphs, each data
element is called a vertex and is
connected to many other vertexes through
connections called edges
Non-linear: Graphs

Figure 7. A Graph
Non-linear: Trees
• A tree is a non-linear
data structure in which
data is organized in
branches. The data
elements in tree are
arranged in a sorted
order. It imposes a
Figure 8. A Tree
hierarchical structure on
the data elements.
Static or Dynamic Data Structure

Static Dynamic

• Fixed • Size of
• No changes in structure is not
memory space fixed
• Change of
data structures
in runtime
Operations in Data Structures

Traversing Searching Inserting

Deleting Sorting Merging


Algorithm
What is Algorithm?
• Algorithm is a step-by-step procedure,
which defines a set of instructions to be
executed in a certain order to get the
desired output
Characteristics
• Clear and unambiguous
• Well-defined Input/Output
• Finite
• Feasible
• Language-independent
Different Approach

• Top-down
• Bottom-up
Algorithm Complexity

Space Time
Complexity Complexity
Example Algorithm
Step 1 − START
Step 2 − Declare three integers a, b and c
Step 3 − Define values of a and b
Step 4 − Add values of a and b
Step 5 − Store output of step 4 to c
Step 6 − Print c
Step 7 − STOP
Algorithm that computes two
integer values a and b
Step 1 − START Step 1 – START
Step 2 − Declare three Step 2 - Declare three
integers a, b and c
integers a, b and c
Step 3 − Define values of
a and b Step 3 - Define values
Step 4 − Add values of a
of a and b
and b Step 4 – c a+b
Step 5 − Store output of Step 5 –Print c
step 4 to c
Step 6 - STOP
Step 6 − Print c
Step 7 − STOP
Why to design an algorithm?

Solution1

Solution 2 Problem Solution 3

Solution 4
Example 1
• Solve for the area of a rectangle?

What to
choose?
ALGORITHM ALGORITHM
1 2
Try this!
• Create a Python program that
computes the area of a circle
Practice Problem
• Design an algorithm and the
corresponding flowchart for adding the test
scores as given below if the number is
even:
26,49,98,87,62,75
• Translate the algorithm to a Python
program (using Google Colab)
• Save your source codes to GitHub
REFERENCE
• S, Gowrishankar; A, Veena (2019)
Introduction to Python Programming
• Soltys, Michael (2018) An introduction to
the analysis of algorithms

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