You are on page 1of 16

Data Structures and Algorithm Overview

(Week 1 Part 1)
What is Data Structure?
• Data structures deal with how the data is
organized and held in the memory when a
program processes it.
• In programming, we use data structures to
store and organize data, and we use
algorithms to manipulate the data in those
structures.
• DS refers to a scheme for organizing data, or in
other words a data structure is an
arrangement of data in computer's memory in
such a way that it could make the data quickly
available to the processor for required
calculations.
• A data structure should be seen as a logical
concept that must address two fundamental
concerns.
• First, how the data will be stored, and
• Second, what operations will be performed on
it?
• data structures are actually an
implementation of Abstract Data Types or
ADT.
• This implementation requires a physical view
of data using some collection of programming
constructs and basic data types.
Characteristics of Data Structures
• data structures can be divided into two
categories in computer science: primitive and
non-primitive data structures.
• The former are the simplest forms of
representing data, whereas the latter are
more advanced: they contain the primitive
data structures within more complex data
structures for special purposes.
Overview of Data Structures
Primitive Data Structures
• These are the most primitive or the basic data
structures. They are the building blocks for data
manipulation and contain pure, simple values of
a data. Python has four primitive variable types:
• Integers
• Float
• Strings
• Boolean
• Integers
You can use an integer represent numeric
data, and more specifically, whole numbers from
negative infinity to infinity, like 4, 5, or -1.
• Float
"Float" stands for 'floating point number'. You
can use it for rational numbers, usually ending
with a decimal figure, such as 1.11 or 3.14
Characteristics of Data Structures
Data Structure Advantages Disadvantages
Array Quick inserts Slow search
Fast access if index known Slow deletes
Fixed size
Ordered Array Faster search than unsorted Slow inserts
array Slow deletes
Fixed size
Stack Last-in, first-out access Slow access to other items
Queue First-in, first-out access Slow access to other items
Linked List Quick inserts Slow search
Quick deletes
Binary Tree Quick search Deletion algorithm is complex
Quick inserts
Quick deletes
(If the tree remains balanced)
Data Structure Advantages Disadvantages

Red-Black Tree Quick search Complex to implement


Quick inserts
Quick deletes
(Tree always remains balanced)
2-3-4 Tree Quick search Complex to implement
Quick inserts
Quick deletes
(Tree always remains balanced)
(Similar trees good for disk storage)

Hash Table Very fast access if key is known Slow deletes


Quick inserts Access slow if key is not known
Inefficient memory usage
Heap Quick inserts Slow access to other items
Quick deletes
Access to largest item
Graph Best models real-world situationsSome algorithms are slow and very
complex
NOTE: The data structures shown above (with the exception of the array) can be thought of as 
Abstract Data Types (ADTs).

A Part Of Thiyagaraaj Websites


Array
Stack
Queue
What is Algorithm?
• An Algorithm is step by step set of instruction
to process the data for a specific purpose.
• In programming, algorithms are implemented
in form of methods or functions or routines. To
get a problem solved we not only want
algorithm but also an efficient algorithm. One
criteria of efficiency is time taken by the
algorithm, another could be the memory it
takes at run time.
• Sometimes, we can have more than one algorithm for the same
problem to process a data structure, and we have to choose the best
one among available algorithms.
• This is done by algorithm analysis. The best algorithm is the one which
has a fine balance between time taken and memory consumption.
• But, as we know the best exists rarely, and we generally give more
priority to the time taken by the algorithm rather than the memory it
consumes.
• Also, as memory is getting cheaper and computers have more
memory today than previous time, therefore, run time analysis
becomes more significant than memory. The analysis of algorithms is
an entirely separate topic and we will discuss that separately.

You might also like