You are on page 1of 30

Data Structures

and Algorithms
Introduction
What is Data?
What is Data?
“…data is a collection of discrete values that
convey information, describing quantity,
quality, fact, statistics, other basic units of
meaning, or simply sequences of symbols
that may be further interpreted…”
What is Data Type?
What is Data Type?

“…data type is a set of possible values and a


set of allowed operations on it...”

Has 2 Types
1. Primitive
2. Composite/Derived
Primitive Data Types
+A basic data type
+Character
+Integer
+Floating-Point Number
+Fixed-Point Number
Composite Data Types
+Array
+Pointers
+Structures
+Unions
+String
Heap vs. Stack
Introduction to Data Structures
Stack vs. Heap
STACK

SUM = 80.89
I = 10
Heap
STACK HEAP

Pointer to “Hello World”


“Hello
SUM = 80.89
World"
I = 10
Data Structures
Definition, Characteristics, and Examples
What is Data Structure?
Defines how we store, organize, and manages data.
Characteristics of Data Structures
+Linear or Non-Linear
+Static and Dynamic
+Time Complexity
+Correctness
+Space Complexity
Linear Data Structures

ARRAY LINKED LIST QUEUE STACK


Non-Linear Data Structures

TREE GRAPH
Looking in to Arrays
Array
A collection of elements – (usually a collection of
elements with the same type, depending on the
language used)
Example on a String
A String
Is a collection/sequence of characters.

“Hello World!”
A String

H E L L O W O R L D !
0 1 2 3 4 5 6 7 8 9 10 11
Example
Array/List
- Collection of elements

fruits = [ “Apple”, “Banana”, “Cherries”, “Dragon Fruit”, … ]


INDEX 0 1 2 3

VALUE Apple Banana Cherries Dragon Fruit


What is an Algorithm?
+An algorithm is a set of well-defined calculations and
instructions to be processed and executed by computers
Example

INDEX 0 1 2 3

VALUE Cherries Dragon Fruit Apple Banana

INDEX 0 1 2 3

VALUE Apple Banana Cherries Dragon Fruit


Sorting Algorithm
+Is an algorithm used to re-arrange items in a list according to a
comparison operator used in each element
Other Data Types
Linked-List
+A linear collection of elements, where nodes have values

apple banana cherries


Record
+Also known as tuple or struct. Record is a data structure that
contains values that contains another values. Mostly these
values are indexed with names.

struct {
int day;
int month;
int year;
}
Object
Can be a variable, function, method, etc. Mostly used in Object-
Oriented Paradigm and defined by use of keyword class (in
most programming languages)

class person:
name: string = “”

def __init__(self):
pass
Data Structures are used for…

Managing
Storing Data Resources and Data Exchange
Services

Ordering and
Indexing Scalability
Sorting
Choosing Data Structure

Supported Computational Programming


Operations Complexity Elegance

You might also like