SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
Algorithm1 Course 
Hani Ghazi && Ghassankhazaal 
IT engineering 
4thyear
Course content : 
•Introduction. 
•Complexity. 
•Data Structure. 
•Recursive. 
•Back Tracking. 
•Dynamic.
Introduction : 
•Algorithm Vs. Programming Language. 
•Engineering Vs. Coding. 
•Why we care ?
Algorithm analyzing (Complexity) : 
1.Time : Analysis of the time required to solve a problem of a particular size 
2.Space: Analysis of the computer memory required to solve a problem of a particular size
Algorithm analyzing (Complexity) : 
•We care about degree of algorithm 
•To determine the degree of algorithm we need to determine all the basic operation that take the longest time to execute. 
•We think always in the worst case.
Algorithm analyzing (Complexity) : 
•Example:imagine we have array with (n) element and we search for element (k) inside it. 
•Best case : we find our value (k) in first cell ( that mean we need just one compare operation )
Algorithm analyzing (Complexity) : 
•Worst case : we find our value [k]in the last position or we don’t find it ( that’s mean we need [n]compare operation ). 
•Average case : is to find our value [k] in middle the array
Algorithm analyzing (Complexity) : 
•As we say before, we look to worst case.
laws we need  
• 푖=1 푛1=푛 
• 푖=1 푛푖= 푛(푛−1) 2 
• 푖=1 푛푖2= 푛(푛+1)(2푛+1) 6 
• 푖=1 푛푏=푏 푖=1 푛1where [b] is constant
Read oly
Alg. 
Who_knows(){ 
arr: array [1..n] of integer; 
res : integer; res = 0; 
For i=0 To ndo 
res = res +arr[i]; 
} 
1. We have just one operation [+] 
2. We know that we need to loop ntimes 
3. What about 
푖=1 푛 1=푛 
4. Complexity is O(n)
Alg. 
Who_knows(){ 
arr: array [1..n] of integer; 
res : integer; res = 0; 
sub : integer; sub = 10000; 
For i=0 To ndo 
res = res +arr[i]; 
sub = sub –arr[i] 
} 
1. We have just tow operation [+,-] 
2. We know that we need to loop ntimes 
3. What about 
푖=1 푛 2=2∗ 푖=1 푛 1=2푛 
The cost will be 2n !!! But we care about degree , so it’s just O(n).
Alg. 
Never_mind(){ 
arr: array [1..n,1..m] of integer; 
res : integer; res = 0; 
For I =0 To ndo 
For j =0 To mdo 
res = res +arr[i,j]; 
} 
1. We have just one operation [+] 
2. Nested loops !! That’s mean we need to loop n*m times 
3. What about 
푖=1 푛 푗=1 푚 1=(푛∗푚) 
The cost will be n*m!!! Let’s consider that m=n so the cost will be O(푛2)
Alg. 
Never_mind(){ 
For I =0 To ndo 
For j =0 To mdo 
For k =0 Toj do 
res = res + 1; 
} 
1. We have just one operation [+] 
2. Nested loops !! 
3. What about 
푖=1 푛 푗=1 푚 푘=1 푗 1= 푖=1 푛 푗=1 푚 푗 
= 푖=1 푛푛(푛+1) 2= 푛(푛+1) 2 푖=1 푛1= 푛2(푛+1) 2 
Complexity is O(푛3)
Algo. 
NeverAsk( ) { 
s = 1; 
while ( n > 1 ) { 
s = s * n; 
n = n/2 ; 
} 
} 
What’s the cost ??!!
Let’s consider n = 16 
At [1] execution, N got N/2, 
At [2] execution, N got N/4 
At [3]execution, N got N/8 
At [4]execution, N got N/16 
At last execution 푁 2푘> 0 푁 22= 1 n = 2푘k =푙표푔2(푛) 
In general O(푙표푔푛(푛)) 
Times 
1 
2 
3 
.. 
k 
N 푁 2 푁 22 푁 23 푁 2푘
What if we have a condition
What if we have a condition 
•First let’s type the formula 
푖=1 푛2||푖푚표푑푛 푗=1 푖 1 
•Then we retype the condition 
i= k*n ; where k is constant 
•When i= 푛2, k = 푛2 푛 =푛 
푘=1 푛 푗=1 푘∗푛 1= 푘=1 푛 푘∗푛=푛∗ 푛(푛+1) 2 
Complexity is O(푛3)
Try to solve 
Homework 
Homework 
Homework  
Algo. 
Homework (){ 
For i= 1 to n { 
if ( Even(i) ) then 
For j = 1 to I do 
sum = sum + 1; 
else 
For k = 1 to I do 
sum = sum -1; 
} 
}
Algorithm1 course 1st slide

