SlideShare a Scribd company logo
Understanding Algorithm
and techniques in
programming at IDE level.
Author: Farrukh Ishaq
Algorithm
• An algorithm (pronounced AL-go-rith-um) is a procedure or formula
for solving a problem, based on conducting a sequence of specified
actions.
• An algorithm has a statement which are lead from an input of a
problem to an output as a solution
• The word algorithm derives from the name of the mathematician,
Mohammed ibn-Musa al-Khwarizmi, who was part of the royal court
in Baghdad and who lived from about 780 to 850.
Some Sorting Algorithm
• Bubble Sort
• Merge Sort
• Insert Sort
• Quick Sort
• Selection Sort
5 44 17 22 2 18 54 84
int[] list;
5 44 17 22 2 18 54 84
0 1 2 3 4 5 6 7
Index [] list
Bubble Sort 5 44 17 22 2 18 54 84
int[] list;
5 44 17 22 2 18 54 84
0 1 2 3 4 5 6 7
Index [] list
Sort starts
from left.
int[] list;
Left element
>
Right element
Swap
END
Use Right
element as
Left
TRUE
Ascending
Order int[] list;
FALSE LOOP
Right
Element <
Left
Element;
Return;
Else
IF
5 44 17 22 2 18 54 84
5 44 17 22 2 18 54 84
44 > 17 then Swap
5 4417 22 2 18 54 84
2 175 18 22 44 54 84
Return list[];
BigO(n^2)
Middle = List[]/2
Left=Middle
Right = L-length.ist
Merge Sort 5 44 17 22 2 18 54 84
5 44 17 22 2 18 54 84
0 1 2 3 4 5 6 7
5 44 17 22 2 18 54 84
5 44 17 22 2 18 54 84
5 > 44 then Swap
2 175 18 22 44 54 84
Return list[];
5 2217 44 2 18 54 84
2 5 17 18 22 44 54 84
Index [] list
Sort starts
from left.
int[] list;
Right[]
END
L.Left
element >
R.Right
TRUE
swap
Ascending
Order int[] list;
FALSE
Left[] || Right[]; Return;
Else
IF
Left[]
BigO(n log n)
Divide and conquer
BigO Notation Table
f(n) Name
1 Constant
Log n Logarithmic
N Linear
N log n Log Linear
N2 Quadratic
N3 Cubic
2n Exponential
BigO
• BigO will provide an explanation about the procedure which has been or which
will be required to complete a certain task.
• BigO is a notation used for programmer to analyses an Algorithm. The statement
which is used to describe BigO is as follow.
Brute Force
• It is a programming technique which means trying all the probabilities
which an algorithm may offer.
• An example is a PADLOCK which has a set of numbers to unlock the
chain, if a user doesn’t know the right code it has to loop all the
probabilities.
SWITCH
Case 1:
Case 2:
Break
switch(expression)
{ case value : //
Statements break; //
optional case value : //
Statements break; //
optional // You can have any number of case statements.
default : //
Optional //
Statements }
Some Search Algorithm
• Linear Search
• Binary Search
• Interpolation
Search
• Hash Table
5 44 17 22 2 18 54 84
int[] list;
5 44 17 22 2 18 54 84
0 1 2 3 4 5 6 7
Index [] list
Binary Search BigO(log n)
Divide and conquer
Middle = List[]/2
Left=Middle
Right = L-length.ist
5 44 17 22 2 18 54 84
5 44 17 22 2 18 54 84
0 1 2 3 4 5 6 7
2 175 18 22 44 54 84Merge Sort Return.
Index [] list
Sort starts
from left.
int[] list;
END
L.Left
element >
R.Right
TRUE
swap
Ascending
Order int[] list;
FALSE
Left[] || Right[]; Return;
Else
IF
Search
# 22
Transform and conquer
List[]/2
Left[] Right[]
Found
#
Return
index
2 175 18 22 44 54 84
Lower-bond upper-bond
22
Index [] list
0 1 2 3 4 5 6 7
Found at 5th position
Test Your Self
What is the worst-case complexity of the each of the following code fragments?
1.Two loops in a row:
for (i = 0; i < N; i++) { sequence of statements } // loop n
for (j = 0; j < M; j++) { sequence of statements } // loop m
How would the complexity change if the second loop went to N instead of M?
2.A nested loop followed by a non-nested loop:
for (i = 0; i < N; i++) // loop n
{
for (j = 0; j < N; j++) { sequence of statements } // loop n (NESTED LOOP)
}
for (k = 0; k < N; k++) { sequence of statements } // loop m
BigO(n+m)
BigO(n^2+m)

