Week 1 - Introduction To Data Structure and Algorithms
Week 1 - Introduction To Data Structure and Algorithms
and Algorithms
1. Introduction to DSA
1.1 Data structure
A data structure is a way to store and organize data in order to facilitate access and
modifications so that we can perform operations on these data in an effective way. No single
data structure works well for all purposes, and so it is important to know the strengths and
limitations of several of them.
Example: A list of numbers, a list of nodes, …
1.2 Types of data structures
There are 2 main types of data structures: Primitive (Built-in) data structures and Non-
primitive Data Structures (User Defined Data Structures)
- Primitive data Structures are also called Primitive Data Types. byte, short, int, float,
char, boolean, long, and double are primitive Data types And the set of operations that
can be performed on these data are also predefined: addition, subtraction, division,
multiplication, …
- Non-primitive data Structures can be divided into two types:
- The elements arranged in a linear fashion are called Linear Data Structures.
Here, each element is connected to one other element only. Linear Data
Structures are as follows: String (in fact, String will be stored as an array of
chars so it is linear), Arrays, Single dimensional Array, Multidimensional
Array, Stack, Queue, Linked List, Singly-linked list, Doubly Linked list,
Circular Linked List.
- The elements arranged in a non-linear fashion are called Non-Linear Data
Structures. Here, each element is connected to n-other elements. Non-Linear
Data Structures are as follows: Trees, Binary Tree, Binary Search Tree, AVL
Tree, Red-Black Tree, Graph, Heap, MaxHeap, MinHeap, Hash, HashSet,
HashMap.
Types of Data Structures
1.2 Algorithm
Informally, an algorithm is any well-defined computational procedure that takes some value,
or set of values, as input and produces some value, or set of values, as output or An algorithm
is thus a sequence of computational steps that transform the input into the output.
The algorithm is not the complete code or program, it is just the core logic of a problem so a
computer program is an instance or concrete representation, for an algorithm in some
programming language.
An algorithm possesses the following properties:
• It must be correct (An algorithm is said to be correct if, for every input instance, it halts
with the correct output.).
• It must be composed of precisely defined steps.
• The order of the steps must be precisely defined.
• It must be composed of a finite number of steps.
• It must terminate for all inputs.