SlideShare a Scribd company logo
Thinking in Data Structures

Tushar B Kute
http://www.tusharkute.com
Data Structure
●

What is the "Data Structure" ?
–
–

●

Ways to represent data.
In a general sense, any data representation is a data structure.
Example: An integer more typically, a data structure is meant to be
an organization for a collection of data items.

Why data structure ?
–
–

Have proven correct algorithms

–
●

To design and implement large-scale computer system
The art of programming

How to master in data structure ?
–

practice, discuss, and think
www.tusharkute.com

2
Need of data structures
●

Data structures organize data
–

●

More powerful computers
–

●

●

More efficient programs.
More complex applications.

More complex applications demand more calculations.
Complex computing tasks are unlike our everyday
experience.

www.tusharkute.com

3
List of data structures
●

Static
–
–

Stack

–
●

Array
Queue

Dynamic
–

Linked list

–

Tree

–

Graph
www.tusharkute.com

4
Choosing a data structure
int p[10], i=0;

int *p, i=0;

while(1)

while(1)

{

{
scanf(“%d”, &p[i]);
i++;

}

scanf(“%d”, &p[i]);
i++;
}

www.tusharkute.com

5
System life cycle
●

Summary
–

●

Requirements
–

●

RADRCV
What inputs, functions, and outputs.

Analysis
–

Break the problem down into manageable pieces.

–

Top-down approach.

–

Bottom-up approach.
www.tusharkute.com

6
System life cycle
●

Design
–

●

Refinement and Coding
–

●

Create abstract data types and the algorithm
specifications, language independent.
Determining data structures and algorithms.

Verification
–

Developing correctness proofs, testing the program,
and removing errors.
www.tusharkute.com

7
Efficiency
●

A solution is said to be efficient if it solves the problem
within its resource constraints.
–
–

●

Space
Time

The cost of a solution is the amount of resources that the
solution consumes.

www.tusharkute.com

8
Data Structure philosophy
●

●

●

Each data structure has costs and benefits.
Rarely is one data structure better than another in all
situations.
A data structure requires:
–
–

●

space for each data item it stores,
time to perform each basic operation,

Programming effort.

www.tusharkute.com

9
Data structure philosophy
●

●

●

Each problem has constraints on available space and
time.
Only after a careful analysis of problem characteristics
can we know the best data structure for the task.
Bank example:
–

Start account: a few minutes

–

Transactions: a few seconds

–

Close account: overnight
www.tusharkute.com

10
Example.
for(a=0; a>10; a++)

//loop-1

{
printf(“Hello World...”);
}
for(a=0; a<10; a++)

//loop-2

{
printf(“Hello World...”);
}
www.tusharkute.com

11
Example.
for(a=0; a<=10; a++)

//loop-3

{
printf(“Hello World...”);
}
for(a=0; a!=10; a++)

//loop-4

{
printf(“Hello World...”);
}
www.tusharkute.com

12
Example: check for prime number
flag=0;
for(a=2;a<num;a++)
{
if(num%a==0)
flag=1;
}
if(flag==1)
printf(“Number is not prime.”);
else
printf(“Number is prime.”);
www.tusharkute.com

13
Refinement-1
flag=0;
for(a=2;a<num;a++)
{
if(num%a==0) {
flag=1;
break;
}
}
if(flag==1)
printf(“Number is not prime.”);
else
www.tusharkute.com
printf(“Number is prime.”);

14
Refinement-2
flag=0;
for(a=2;a<num/2;a++)
{
if(num%a==0) {
flag=1;
break;
}
}
if(flag==1)
printf(“Number is not prime.”);
else
www.tusharkute.com
printf(“Number is prime.”);

15
Refinement-3
for(a=2;a<num/2;a++)
{
if(num%a==0)
break;
}
if(a==(num/2))
printf(“Number is prime.”);
else
printf(“Number is not prime.”);
www.tusharkute.com

16
Example: swapping of two numbers, Way-1
a=13, b=29;
temp = a;
a = b;
b = temp;

www.tusharkute.com

17
Way-2
a=13, b=29;
a = a + b;
a = a – b;
b = a – b;

www.tusharkute.com