More Related Content

What's hot

Day 1 Chapter 1 Unit 1
Day 1 Chapter 1 Unit 1Day 1 Chapter 1 Unit 1
Applications of Stack
Applications of StackApplications of Stack
Applications of Stack
Christalin Nelson
 
Bakery Algorithm
Bakery Algorithm Bakery Algorithm
Bakery Algorithm
thededar
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
Stoian Kirov
 
COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4
Vishal Patil
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
Prabhakaran V M
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expression
DrkhanchanaR
 
Joins
JoinsJoins
COMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax AnalysisCOMPILER DESIGN- Syntax Analysis
COMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTIONCOMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTION
Anil Pokhrel
 
Chapter 6 Intermediate Code Generation
Chapter 6   Intermediate Code GenerationChapter 6   Intermediate Code Generation
Chapter 6 Intermediate Code Generation
Radhakrishnan Chinnusamy
 
Day 3 chapter 2 unit 1
Day 3 chapter 2 unit 1Day 3 chapter 2 unit 1
Algorithms
AlgorithmsAlgorithms
Algorithms
Santosh Rajan
 
Fundamental of Algorithms
Fundamental of Algorithms Fundamental of Algorithms
Fundamental of Algorithms
Dr Shashikant Athawale
 
Assignment
AssignmentAssignment
Assignment
MrunalMehta4
 
175035 cse lab-05
175035 cse lab-05 175035 cse lab-05
175035 cse lab-05
Mahbubay Rabbani Mim
 
vhdl exp-5
vhdl exp-5vhdl exp-5
vhdl exp-5
ChinmaySharma35
 
C after correction
C after correctionC after correction
C after correction
Prof. K R Biradar
 
Lecture8 syntax analysis_4
Lecture8 syntax analysis_4Lecture8 syntax analysis_4
Lecture8 syntax analysis_4
Mahesh Kumar Chelimilla
 

What's hot (19)

Day 1 Chapter 1 Unit 1
Day 1 Chapter 1 Unit 1Day 1 Chapter 1 Unit 1
Day 1 Chapter 1 Unit 1
 
Applications of Stack
Applications of StackApplications of Stack
Applications of Stack
 
Bakery Algorithm
Bakery Algorithm Bakery Algorithm
Bakery Algorithm
 
03. operators and-expressions
03. operators and-expressions03. operators and-expressions
03. operators and-expressions
 
COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4COMPUTER PROGRAMMING UNIT 1 Lecture 4
COMPUTER PROGRAMMING UNIT 1 Lecture 4
 
Algorithmic problem solving
Algorithmic problem solvingAlgorithmic problem solving
Algorithmic problem solving
 
Unit I - Evaluation of expression
Unit I - Evaluation of expressionUnit I - Evaluation of expression
Unit I - Evaluation of expression
 
Joins
JoinsJoins
Joins
 
COMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax AnalysisCOMPILER DESIGN- Syntax Analysis
COMPILER DESIGN- Syntax Analysis
 
COMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTIONCOMPILER DESIGN AND CONSTRUCTION
COMPILER DESIGN AND CONSTRUCTION
 
Chapter 6 Intermediate Code Generation
Chapter 6   Intermediate Code GenerationChapter 6   Intermediate Code Generation
Chapter 6 Intermediate Code Generation
 
Day 3 chapter 2 unit 1
Day 3 chapter 2 unit 1Day 3 chapter 2 unit 1
Day 3 chapter 2 unit 1
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Fundamental of Algorithms
Fundamental of Algorithms Fundamental of Algorithms
Fundamental of Algorithms
 
Assignment
AssignmentAssignment
Assignment
 
175035 cse lab-05
175035 cse lab-05 175035 cse lab-05
175035 cse lab-05
 
vhdl exp-5
vhdl exp-5vhdl exp-5
vhdl exp-5
 
C after correction
C after correctionC after correction
C after correction
 
Lecture8 syntax analysis_4
Lecture8 syntax analysis_4Lecture8 syntax analysis_4
Lecture8 syntax analysis_4
 

