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

DSA1 - Introduction - JVM

Uploaded by

2022bin003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

DSA1 - Introduction - JVM

Uploaded by

2022bin003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

DSA - Introduction

Compiled presentation by – Dr. J. V. Megha


Data Structure
🠶 Data Structure is a way of collecting and organizing data in such a
way that we can perform operations on these data in an effective
way.

🠶 Data Structures is about rendering data elements in terms of some


relationship, for better organization and storage.

🠶 They are the structures programmed to store ordered data, so that


various operations can be performed on it easily. It represents the
knowledge of data to be organized in memory.

🠶 It should be designed and implemented in such a way that it reduces


the complexity and increases the efficiency.
Data Structure
🠶 In real life applications, various kind of data other than the primitive
data are involved.

🠶 Manipulation of real-life data (user data) requires the following essential


tasks:

🠶 Storage representation of user data: User data should be stored in such


a way that computer can understand.

🠶 Retrieval of stored data: Data stored in a computer should be retrieved in


such a way that user can understand.

🠶 Transformation of user data: Various operations which require to be


performed on user data so that it can be transformed from on form to
another.
Characteristics of a data structure

🠶 Correctness: Data structure implementation should implement its


interface correctly.

🠶 Time Complexity: Running time or the execution time of the


operations of data structure must be as small as possible.

🠶 Space Complexity: Memory usage of a data structure operation


should be as little as possible.
Need for data structure

🠶 As applications are getting complex and data rich, there are three common problems
that applications face now-a-days.

🠶 Data search – As the data grows, the search will become slower. Consider an inventory of 1
million items of a store. If the application need to search an item, it has to search an item in 1
million items every time slowing down the search.

🠶 Processor speed – Processor speed although very high, falls limited if the data grows to
billion records.

🠶 Multiple Requests – As thousands of users can search data simultaneously on a web server,
even the fast server fails while searching the data.

🠶 To solve the above-mentioned problems, data structures come to rescue. Data can be
organized in a data structure in such a way that all items may not be required to be
searched, and the required data can be searched almost instantly.
Classification of data structures
🠶 Classic data structure:
🠶 Linear data structure:
🠶 Arrays
🠶 Linked list
🠶 Stack
🠶 Queues

🠶 Non-linear data structure:


🠶 Tree
🠶 Graph
🠶 Tables
🠶 Sets
Linear Vs Non-linear data structures

Linear data structures Non-linear data structures


The data items are arranged in sequential
order, one after the other
All the items are present on the single
layer
It can be traversed on a single run. That
is, if we start from the first element, we
can traverse all the elements sequentially
in a single pass
The memory utilization is not efficient
The time complexity increases with the
data size.
Linear Vs Non-linear data structures

Linear data structures Non-linear data structures


The data items are arranged in sequential The data items are arranged in non-
order, one after the other sequential order (hierarchical manner).
All the items are present on the single The data items are present at different
layer layers.
It can be traversed on a single run. That It requires multiple runs, That is, if we
is, if we start from the first element, we start from the first element it might not be
can traverse all the elements sequentially possible to traverse all the elements in a
in a single pass single pass.
Different structures utilize memory in
The memory utilization is not efficient different efficient ways depending on the
need.
The time complexity increases with the
Time complexity remains the same.
data size.
What is an Algorithm
🠶 In computer programming terms, an algorithm is a set of step-by-step well-
defined instructions to solve a particular problem. It takes a set of input(s)
and produces the desired output.
🠶 High level and language independent instructions
🠶 Each instruction must be clear
🠶 Finite number of instructions
🠶 For example:
🠶 An algorithm to add two numbers:
🠶 Take two numbers
🠶 Add two numbers using the + operator
🠶 Display the result

🠶 Good algorithm: Efficient algorithm issues


🠶 Time required to complete operations (operational efficiency)
🠶 Space needed
Qualities of a Good Algorithm
🠶 Input and output should be defined precisely.
🠶 Each step in the algorithm should be clear and unambiguous.
🠶 Algorithms should be most effective among many ways to solve a
problem.
🠶 An algorithm shouldn’t include computer code. Instead, the algorithm
should be written in such a way that it can be used in different
programming languages.
🠶 A basic flowchart:
Step Start
Ye
s

Start Step Decision


No

Step Start
Categories of Algorithms
🠶 From data structures 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 from a data structure


Characteristics of an algorithm
🠶 Not all procedures can be called algorithms. An algorithm should have
the following characteristics:
🠶 Unambiguous – Algorithm should be clear and unambiguous. Each of its
steps (or phases), and their inputs/outputs should be clear and must lead to
only one meaning.
🠶 Input – an algorithm should have 0 or more well-defined inputs.
🠶 Output - an algorithm should have 1 or more well-defined outputs, and
should match the desired output.
🠶 Finiteness – Algorithms must terminate after a finite number of steps.
🠶 Feasibility – should be feasible with the available resources.
🠶 Independent – an algorithm should have step-by-step directions, which
should be independent of any programming code.
Examples and assignment

🠶 Examples:
🠶 Receipes
🠶 Sorting files/papers
🠶 Assignment:
🠶 Write down at least THREE algorithms you interact with everyday and present
it.

You might also like