Mais conteúdo relacionado

Mais procurados

Data Structure and Algorithms Merge Sort
Data Structure and Algorithms Merge SortData Structure and Algorithms Merge Sort
Data Structure and Algorithms Merge SortManishPrajapati78
 
Insertion sort
Insertion sortInsertion sort
Insertion sortalmaqboli
 
Parallel sorting Algorithms
Parallel  sorting AlgorithmsParallel  sorting Algorithms
Parallel sorting AlgorithmsGARIMA SHAKYA
 
Algorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisAlgorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisÖmer Faruk Öztürk
 
18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)AdityaKhandelwal58
 
Presentation on binary search, quick sort, merge sort and problems
Presentation on binary search, quick sort, merge sort  and problemsPresentation on binary search, quick sort, merge sort  and problems
Presentation on binary search, quick sort, merge sort and problemsSumita Das
 
SORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix SortSORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix SortDevanshu Taneja
 
Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...
Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...
Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...Daniel Hutama
 
How to Solve the Force Problems
How to Solve the  Force ProblemsHow to Solve the  Force Problems
How to Solve the Force Problemsphysicscatalyst
 
01. Theory of Computing
01. Theory of Computing01. Theory of Computing
01. Theory of Computingrabiul souvon
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysisjayavignesh86
 
Intro to Sorting + Insertion Sort
Intro to Sorting + Insertion SortIntro to Sorting + Insertion Sort
Intro to Sorting + Insertion SortNicholas Case
 
Grovers Algorithm
Grovers Algorithm Grovers Algorithm
Grovers Algorithm CaseyHaaland
 

Mais procurados (20)

Lecture23
Lecture23Lecture23
Lecture23
 
Data Structure and Algorithms Merge Sort
Data Structure and Algorithms Merge SortData Structure and Algorithms Merge Sort
Data Structure and Algorithms Merge Sort
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Parallel sorting Algorithms
Parallel  sorting AlgorithmsParallel  sorting Algorithms
Parallel sorting Algorithms
 
Algorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisAlgorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O Analysis
 
18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)18103010 algorithm complexity (iterative)
18103010 algorithm complexity (iterative)
 
Insertion sort algorithm power point presentation
Insertion  sort algorithm power point presentation Insertion  sort algorithm power point presentation
Insertion sort algorithm power point presentation
 
Presentation on binary search, quick sort, merge sort and problems
Presentation on binary search, quick sort, merge sort  and problemsPresentation on binary search, quick sort, merge sort  and problems
Presentation on binary search, quick sort, merge sort and problems
 
SORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix SortSORTTING IN LINEAR TIME - Radix Sort
SORTTING IN LINEAR TIME - Radix Sort
 
A03310103
A03310103A03310103
A03310103
 
Recursive squaring
Recursive squaringRecursive squaring
Recursive squaring
 
Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...
Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...
Cryptanalysis with a Quantum Computer - An Exposition on Shor's Factoring Alg...
 
How to Solve the Force Problems
How to Solve the  Force ProblemsHow to Solve the  Force Problems
How to Solve the Force Problems
 
Quick sort
Quick sortQuick sort
Quick sort
 
01. Theory of Computing
01. Theory of Computing01. Theory of Computing
01. Theory of Computing
 
