Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

2_Data structures and Algorithms in problem solving

The lecture focuses on understanding problem solving, the role of computers, and various types of problems in the context of data structures and algorithms. Key concepts include functional, decisional, search, and optimization problems, along with a roadmap for learning about algorithm design and data structures. The course aims to equip students with the ability to implement data structures, solve problems, analyze algorithms, and employ sorting and searching techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

2_Data structures and Algorithms in problem solving

The lecture focuses on understanding problem solving, the role of computers, and various types of problems in the context of data structures and algorithms. Key concepts include functional, decisional, search, and optimization problems, along with a roadmap for learning about algorithm design and data structures. The course aims to equip students with the ability to implement data structures, solve problems, analyze algorithms, and employ sorting and searching techniques.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

19CCE202 Data Structures and Algorithms

LECTURE 2 – DATA STRUCTURES AND ALGORITHMS IN PROBLEM SOLVING

Dr. R. Ramanathan
Associate Professor
Department of Electronics and Communication Engineering
Amrita School of Engineering, Coimbatore
r_ramanathan@cb.amrita.edu
Objective
To understand the concept of problem solving, components of computing and types of
problems; to define the learning road map for the course.

Key concepts
• Problem solving [CO2] CO1: Ability to implement linear and
• Role of computers in problem solving [CO2] non-linear data structure operations in C
• Components of computing [CO2] / Python
• Types of problems CO2: Ability to solve problems using
– Functional problems [CO4] appropriate data structures
– Decisional problems [CO4] CO3: Ability to analyze the algorithms
and its complexity
– Search problems [CO3]
CO4: Ability to employ sorting and
– Optimization problems [CO3] searching algorithms using relevant data
• Roadmap structures
Problem solving & role of computers

“Data Structures and Algorithms”


• is one of the classic, core topics of
Computer Science /
Computational Engineering.
• are central to the development of
good quality computer programs.

A computer is a machine that can perform computation. It is difficult to give a precise


definition of computation. Intuitively, a computation involves the following three
components,
1. Input: The user gives a set of input data.
2. Processing: The input data is processed by a well-defined and finite sequence of
steps.
3. Output: Some data available from the processing step are output to the user
A set of arguments (a1,a2,...,an) constitute the input. Some
function f(a1,a2,...,an) of the arguments is calculated and
Functional Problems output to the user.
Example 1: Polynomial root finding
Input: A polynomial with real coefficients
Output: One (or all) real roots of the input polynomial
Processing: Usually, one involves a numerical method (like the Newton-Raphson method) for computing the
real roots of a polynomial.
Example 2: Matrix inversion
Input: A square matrix with rational entries
Output: The inverse of the input matrix if it is invertible, or "failure"
Processing: Gaussian elimination is a widely used method for matrix inversion.
Example 3: Weather prediction
Input: Records of weather for previous days and years. Possibly also data from satellites.
Output: Expected weather of Coimbatore for tomorrow
Processing: One statistically processes and analyzes the available data and makes an educated extrapolating
guess for tomorrow's weather
Example: Primality testing
Input: A positive integer
Decisional Problems
Output: The decision whether the input integer is prime or not
These form a special class of Processing: For checking the primality of n, it is an obvious
strategy to divide n by integers between 2 and square root of n.
functional problems whose
If a divisor of n is found, n is declared "composite" ("no"), else n
outputs are "yes" and "no" (or is declared "prime" ("yes").
"true" and "false", or "1" and
"0", etc).
Example: Chess : Can I win?
Search Problems Input: A configuration of the standard 8x8 chess board and the
Player ("white" or "black") who is going to move next
Given an input object, one tries
to locate some particular Output: A winning move for the next player, if existent, or
"failure"
configuration pertaining to the
Processing: In general, finding a winning chess move from a
object and outputs the located
given state is a very difficult problem.
configuration, or "failure" if no The trouble is that one may have to explore an infinite number of
configuration can be located. possibilities. Even when the total possibilities are finite in
number, that number is so big that one cannot expect to complete
exploration of all of these possibilities in a reasonable time.
A more practical strategy is to investigate all possible board
sequences involving a small number of moves starting from the
given configuration and to identify the best sequence under some
criterion and finally prescribe the first move in the best
sequence.
Optimization Example: Traveling salesman
Problems problem (TSP)
Input: A set of cities, the cost of traveling between each pair of
Given an object, a cities, and the criterion of cost minimization
configuration and a criterion Output: A route through all the cities with each city visited only
for goodness, one finds and once and with the total cost of travel as small as possible
reports the configuration Processing: Since the total number of feasible routes for n cities
is n!, a finite quantity, checking all routes to find the minimum is
pertaining to the object, that is definitely a strategy to solve the TSP.
best with respect to the However, n! grows very rapidly with n, and this brute-force
goodness criterion. If no such search is impractical.
configuration is found, We do not know efficient solutions for the TSP.
"failure" is to be reported. One may, however, plan to remain happy with a suboptimal
solution in which the total cost is not the smallest possible, but
close to it.
Roadmap

 key ideas involved in designing algorithms.


 the design of suitable data structures, and how some structures and algorithms are more
efficient than others for the same task.
 few basic tasks, such as storing, sorting and searching data, that underlie much of
computer science.
 some key data structures / ADTs, such as arrays, lists, queues, stacks and trees
 explore their use in a range of different searching and sorting algorithms.
 investigate the computational efficiency of the algorithms we develop, and gain intuitions
about the pros and cons of the various potential approaches for each task.

You might also like