Similar to Learn about algorithm

Counting Sort
Counting SortCounting Sort
Counting Sort
Faiza Saleem
 
14-sorting.ppt
14-sorting.ppt14-sorting.ppt
14-sorting.ppt
RenalthaPujaBagaskar
 
14-sorting (3).ppt
14-sorting (3).ppt14-sorting (3).ppt
14-sorting (3).ppt
yasser3omr
 
14-sorting.ppt
14-sorting.ppt14-sorting.ppt
14-sorting.ppt
SushantRaj25
 
14-sorting.ppt
14-sorting.ppt14-sorting.ppt
14-sorting.ppt
KamalAlbashiri
 
Quick sort
Quick sortQuick sort
Quick sort
Jehat Hassan
 
Sorting
SortingSorting
Sorting
Shaista Qadir
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptx
ssuserd602fd
 
Algorithm By AMT.pptx
Algorithm By AMT.pptxAlgorithm By AMT.pptx
Algorithm By AMT.pptx
AungMyintTun3
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
Quick sort
Quick sortQuick sort
Quick sort
Uma mohan
 
Basic Sorting algorithms csharp
Basic Sorting algorithms csharpBasic Sorting algorithms csharp
Basic Sorting algorithms csharp
Micheal Ogundero
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
Dr.Umadevi V
 
Chapter 14 Searching and Sorting
Chapter 14 Searching and SortingChapter 14 Searching and Sorting
Chapter 14 Searching and Sorting
MuhammadBakri13
 
Lecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structureLecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structure
Nurjahan Nipa
 
Cis435 week01
Cis435 week01Cis435 week01
Cis435 week01
ashish bansal
 
Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...
Anwar Patel
 
16-sorting.ppt
16-sorting.ppt16-sorting.ppt
16-sorting.ppt
18Gunaalanpg
 
Algorithms lecture 3
Algorithms lecture 3Algorithms lecture 3
Algorithms lecture 3
Mimi Haque
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
Fadhil Ismail
 

Similar to Learn about algorithm (20)

Counting Sort
Counting SortCounting Sort
Counting Sort
 
14-sorting.ppt
14-sorting.ppt14-sorting.ppt
14-sorting.ppt
 
14-sorting (3).ppt
14-sorting (3).ppt14-sorting (3).ppt
14-sorting (3).ppt
 
14-sorting.ppt
14-sorting.ppt14-sorting.ppt
14-sorting.ppt
 
14-sorting.ppt
14-sorting.ppt14-sorting.ppt
14-sorting.ppt
 
Quick sort
Quick sortQuick sort
Quick sort
 
Sorting
SortingSorting
Sorting
 
Unit III Version I.pptx
Unit III Version I.pptxUnit III Version I.pptx
Unit III Version I.pptx
 
Algorithm By AMT.pptx
Algorithm By AMT.pptxAlgorithm By AMT.pptx
Algorithm By AMT.pptx
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and SearchingChapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
 
Quick sort
Quick sortQuick sort
Quick sort
 
Basic Sorting algorithms csharp
Basic Sorting algorithms csharpBasic Sorting algorithms csharp
Basic Sorting algorithms csharp
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
Chapter 14 Searching and Sorting
Chapter 14 Searching and SortingChapter 14 Searching and Sorting
Chapter 14 Searching and Sorting
 
Lecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structureLecture 02: Preliminaries of Data structure
Lecture 02: Preliminaries of Data structure
 
Cis435 week01
Cis435 week01Cis435 week01
Cis435 week01
 
Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...Decimal Long Double Double Double. Represents double-precision floating-point...
Decimal Long Double Double Double. Represents double-precision floating-point...
 
16-sorting.ppt
16-sorting.ppt16-sorting.ppt
16-sorting.ppt
 
Algorithms lecture 3
Algorithms lecture 3Algorithms lecture 3
Algorithms lecture 3
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
 

Recently uploaded

Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
lorraineandreiamcidl
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
Yara Milbes
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 

Recently uploaded (20)

Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptxLORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
LORRAINE ANDREI_LEQUIGAN_HOW TO USE WHATSAPP.pptx
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
SMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API ServiceSMS API Integration in Saudi Arabia| Best SMS API Service
SMS API Integration in Saudi Arabia| Best SMS API Service
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 