18
Way-3
a=13, b=29;
a = a ^ b;
b = a ^ b;
a = a ^ b;
or
a^=b^=a^=b;
www.tusharkute.com

19
Worst / Average / Best case
●

Worst-case running time of an algorithm
–

The longest running time for any input of size n

–

An upper bound on the running time for any input

–

Guarantee that the algorithm will never take longer
Example: Sort a set of numbers in increasing order; and the data is in
decreasing order

–

The worst case can occur fairly often

–

E.g. in searching a database for a particular piece of information

●

●

Best-case running time
–

●

Sort a set of numbers in increasing order; and the data is already in
increasing order

Average-case running time
–

May be difficult to define what “average” means
www.tusharkute.com

20
Example: searching in database
●

Best case: O(1)

●

Worst case: O(n)

●

Average case: O(n/2)

www.tusharkute.com

21
Running time of algorithms
●

Bounds are for the algorithms, rather than programs
–

●

Programs are just implementations of an algorithm,
and almost always the details of the program do not
affect the bounds

Bounds are for algorithms, rather than problems
–

A problem can be solved with several algorithms,
some are more efficient than others

www.tusharkute.com

22
Describing algorithms
●

Natural language
–
–

●

English, Chinese
Instructions must be definite and effectiveness.

Graphic representation
–

Flowchart

Work well only if the algorithm is small and simple.
Pseudo language
●

●

–

Readable

Instructions must be definite and effectiveness.
Combining English and C
●

●

–

Simple and Tough task to do.
www.tusharkute.com

23
Algorithm and programs
●

Algorithm: a method or a process followed to solve a
problem.
–

●

An algorithm takes the input to a problem (function) and
transforms it to the output.
–

●

A recipe: The algorithm gives us a “recipe” for solving
the problem by performing a series of steps, where
each step is completely understood.

A mapping of input to output.

A problem can be solved by many algorithms.
www.tusharkute.com

24
A problem can have many solutions
●

For example, the problem of sorting can be solved by the
following algorithms:
–

Insertion sort

–

Bubble sort

–

Selection sort

–

Shell sort

–

Merge sort

–

Radix sort

–

Merge sort

–

Quick sort
www.tusharkute.com

25
Algorithm properties
●

An algorithm possesses the following properties:
–
–

It must be composed of a series of concrete steps.

–

There can be no ambiguity as to which step will be
performed next.

–

It must be composed of a finite number of steps.

–
●

It must be correct.

It must terminate.

A computer program is an instance, or concrete
representation, for an algorithm in some programming
language.
www.tusharkute.com

26
Thank you

This presentation is created using LibreOffice Impress 3.6.2.2
www.tusharkute.com

27

More Related Content

Similar to Thinking in data structures

Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
MumitAhmed1
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
SharabiNaif
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
Anonymous9etQKwW
 
Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Valeriy Kravchuk
 
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dan Lynn
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35
Bilal Ahmed
 
CSC 101-CSC 111 - Introduction to Computer Science - Lecture 4.pdf
CSC 101-CSC 111 - Introduction to Computer Science - Lecture 4.pdfCSC 101-CSC 111 - Introduction to Computer Science - Lecture 4.pdf
CSC 101-CSC 111 - Introduction to Computer Science - Lecture 4.pdf
MisterPhilips
 
CS3114_09212011.ppt
CS3114_09212011.pptCS3114_09212011.ppt
CS3114_09212011.ppt
Arumugam90
 
Dirty data? Clean it up! - Datapalooza Denver 2016
Dirty data? Clean it up! - Datapalooza Denver 2016Dirty data? Clean it up! - Datapalooza Denver 2016
Dirty data? Clean it up! - Datapalooza Denver 2016
Dan Lynn
 
Apache spark as a gateway drug to FP concepts taught and broken - Curry On 2018
Apache spark as a gateway drug to FP concepts taught and broken - Curry On 2018Apache spark as a gateway drug to FP concepts taught and broken - Curry On 2018
Apache spark as a gateway drug to FP concepts taught and broken - Curry On 2018
Holden Karau
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
example43
 
MySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukMySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukValeriy Kravchuk
 
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Holden Karau
 