Lecture 3 insertion sort and complexity analysis
Lecture 3   insertion sort and complexity analysisLecture 3   insertion sort and complexity analysis
Lecture 3 insertion sort and complexity analysis
 
Quick sort
Quick sortQuick sort
Quick sort
 
Selection sort
Selection sortSelection sort
Selection sort
 
Intro to Sorting + Insertion Sort
Intro to Sorting + Insertion SortIntro to Sorting + Insertion Sort
Intro to Sorting + Insertion Sort
 
Grovers Algorithm
Grovers Algorithm Grovers Algorithm
Grovers Algorithm
 

Destaque

International Journal of Algorithms Design and Analysis vol 2 issue 1
International Journal of Algorithms Design and Analysis vol 2 issue 1International Journal of Algorithms Design and Analysis vol 2 issue 1
International Journal of Algorithms Design and Analysis vol 2 issue 1JournalsPub www.journalspub.com
 
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosluzenith_g
 
Tema e Diplomes- Version përfundimtar
Tema e Diplomes- Version përfundimtarTema e Diplomes- Version përfundimtar
Tema e Diplomes- Version përfundimtarKristo Xhimo
 
Complejidad ppt analisis de algoritmo
Complejidad ppt analisis de algoritmoComplejidad ppt analisis de algoritmo
Complejidad ppt analisis de algoritmoJanii Rivera
 
Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)Zihui Li
 
Gjuhe Programuese ushtrimet C++
Gjuhe Programuese   ushtrimet   C++Gjuhe Programuese   ushtrimet   C++
Gjuhe Programuese ushtrimet C++Ajla Hasani
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSGayathri Gaayu
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsSwapnil Agrawal
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to AlgorithmsVenkatesh Iyer
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsArvind Krishnaa
 
Analiza statistikore e të dhënave - Ardiana Gashi
Analiza statistikore e të dhënave - Ardiana GashiAnaliza statistikore e të dhënave - Ardiana Gashi
Analiza statistikore e të dhënave - Ardiana GashiMenaxherat
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)jehan1987
 
Analize statistikore
Analize statistikoreAnalize statistikore
Analize statistikoreMenaxherat
 

Destaque (17)

International Journal of Algorithms Design and Analysis vol 2 issue 1
International Journal of Algorithms Design and Analysis vol 2 issue 1International Journal of Algorithms Design and Analysis vol 2 issue 1
International Journal of Algorithms Design and Analysis vol 2 issue 1
 
Introducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmosIntroducción al Análisis y diseño de algoritmos
Introducción al Análisis y diseño de algoritmos
 
Tema e Diplomes- Version përfundimtar
Tema e Diplomes- Version përfundimtarTema e Diplomes- Version përfundimtar
Tema e Diplomes- Version përfundimtar
 
Complejidad ppt analisis de algoritmo
Complejidad ppt analisis de algoritmoComplejidad ppt analisis de algoritmo
Complejidad ppt analisis de algoritmo
 
Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)Machine Learning Algorithms (Part 1)
Machine Learning Algorithms (Part 1)
 
Algoritmet
AlgoritmetAlgoritmet
Algoritmet
 
Gjuhe Programuese ushtrimet C++
Gjuhe Programuese   ushtrimet   C++Gjuhe Programuese   ushtrimet   C++
Gjuhe Programuese ushtrimet C++
 
ADA complete notes
ADA complete notesADA complete notes
ADA complete notes
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
Algoritmet C++
Algoritmet C++Algoritmet C++
Algoritmet C++
 
Algoritmet
AlgoritmetAlgoritmet
Algoritmet
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Analiza statistikore e të dhënave - Ardiana Gashi
Analiza statistikore e të dhënave - Ardiana GashiAnaliza statistikore e të dhënave - Ardiana Gashi
Analiza statistikore e të dhënave - Ardiana Gashi
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Analize statistikore
Analize statistikoreAnalize statistikore
Analize statistikore
 

Semelhante a Algorithm1 course 1st slide

DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...2022cspaawan12556
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfAmayJaiswal4
 
UNIT I- Session 3.pptx
UNIT I- Session 3.pptxUNIT I- Session 3.pptx
UNIT I- Session 3.pptxabcdefgh690537
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithmsDr. Rupa Ch
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesSreedhar Chowdam
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdfSrinivasaReddyPolamR
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihmSajid Marwat
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..KarthikeyaLanka1
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithmspppepito86
 
Time and Space Complexity Analysis.pptx
Time and Space Complexity Analysis.pptxTime and Space Complexity Analysis.pptx
Time and Space Complexity Analysis.pptxdudelover
 
CSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxCSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxDeepakM509554
 
Lecture 3 complexity
Lecture 3 complexityLecture 3 complexity
Lecture 3 complexityMadhu Niket
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.Tariq Khan
 
1_Asymptotic_Notation_pptx.pptx
1_Asymptotic_Notation_pptx.pptx1_Asymptotic_Notation_pptx.pptx
1_Asymptotic_Notation_pptx.pptxpallavidhade2
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexityAbbas Ali
 

Semelhante a Algorithm1 course 1st slide (20)

Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...DSA Complexity.pptx   What is Complexity Analysis? What is the need for Compl...
DSA Complexity.pptx What is Complexity Analysis? What is the need for Compl...
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Unit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdfUnit-1 DAA_Notes.pdf
Unit-1 DAA_Notes.pdf
 
Anu DAA i1t unit
Anu DAA i1t unitAnu DAA i1t unit
Anu DAA i1t unit
 
UNIT I- Session 3.pptx
UNIT I- Session 3.pptxUNIT I- Session 3.pptx
UNIT I- Session 3.pptx
 
Design and Analysis of algorithms
Design and Analysis of algorithmsDesign and Analysis of algorithms
Design and Analysis of algorithms
 
Design and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture NotesDesign and Analysis of Algorithms Lecture Notes
Design and Analysis of Algorithms Lecture Notes
 
time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
 
how to calclute time complexity of algortihm
how to calclute time complexity of algortihmhow to calclute time complexity of algortihm
how to calclute time complexity of algortihm
 
DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..DS Unit-1.pptx very easy to understand..
DS Unit-1.pptx very easy to understand..
 
Introduction to Algorithms
Introduction to AlgorithmsIntroduction to Algorithms
Introduction to Algorithms
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
 
Time and Space Complexity Analysis.pptx
Time and Space Complexity Analysis.pptxTime and Space Complexity Analysis.pptx
Time and Space Complexity Analysis.pptx
 
CSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxCSE680-07QuickSort.pptx
CSE680-07QuickSort.pptx
 
Lecture 3 complexity
Lecture 3 complexityLecture 3 complexity
Lecture 3 complexity
 
Algorithm And analysis Lecture 03& 04-time complexity.
 Algorithm And analysis Lecture 03& 04-time complexity. Algorithm And analysis Lecture 03& 04-time complexity.
Algorithm And analysis Lecture 03& 04-time complexity.
 
algorithm unit 1
algorithm unit 1algorithm unit 1
algorithm unit 1
 
1_Asymptotic_Notation_pptx.pptx
1_Asymptotic_Notation_pptx.pptx1_Asymptotic_Notation_pptx.pptx
1_Asymptotic_Notation_pptx.pptx
 
Lec03 04-time complexity
Lec03 04-time complexityLec03 04-time complexity
Lec03 04-time complexity
 

Último

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 

Último (20)

College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 