Learn about algorithm

  • 1. Understanding Algorithm and techniques in programming at IDE level. Author: Farrukh Ishaq
  • 2. Algorithm • An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem, based on conducting a sequence of specified actions. • An algorithm has a statement which are lead from an input of a problem to an output as a solution • The word algorithm derives from the name of the mathematician, Mohammed ibn-Musa al-Khwarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850.
  • 3. Some Sorting Algorithm • Bubble Sort • Merge Sort • Insert Sort • Quick Sort • Selection Sort 5 44 17 22 2 18 54 84 int[] list; 5 44 17 22 2 18 54 84 0 1 2 3 4 5 6 7 Index [] list
  • 4. Bubble Sort 5 44 17 22 2 18 54 84 int[] list; 5 44 17 22 2 18 54 84 0 1 2 3 4 5 6 7 Index [] list Sort starts from left. int[] list; Left element > Right element Swap END Use Right element as Left TRUE Ascending Order int[] list; FALSE LOOP Right Element < Left Element; Return; Else IF 5 44 17 22 2 18 54 84 5 44 17 22 2 18 54 84 44 > 17 then Swap 5 4417 22 2 18 54 84 2 175 18 22 44 54 84 Return list[]; BigO(n^2)
  • 5. Middle = List[]/2 Left=Middle Right = L-length.ist Merge Sort 5 44 17 22 2 18 54 84 5 44 17 22 2 18 54 84 0 1 2 3 4 5 6 7 5 44 17 22 2 18 54 84 5 44 17 22 2 18 54 84 5 > 44 then Swap 2 175 18 22 44 54 84 Return list[]; 5 2217 44 2 18 54 84 2 5 17 18 22 44 54 84 Index [] list Sort starts from left. int[] list; Right[] END L.Left element > R.Right TRUE swap Ascending Order int[] list; FALSE Left[] || Right[]; Return; Else IF Left[] BigO(n log n) Divide and conquer
  • 6. BigO Notation Table f(n) Name 1 Constant Log n Logarithmic N Linear N log n Log Linear N2 Quadratic N3 Cubic 2n Exponential
  • 7. BigO • BigO will provide an explanation about the procedure which has been or which will be required to complete a certain task. • BigO is a notation used for programmer to analyses an Algorithm. The statement which is used to describe BigO is as follow.
  • 8. Brute Force • It is a programming technique which means trying all the probabilities which an algorithm may offer. • An example is a PADLOCK which has a set of numbers to unlock the chain, if a user doesn’t know the right code it has to loop all the probabilities. SWITCH Case 1: Case 2: Break switch(expression) { case value : // Statements break; // optional case value : // Statements break; // optional // You can have any number of case statements. default : // Optional // Statements }
  • 9. Some Search Algorithm • Linear Search • Binary Search • Interpolation Search • Hash Table 5 44 17 22 2 18 54 84 int[] list; 5 44 17 22 2 18 54 84 0 1 2 3 4 5 6 7 Index [] list
  • 10. Binary Search BigO(log n) Divide and conquer Middle = List[]/2 Left=Middle Right = L-length.ist 5 44 17 22 2 18 54 84 5 44 17 22 2 18 54 84 0 1 2 3 4 5 6 7 2 175 18 22 44 54 84Merge Sort Return. Index [] list Sort starts from left. int[] list; END L.Left element > R.Right TRUE swap Ascending Order int[] list; FALSE Left[] || Right[]; Return; Else IF Search # 22 Transform and conquer List[]/2 Left[] Right[] Found # Return index 2 175 18 22 44 54 84 Lower-bond upper-bond 22 Index [] list 0 1 2 3 4 5 6 7 Found at 5th position
  • 11. Test Your Self What is the worst-case complexity of the each of the following code fragments? 1.Two loops in a row: for (i = 0; i < N; i++) { sequence of statements } // loop n for (j = 0; j < M; j++) { sequence of statements } // loop m How would the complexity change if the second loop went to N instead of M? 2.A nested loop followed by a non-nested loop: for (i = 0; i < N; i++) // loop n { for (j = 0; j < N; j++) { sequence of statements } // loop n (NESTED LOOP) } for (k = 0; k < N; k++) { sequence of statements } // loop m BigO(n+m) BigO(n^2+m)