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

Intro to Data Structure and Ag (3)

The document provides an overview of data structures and algorithms, emphasizing their importance in programming for solving complex problems. It defines data structures as organized ways to store data and algorithms as step-by-step procedures for problem-solving. Additionally, it discusses various types of data structures, their features, and the characteristics of effective algorithms.

Uploaded by

kellykelokorie
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Intro to Data Structure and Ag (3)

The document provides an overview of data structures and algorithms, emphasizing their importance in programming for solving complex problems. It defines data structures as organized ways to store data and algorithms as step-by-step procedures for problem-solving. Additionally, it discusses various types of data structures, their features, and the characteristics of effective algorithms.

Uploaded by

kellykelokorie
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Data Structures and Algorithms

Overview
Types of data structures

Operations on data structures

Algorithms Design Techniques


Course Information

 Introduction to Data Structures and Algorithms


Public university in Mumbai, India.
https://mu.ac.in/wp-content/uploads/2021
 Data Structures and Algorithms
by A. V. Aho, J. E. Hopcroft, J. D. Ullman
 Understanding Data Structures and
Algorithms - by Tope Adamson
 Algorithms in Computer Science. Study Smart
Center
Overview

 Asa programmer, no matter what programming


language you are working with, data structures
and algorithms have to be an important aspect of
your day-to-day programming. That’s because we
always need them to solve complex problems.
 EVERYTHING IS DATA

 Why use programing language?


 To process the data

 Why use database?


 To store the data

 Why use AI?


 To generate data or to understand data
What are Data Structures and
Algorithms?
 Data structures and algorithms go hand in
hand. You may have a set of data arranged in
a certain structure which you then pass into
an algorithm to execute in a certain way but
data structures and algorithms are not the
same things. So let’s look at them separately.
BASIC CONCEPT OF DATA
STRUCTURE
 Thestudy of data structure helps you to
understand how data is organized and how data
flow is managed to increase efficiency of any
process or program.
What is a Data
Structure?
What is a Data Structure?
A data structure is a particular way data is arranged so
it can be saved in memory and retrieved for later use.

 Incomputer science, a data structure is a way of storing data in a


computer so that it can be used efficiently.

 Data structure is the structural representation of logical relationship


between data elements. This means that a data structure organizes
data items based on the relationship between the data elements.
Example: A house
Basic Terminology

 Following terminology is used as far as data


structures are concerned
 Data
 Group Items
 Record
 File
 Attribute and Entity
 Field
 Examples of Data Structures
 Datacan be anything that can be saved. It
could be primitive types like string, boolean,
integer, or float. Or non-primitive types like
arrays, linked list trees, stacks, and queues.
Need for Data Structure
 It gives different level of organization data.
 It tells how data can be stored and accessed
in its elementary level.
 Provide operation on group of data, such as
adding an item, looking up highest priority
item.
 Provide a means to manage huge amount of
data efficiently.
 Provide fast searching and sorting of data
Goals of Data Structure
 Data structure basically implements two
complementary goals.
 Correctness: Data structure is designed such that
it operates correctly for all kinds of input, which is
based on the domain of interest. In other words,
correctness forms the primary goal of data
structure, which always depends on the specific
problems that the data structure is intended to
solve.
 Efficiency: Data structure also needs to be
efficient. It should process the data at high
speed without utilizing much of the computer
resources such as memory space. In a real time
state, the efficiency of a data structure is an
important factor that determines the success
and failure of the process.
Features of Data Structure

 Some of the important features of data structures


are:
 Robustness:Generally, all computer programmers
wish to produce software that generates correct
output for every possible input provided to it, as
well as execute efficiently on all hardware
platforms.
This kind of robust software must be able to
manage both valid and invalid inputs.
 Adaptability: Developing software projects
such as word processors, Web browsers and
Internet search engine involves large software
systems that work or execute correctly and
efficiently for many years. Moreover, software
evolves due to ever changing market
conditions or due to emerging technologies
 Reusability: Reusability and adaptability go
hand-in-hand.
It is a known fact that the programmer requires
many resources for developing any software,
which makes it an expensive enterprise. However,
if the software is developed in a reusable and
adaptable way, then it can be implemented in
most of the future applications. Thus, by
implementing quality data structures, it is possible
to develop reusable software, which tends to be
cost effective and time saving.
CLASSIFICATION OF DATA STRUCTURES

A data structure provides a structured set of


variables that are associated with each other in
different ways. It forms a basis of programming
tool that represents the relationship between
data elements and helps programmers to
process the data easily.
Data structure can be classified into two
categories:
1 Primitive data structure
2 Non-primitive data structure
Linear Data Structure

A data structure that maintains a linear