Rules Programming tutorial
Rules Programming tutorialRules Programming tutorial
Rules Programming tutorialSrinath Perera
 
How I learned to time travel, or, data pipelining and scheduling with Airflow
How I learned to time travel, or, data pipelining and scheduling with AirflowHow I learned to time travel, or, data pipelining and scheduling with Airflow
How I learned to time travel, or, data pipelining and scheduling with Airflow
Laura Lorenz
 
R programming for data science
R programming for data scienceR programming for data science
R programming for data science
Sovello Hildebrand
 
Function-Oriented(Lec5) Pantnagar college.pdf
Function-Oriented(Lec5) Pantnagar college.pdfFunction-Oriented(Lec5) Pantnagar college.pdf
Function-Oriented(Lec5) Pantnagar college.pdf
yash32148
 

Similar to Thinking in data structures (20)

Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013Performance schema in_my_sql_5.6_pluk2013
Performance schema in_my_sql_5.6_pluk2013
 
Lec1
Lec1Lec1
Lec1
 
Lec1
Lec1Lec1
Lec1
 
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
Dirty Data? Clean it up! - Rocky Mountain DataCon 2016
 
CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35CS101- Introduction to Computing- Lecture 35
CS101- Introduction to Computing- Lecture 35
 
CSC 101-CSC 111 - Introduction to Computer Science - Lecture 4.pdf
CSC 101-CSC 111 - Introduction to Computer Science - Lecture 4.pdfCSC 101-CSC 111 - Introduction to Computer Science - Lecture 4.pdf
CSC 101-CSC 111 - Introduction to Computer Science - Lecture 4.pdf
 
CS3114_09212011.ppt
CS3114_09212011.pptCS3114_09212011.ppt
CS3114_09212011.ppt
 
Dirty data? Clean it up! - Datapalooza Denver 2016
Dirty data? Clean it up! - Datapalooza Denver 2016Dirty data? Clean it up! - Datapalooza Denver 2016
Dirty data? Clean it up! - Datapalooza Denver 2016
 
Apache spark as a gateway drug to FP concepts taught and broken - Curry On 2018
Apache spark as a gateway drug to FP concepts taught and broken - Curry On 2018Apache spark as a gateway drug to FP concepts taught and broken - Curry On 2018
Apache spark as a gateway drug to FP concepts taught and broken - Curry On 2018
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
MySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukMySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossuk
 
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
Ml pipelines with Apache spark and Apache beam - Ottawa Reactive meetup Augus...
 
Rules Programming tutorial
Rules Programming tutorialRules Programming tutorial
Rules Programming tutorial
 
Lec1
Lec1Lec1
Lec1
 
How I learned to time travel, or, data pipelining and scheduling with Airflow
How I learned to time travel, or, data pipelining and scheduling with AirflowHow I learned to time travel, or, data pipelining and scheduling with Airflow
How I learned to time travel, or, data pipelining and scheduling with Airflow
 
R programming for data science
R programming for data scienceR programming for data science
R programming for data science
 
Function-Oriented(Lec5) Pantnagar college.pdf
Function-Oriented(Lec5) Pantnagar college.pdfFunction-Oriented(Lec5) Pantnagar college.pdf
Function-Oriented(Lec5) Pantnagar college.pdf
 

More from Tushar B Kute

Apache Pig: A big data processor
Apache Pig: A big data processorApache Pig: A big data processor
Apache Pig: A big data processor
Tushar B Kute
 
01 Introduction to Android
01 Introduction to Android01 Introduction to Android
01 Introduction to Android
Tushar B Kute
 
Ubuntu OS and it's Flavours
Ubuntu OS and it's FlavoursUbuntu OS and it's Flavours
Ubuntu OS and it's Flavours
Tushar B Kute
 
Install Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteInstall Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. Kute
Tushar B Kute
 
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteInstall Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Tushar B Kute
 
Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftp
Tushar B Kute
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in Linux
Tushar B Kute
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in Linux
Tushar B Kute
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
Tushar B Kute
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix Threads
Tushar B Kute
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
Tushar B Kute
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
Tushar B Kute
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
Tushar B Kute
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
Tushar B Kute
 