Algorithm1 course 1st slide

  • 1. Algorithm1 Course Hani Ghazi && Ghassankhazaal IT engineering 4thyear
  • 2. Course content : •Introduction. •Complexity. •Data Structure. •Recursive. •Back Tracking. •Dynamic.
  • 3. Introduction : •Algorithm Vs. Programming Language. •Engineering Vs. Coding. •Why we care ?
  • 4. Algorithm analyzing (Complexity) : 1.Time : Analysis of the time required to solve a problem of a particular size 2.Space: Analysis of the computer memory required to solve a problem of a particular size
  • 5. Algorithm analyzing (Complexity) : •We care about degree of algorithm •To determine the degree of algorithm we need to determine all the basic operation that take the longest time to execute. •We think always in the worst case.
  • 6. Algorithm analyzing (Complexity) : •Example:imagine we have array with (n) element and we search for element (k) inside it. •Best case : we find our value (k) in first cell ( that mean we need just one compare operation )
  • 7. Algorithm analyzing (Complexity) : •Worst case : we find our value [k]in the last position or we don’t find it ( that’s mean we need [n]compare operation ). •Average case : is to find our value [k] in middle the array
  • 8. Algorithm analyzing (Complexity) : •As we say before, we look to worst case.
  • 9. laws we need  • 푖=1 푛1=푛 • 푖=1 푛푖= 푛(푛−1) 2 • 푖=1 푛푖2= 푛(푛+1)(2푛+1) 6 • 푖=1 푛푏=푏 푖=1 푛1where [b] is constant
  • 11. Alg. Who_knows(){ arr: array [1..n] of integer; res : integer; res = 0; For i=0 To ndo res = res +arr[i]; } 1. We have just one operation [+] 2. We know that we need to loop ntimes 3. What about 푖=1 푛 1=푛 4. Complexity is O(n)
  • 12. Alg. Who_knows(){ arr: array [1..n] of integer; res : integer; res = 0; sub : integer; sub = 10000; For i=0 To ndo res = res +arr[i]; sub = sub –arr[i] } 1. We have just tow operation [+,-] 2. We know that we need to loop ntimes 3. What about 푖=1 푛 2=2∗ 푖=1 푛 1=2푛 The cost will be 2n !!! But we care about degree , so it’s just O(n).
  • 13. Alg. Never_mind(){ arr: array [1..n,1..m] of integer; res : integer; res = 0; For I =0 To ndo For j =0 To mdo res = res +arr[i,j]; } 1. We have just one operation [+] 2. Nested loops !! That’s mean we need to loop n*m times 3. What about 푖=1 푛 푗=1 푚 1=(푛∗푚) The cost will be n*m!!! Let’s consider that m=n so the cost will be O(푛2)
  • 14. Alg. Never_mind(){ For I =0 To ndo For j =0 To mdo For k =0 Toj do res = res + 1; } 1. We have just one operation [+] 2. Nested loops !! 3. What about 푖=1 푛 푗=1 푚 푘=1 푗 1= 푖=1 푛 푗=1 푚 푗 = 푖=1 푛푛(푛+1) 2= 푛(푛+1) 2 푖=1 푛1= 푛2(푛+1) 2 Complexity is O(푛3)
  • 15.
  • 16. Algo. NeverAsk( ) { s = 1; while ( n > 1 ) { s = s * n; n = n/2 ; } } What’s the cost ??!!
  • 17. Let’s consider n = 16 At [1] execution, N got N/2, At [2] execution, N got N/4 At [3]execution, N got N/8 At [4]execution, N got N/16 At last execution 푁 2푘> 0 푁 22= 1 n = 2푘k =푙표푔2(푛) In general O(푙표푔푛(푛)) Times 1 2 3 .. k N 푁 2 푁 22 푁 23 푁 2푘
  • 18.
  • 19. What if we have a condition
  • 20. What if we have a condition •First let’s type the formula 푖=1 푛2||푖푚표푑푛 푗=1 푖 1 •Then we retype the condition i= k*n ; where k is constant •When i= 푛2, k = 푛2 푛 =푛 푘=1 푛 푗=1 푘∗푛 1= 푘=1 푛 푘∗푛=푛∗ 푛(푛+1) 2 Complexity is O(푛3)
  • 24. Homework  Algo. Homework (){ For i= 1 to n { if ( Even(i) ) then For j = 1 to I do sum = sum + 1; else For k = 1 to I do sum = sum -1; } }