relationship among its elements is called a
linear data structure. Here, the data is
arranged in a linear fashion. But in the
memory, the arrangement may not be
sequential.
 Ex: Arrays, linked lists, stacks, queues.
Non-linear Data Structure
 Non-linear data structure is a kind of data
structure in which data elements are not
arranged in a sequential order. There is a
hierarchical relationship between individual data
items. Here, the insertion and deletion of data is
not possible in a linear fashion.
 Treesand graphs are examples of non-linear
data structures
ALGORITHM
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. Algorithms
are generally created independent of underlying
languages, i.e. an algorithm can be implemented
in more than one programming language.
 Inprogramming, an algorithm is a set of
steps for solving a known problem. The
problems solved by an algorithm could be
sorting a set of data, searching through
available data, or even encrypting data.
The study of algorithm involves three major parts
 Designing the algorithm
 Proving the correctness of the algorithm
 Analyzing the algorithm

The analysis of algorithms deals with the amount of time


and space consumed by it. Efficient algorithms can be
computed with minimum requirement of time and space.
Practically, time and space complexity can???
Types of Algorithms

 There are a number of types of algorithms


available today. There’s no particular way the
types are characterized, but there are broad
categories like sorting and searching
algorithms.
 Examples of sorting algorithms are merge
sort, bubble sort, selection sort, and others.
And examples of searching algorithms are
exponential search, binary search, jump
search, and others.

 From the data structure point of view, following
are some important categories of
 algorithms −
 Search − Algorithm to search an item in a data
structure.
 Sort − Algorithm to sort items in a certain order.
 Insert − Algorithm to insert item in a data
structure.
 Update − Algorithm to update an existing item
in a data structure.
 Delete − Algorithm to delete an existing item
Characteristics of an Algorithm
 An algorithm should have the following
characteristics −
 Clear and Unambiguous: Algorithm should
be clear and unambiguous. Each of its
steps should be clear in all aspects and
must lead to only one meaning.
 Well-Defined Inputs: If an algorithm says to
take inputs, it should be well defined
inputs.
 Not all procedures can be called an
algorithm. An algorithm should have the
following characteristics −
 Well-Defined Outputs: The algorithm must
clearly define what output will be yielded
and it should be well-defined as well.
 Finite-ness: The algorithm must be finite,
i.e. it should not end up in an infinite
loops or similar.
 Feasible: The algorithm must be simple, generic
and practical, such that it can be executed upon
will the available resources. It must not contain
some future
technology, or anything.
 Language Independent: The Algorithm designed
must be language independent, i.e. it must be
just plain instructions that can be implemented
in any
language, and yet the output will be same, as
expected.
Advantages and Disadvantages of
Algorithm

Advantages of Algorithms:
 It is easy to understand.
 Algorithm is a step-wise representation of a
solution to a given problem.
 In Algorithm the problem is broken down
into smaller pieces or steps hence, it is
easier for the programmer to convert it into
an actual program.
Disadvantages of Algorithms

 Writing an algorithm takes a long time


so it is time-consuming.
 Branching and Looping statements are
difficult to show in Algorithms.
Different approach to design an
algorithm
 1.Top-Down Approach: A top-down
approach starts with identifying major
components of system or program
decomposing them into their lower level
components & iterating until desired level of
module complexity is achieved . In this we
start with topmost module & incrementally
add modules that is calls.
 2.Bottom-Up Approach: A bottom-up
approach starts with designing most basic
or primitive component & proceeds to
higher level components. Starting from very
bottom , operations that provide layer of
abstraction are implemented
How to Write an Algorithm?

 There are no well-defined standards for writing


algorithms. Rather, it is problem and resource
dependent. Algorithms are never written to support
a particular programming code. As we know that all
programming languages share basic code constructs
like loops (do, for, while), flow-control (if-else), etc.
These common constructs can be used to write an
algorithm
 We write algorithms in a step-by-step manner,
but it is not always the case. Algorithm writing is
a process and is executed after the problem
domain is well-defined. That is, we should know
the problem domain, for which we are designing
a solution.
Properties /Characteristics of an
Algorithm
 Algorithm has the following basic properties
 Input-Output:- Algorithm takes ‘0’ or more input
and produces the required output.
 This is the basic characteristic of an algorithm.
 Finiteness:- An algorithm must terminate in
countable number of steps.
 Definiteness: Each step of an algorithm must
be stated clearly and unambiguously.
 Effectiveness: Each and every step in an
algorithm can be converted in to
programming language statement.
 We write algorithms in a step-by-step
manner, but it is not always the case.
Algorithm writing is a process and is
executed after the problem domain is well-
defined. That is, we should know the problem
domain, for which we are designing a
solution.
Example
 Let's
try to learn algorithm-writing by using an
example.
 Problem
− Design an algorithm to add two
numbers and display the result.

You might also like