Open source applications softwares
Open source applications softwaresOpen source applications softwares
Open source applications softwares
Tushar B Kute
 
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Tushar B Kute
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Tushar B Kute
 
Technical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTechnical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrc
Tushar B Kute
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 

More from Tushar B Kute (20)

Apache Pig: A big data processor
Apache Pig: A big data processorApache Pig: A big data processor
Apache Pig: A big data processor
 
01 Introduction to Android
01 Introduction to Android01 Introduction to Android
01 Introduction to Android
 
Ubuntu OS and it's Flavours
Ubuntu OS and it's FlavoursUbuntu OS and it's Flavours
Ubuntu OS and it's Flavours
 
Install Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. KuteInstall Drupal in Ubuntu by Tushar B. Kute
Install Drupal in Ubuntu by Tushar B. Kute
 
Install Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. KuteInstall Wordpress in Ubuntu Linux by Tushar B. Kute
Install Wordpress in Ubuntu Linux by Tushar B. Kute
 
Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftp
 
Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in Linux
 
Implementation of FIFO in Linux
Implementation of FIFO in LinuxImplementation of FIFO in Linux
Implementation of FIFO in Linux
 
Implementation of Pipe in Linux
Implementation of Pipe in LinuxImplementation of Pipe in Linux
Implementation of Pipe in Linux
 
Basic Multithreading using Posix Threads
Basic Multithreading using Posix ThreadsBasic Multithreading using Posix Threads
Basic Multithreading using Posix Threads
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
 
Part 03 File System Implementation in Linux
Part 03 File System Implementation in LinuxPart 03 File System Implementation in Linux
Part 03 File System Implementation in Linux
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)Part 01 Linux Kernel Compilation (Ubuntu)
Part 01 Linux Kernel Compilation (Ubuntu)
 
Open source applications softwares
Open source applications softwaresOpen source applications softwares
Open source applications softwares
 
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
Introduction to Ubuntu Edge Operating System (Ubuntu Touch)
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
 
Technical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrcTechnical blog by Engineering Students of Sandip Foundation, itsitrc
Technical blog by Engineering Students of Sandip Foundation, itsitrc
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 

Recently uploaded

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

Thinking in data structures

  • 1. Thinking in Data Structures Tushar B Kute http://www.tusharkute.com
  • 2. Data Structure ● What is the "Data Structure" ? – – ● Ways to represent data. In a general sense, any data representation is a data structure. Example: An integer more typically, a data structure is meant to be an organization for a collection of data items. Why data structure ? – – Have proven correct algorithms – ● To design and implement large-scale computer system The art of programming How to master in data structure ? – practice, discuss, and think www.tusharkute.com 2
  • 3. Need of data structures ● Data structures organize data – ● More powerful computers – ● ● More efficient programs. More complex applications. More complex applications demand more calculations. Complex computing tasks are unlike our everyday experience. www.tusharkute.com 3
  • 4. List of data structures ● Static – – Stack – ● Array Queue Dynamic – Linked list – Tree – Graph www.tusharkute.com 4
  • 5. Choosing a data structure int p[10], i=0; int *p, i=0; while(1) while(1) { { scanf(“%d”, &p[i]); i++; } scanf(“%d”, &p[i]); i++; } www.tusharkute.com 5
  • 6. System life cycle ● Summary – ● Requirements – ● RADRCV What inputs, functions, and outputs. Analysis – Break the problem down into manageable pieces. – Top-down approach. – Bottom-up approach. www.tusharkute.com 6
  • 7. System life cycle ● Design – ● Refinement and Coding – ● Create abstract data types and the algorithm specifications, language independent. Determining data structures and algorithms. Verification – Developing correctness proofs, testing the program, and removing errors. www.tusharkute.com 7
  • 8. Efficiency ● A solution is said to be efficient if it solves the problem within its resource constraints. – – ● Space Time The cost of a solution is the amount of resources that the solution consumes. www.tusharkute.com 8
  • 9. Data Structure philosophy ● ● ● Each data structure has costs and benefits. Rarely is one data structure better than another in all situations. A data structure requires: – – ● space for each data item it stores, time to perform each basic operation, Programming effort. www.tusharkute.com 9
  • 10. Data structure philosophy ● ● ● Each problem has constraints on available space and time. Only after a careful analysis of problem characteristics can we know the best data structure for the task. Bank example: – Start account: a few minutes – Transactions: a few seconds – Close account: overnight www.tusharkute.com 10
  • 11. Example. for(a=0; a>10; a++) //loop-1 { printf(“Hello World...”); } for(a=0; a<10; a++) //loop-2 { printf(“Hello World...”); } www.tusharkute.com 11
  • 12. Example. for(a=0; a<=10; a++) //loop-3 { printf(“Hello World...”); } for(a=0; a!=10; a++) //loop-4 { printf(“Hello World...”); } www.tusharkute.com 12
  • 13. Example: check for prime number flag=0; for(a=2;a<num;a++) { if(num%a==0) flag=1; } if(flag==1) printf(“Number is not prime.”); else printf(“Number is prime.”); www.tusharkute.com 13
  • 14. Refinement-1 flag=0; for(a=2;a<num;a++) { if(num%a==0) { flag=1; break; } } if(flag==1) printf(“Number is not prime.”); else www.tusharkute.com printf(“Number is prime.”); 14
  • 15. Refinement-2 flag=0; for(a=2;a<num/2;a++) { if(num%a==0) { flag=1; break; } } if(flag==1) printf(“Number is not prime.”); else www.tusharkute.com printf(“Number is prime.”); 15
  • 17. Example: swapping of two numbers, Way-1 a=13, b=29; temp = a; a = b; b = temp; www.tusharkute.com 17
  • 18. Way-2 a=13, b=29; a = a + b; a = a – b; b = a – b; www.tusharkute.com 18
  • 19. Way-3 a=13, b=29; a = a ^ b; b = a ^ b; a = a ^ b; or a^=b^=a^=b; www.tusharkute.com 19
  • 20. Worst / Average / Best case ● Worst-case running time of an algorithm – The longest running time for any input of size n – An upper bound on the running time for any input – Guarantee that the algorithm will never take longer Example: Sort a set of numbers in increasing order; and the data is in decreasing order – The worst case can occur fairly often – E.g. in searching a database for a particular piece of information ● ● Best-case running time – ● Sort a set of numbers in increasing order; and the data is already in increasing order Average-case running time – May be difficult to define what “average” means www.tusharkute.com 20
  • 21. Example: searching in database ● Best case: O(1) ● Worst case: O(n) ● Average case: O(n/2) www.tusharkute.com 21
  • 22. Running time of algorithms ● Bounds are for the algorithms, rather than programs – ● Programs are just implementations of an algorithm, and almost always the details of the program do not affect the bounds Bounds are for algorithms, rather than problems – A problem can be solved with several algorithms, some are more efficient than others www.tusharkute.com 22
  • 23. Describing algorithms ● Natural language – – ● English, Chinese Instructions must be definite and effectiveness. Graphic representation – Flowchart Work well only if the algorithm is small and simple. Pseudo language ● ● – Readable Instructions must be definite and effectiveness. Combining English and C ● ● – Simple and Tough task to do. www.tusharkute.com 23
  • 24. Algorithm and programs ● Algorithm: a method or a process followed to solve a problem. – ● An algorithm takes the input to a problem (function) and transforms it to the output. – ● A recipe: The algorithm gives us a “recipe” for solving the problem by performing a series of steps, where each step is completely understood. A mapping of input to output. A problem can be solved by many algorithms. www.tusharkute.com 24
  • 25. A problem can have many solutions ● For example, the problem of sorting can be solved by the following algorithms: – Insertion sort – Bubble sort – Selection sort – Shell sort – Merge sort – Radix sort – Merge sort – Quick sort www.tusharkute.com 25
  • 26. Algorithm properties ● An algorithm possesses the following properties: – – It must be composed of a series of concrete steps. – There can be no ambiguity as to which step will be performed next. – It must be composed of a finite number of steps. – ● It must be correct. It must terminate. A computer program is an instance, or concrete representation, for an algorithm in some programming language. www.tusharkute.com 26
  • 27. Thank you This presentation is created using LibreOffice Impress 3.6.2.2 www.tusharkute.com 27