SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Introduction to Algorithms
Why do you need algorithms?
Good algorithmic training is VERY important for the programmer, but
you don’t need to memorize all the algorithms
Understanding algorithms gives you:
1) Ability to solve incomprehensible problems
2) Habit to analyze the effectiveness of each of your solutions
3) Ability to skillfully use the existing tools
One more reason: jobs
Outline
• Definition of algorithm
• Formal properties of algorithms
• Some classification of algorithms
• Complexity of algorithms
• ALGORITHMS
Disclaimer
Some of the terms and words Google-translated.
Sorry.
Source code is availigle on GitHub
Definition of algorithm
Simple:
Algorithm is a set of rules for solving a problem in a finite
number of steps
Less simple:
Algorithm is a finite set of unambiguous instructions that, given some
set of initial conditions, can be performed in a prescribed sequence to
achieve a certain goal and that has a recognizable set of end
conditions.
Formal properties of algorithms
1) Finiteness
2) Discreteness
3) Clarity
4) Accuracy
5) Mass character
6) Definitiveness
Finiteness
Finiteness (or effectiviness)
means that algorithm has a finite number of steps
to received result.
Discreteness
Discreteness
means that algorithm has to be broken down into
a sequence of steps performed
Clarity
Clarity
means that algorithm must contain only the
commands that are part of a set of commands
that can perform a particular executor
Accuracy
Accuracy
means that any step of an algorithm should be
definite and unambiguous
Mass character
Mass character
means that once algorithm is made up it must
solve similar problems with different input data
Definitiveness
Definitiveness
means that the same set of input data will
produce the same result, i.e. the result is uniquely
determined by the initial data.
Test yourself
I want to cut an orange.
What’s the plan?
Example of algorithm:
How to cut an orange
Classification
Couple of categories of algorithms (there are a plenty of them)
•Deterministic / Randomized
•Exact / Approximation
•Sequential / Parallel
•etc.
Complexity of algorithms
1) Confusing explanation
2) Clear explanation (must read)
The idea is Big-O notation
Big-O notation is a relative representation of the
complexity of an algorithm.
Algorithms: Strings/arrays
Algorithm #1: Remove Element
Given an array and a value, remove all instances of
that value in place and return the new length.
(Note: The order of elements can be changed. It doesn't matter
what you leave beyond the new length.)
Algorithms: Strings/arrays
Algorithm #2: Search Insert Position
Given a sorted array and a target value, return the
index if the target is found. If not, return the index
where it would be if it were inserted in order. You
may assume no duplicates in the array.
[1,3,5,6], 5 -> 2
[1,3,5,6], 2 -> 1
[1,3,5,6], 7 -> 4
[1,3,5,6], 0 -> 0
Algorithms: Strings/arrays
Algorithm #3: Anagrams
Given an array of strings, return all groups of strings that are
anagrams.
An anagram is a type of word play, the result of rearranging the
letters of a word or phrase to produce a new word or phrase,
using all the original letters exactly once; for example Torchwood
can be rearranged into Doctor Who.
If two strings are anagram to each other, their sorted sequence is
the same. Therefore, this problem can be seen as a problem of
finding duplicate elements.
Algorithms: Matrix
Algorithm: Rotate Image
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Algorithms: Linked List
Linked list is a linear collection of data elements, called nodes pointing
to the next node by means of pointer
Algorithm: Reverse Linked List
Reverse a singly linked list.
Algorithms: Binary Tree
Binary tree is a tree data structure in which each node has at most two
children, which are referred to as the left child and the right child
Algorithm: Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. The path may
start and end at any node in the tree.
Algorithms: Sorting
Сhances that you will need to write a sorting algorithm are close to
zero.
http://www.sorting-algorithms.com/
https://www.youtube.com/watch?v=kPRA0W1kECg
Today:
• Learn some theory (definition properties, complexity)
• Overview several algorithms
Extra resources
1) http://www.programcreek.com/2012/11/top-10-algorithms-for-
coding-interview/

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Fundamentals of algorithms
Fundamentals of algorithmsFundamentals of algorithms
Fundamentals of algorithms
 
DBMS CS3
DBMS CS3DBMS CS3
DBMS CS3
 
Unit 1 polynomial manipulation
Unit 1   polynomial manipulationUnit 1   polynomial manipulation
Unit 1 polynomial manipulation
 
Chapitre 08
Chapitre 08Chapitre 08
Chapitre 08
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Efficient Sparse Coding Algorithms
Efficient Sparse Coding AlgorithmsEfficient Sparse Coding Algorithms
Efficient Sparse Coding Algorithms
 
Binary search
Binary searchBinary search
Binary search
 
Binary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of AlgorithmsBinary Search - Design & Analysis of Algorithms
Binary Search - Design & Analysis of Algorithms
 
Data structures
Data structuresData structures
Data structures
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Ap Power Point Chpt2
Ap Power Point Chpt2Ap Power Point Chpt2
Ap Power Point Chpt2
 
Applying Generics
Applying GenericsApplying Generics
Applying Generics
 
Java -lec-6
Java -lec-6Java -lec-6
Java -lec-6
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
 
Data structures using C
Data structures using CData structures using C
Data structures using C
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Methods In C-Sharp (C#)
Methods In C-Sharp (C#)Methods In C-Sharp (C#)
Methods In C-Sharp (C#)
 
Fuzzy logic
Fuzzy logicFuzzy logic
Fuzzy logic
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 
Abstract method
Abstract methodAbstract method
Abstract method
 

Ähnlich wie CubeIT Tech - Algorithms

Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question'shammad463061
 
Types of Algorithms.ppt
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.pptALIZAIB KHAN
 
DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptxRAJESH S
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptxRAJESH S
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1chidabdu
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxskilljiolms
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - IntroductionMadhu Bala
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and reviewAbdullah Al-hazmy
 
Sienna 13 limitations
Sienna 13 limitationsSienna 13 limitations
Sienna 13 limitationschidabdu
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptxSayanSen36
 
Csallner algorithms1
Csallner algorithms1Csallner algorithms1
Csallner algorithms1seshagiri rao
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptxAlgorithms and problem solving.pptx
Algorithms and problem solving.pptxaikomo1
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.pptRaoHamza24
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoreambikavenkatesh2
 
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdfADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdfRGPV De Bunkers
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptxrajesshs31r
 

Ähnlich wie CubeIT Tech - Algorithms (20)

Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question's
 
Types of Algorithms.ppt
Types of Algorithms.pptTypes of Algorithms.ppt
Types of Algorithms.ppt
 
Daa chapter 1
Daa chapter 1Daa chapter 1
Daa chapter 1
 
DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptx
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptx
 
Algorithm chapter 1
Algorithm chapter 1Algorithm chapter 1
Algorithm chapter 1
 
VCE Unit 01 (2).pptx
VCE Unit 01 (2).pptxVCE Unit 01 (2).pptx
VCE Unit 01 (2).pptx
 
Algorithm - Introduction
Algorithm - IntroductionAlgorithm - Introduction
Algorithm - Introduction
 
Data Structures- Part1 overview and review
Data Structures- Part1 overview and reviewData Structures- Part1 overview and review
Data Structures- Part1 overview and review
 
Design & Analysis Of Algorithm
Design & Analysis Of AlgorithmDesign & Analysis Of Algorithm
Design & Analysis Of Algorithm
 
DAA UNIT 3
DAA UNIT 3DAA UNIT 3
DAA UNIT 3
 
Sienna 13 limitations
Sienna 13 limitationsSienna 13 limitations
Sienna 13 limitations
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
chapter 1
chapter 1chapter 1
chapter 1
 
Csallner algorithms1
Csallner algorithms1Csallner algorithms1
Csallner algorithms1
 
Algorithms and problem solving.pptx
Algorithms and problem solving.pptxAlgorithms and problem solving.pptx
Algorithms and problem solving.pptx
 
Lecture 01-2.ppt
Lecture 01-2.pptLecture 01-2.ppt
Lecture 01-2.ppt
 
data structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysoredata structures using C 2 sem BCA univeristy of mysore
data structures using C 2 sem BCA univeristy of mysore
 
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdfADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptx
 

Kürzlich hochgeladen

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Kürzlich hochgeladen (20)

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

CubeIT Tech - Algorithms

  • 2. Why do you need algorithms? Good algorithmic training is VERY important for the programmer, but you don’t need to memorize all the algorithms Understanding algorithms gives you: 1) Ability to solve incomprehensible problems 2) Habit to analyze the effectiveness of each of your solutions 3) Ability to skillfully use the existing tools One more reason: jobs
  • 3. Outline • Definition of algorithm • Formal properties of algorithms • Some classification of algorithms • Complexity of algorithms • ALGORITHMS
  • 4. Disclaimer Some of the terms and words Google-translated. Sorry. Source code is availigle on GitHub
  • 5. Definition of algorithm Simple: Algorithm is a set of rules for solving a problem in a finite number of steps Less simple: Algorithm is a finite set of unambiguous instructions that, given some set of initial conditions, can be performed in a prescribed sequence to achieve a certain goal and that has a recognizable set of end conditions.
  • 6. Formal properties of algorithms 1) Finiteness 2) Discreteness 3) Clarity 4) Accuracy 5) Mass character 6) Definitiveness
  • 7. Finiteness Finiteness (or effectiviness) means that algorithm has a finite number of steps to received result.
  • 8. Discreteness Discreteness means that algorithm has to be broken down into a sequence of steps performed
  • 9. Clarity Clarity means that algorithm must contain only the commands that are part of a set of commands that can perform a particular executor
  • 10. Accuracy Accuracy means that any step of an algorithm should be definite and unambiguous
  • 11. Mass character Mass character means that once algorithm is made up it must solve similar problems with different input data
  • 12. Definitiveness Definitiveness means that the same set of input data will produce the same result, i.e. the result is uniquely determined by the initial data.
  • 13. Test yourself I want to cut an orange. What’s the plan?
  • 14. Example of algorithm: How to cut an orange
  • 15. Classification Couple of categories of algorithms (there are a plenty of them) •Deterministic / Randomized •Exact / Approximation •Sequential / Parallel •etc.
  • 16. Complexity of algorithms 1) Confusing explanation 2) Clear explanation (must read) The idea is Big-O notation Big-O notation is a relative representation of the complexity of an algorithm.
  • 17.
  • 18. Algorithms: Strings/arrays Algorithm #1: Remove Element Given an array and a value, remove all instances of that value in place and return the new length. (Note: The order of elements can be changed. It doesn't matter what you leave beyond the new length.)
  • 19. Algorithms: Strings/arrays Algorithm #2: Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. [1,3,5,6], 5 -> 2 [1,3,5,6], 2 -> 1 [1,3,5,6], 7 -> 4 [1,3,5,6], 0 -> 0
  • 20. Algorithms: Strings/arrays Algorithm #3: Anagrams Given an array of strings, return all groups of strings that are anagrams. An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase, using all the original letters exactly once; for example Torchwood can be rearranged into Doctor Who. If two strings are anagram to each other, their sorted sequence is the same. Therefore, this problem can be seen as a problem of finding duplicate elements.
  • 21. Algorithms: Matrix Algorithm: Rotate Image You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise).
  • 22. Algorithms: Linked List Linked list is a linear collection of data elements, called nodes pointing to the next node by means of pointer Algorithm: Reverse Linked List Reverse a singly linked list.
  • 23. Algorithms: Binary Tree Binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child Algorithm: Binary Tree Maximum Path Sum Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree.
  • 24. Algorithms: Sorting Сhances that you will need to write a sorting algorithm are close to zero. http://www.sorting-algorithms.com/ https://www.youtube.com/watch?v=kPRA0W1kECg
  • 25. Today: • Learn some theory (definition properties, complexity) • Overview several algorithms

Hinweis der Redaktion

  1. First, is the ability to solve the problem of incomprehensible. The vague wording of vital problems to see the possible strict interpretation. Comprehensively analyze the various options and choose the most suitable. Obviously, it is not enough just to know the algorithms. You must be able to "see them", to recognize the possibilities of their application. Secondly, algorithmic training should get you the habit of analyzing the effectiveness of each of your solutions. Third, algorithmic training should help skillfully use the existing tools. Databases are continuous data structures and algorithms. And conceptually quite simple and clear - search trees, hash table For example, knowing that the database index - it's just a search tree, it is easy to understand which requests can be met quickly and which ones are doomed to full-scan.
  2. http://dictionary.reference.com/browse/algorithm https://books.google.ca/books?id=uI1ytRzul8MC&pg=PA5&lpg=PA5&dq=finite+set+of+unambiguous+instructions+that,+given+some+set+of+initial+conditions,+can+be+performed+in+a+prescribed+sequence+to+achieve+a+certain+goal+and+that+has+a+recognizable+set+of+end+conditions&source=bl&ots=QLftG8AKmM&sig=EMu5Y74g3c9qrZowCNpYEr9VOJ4&hl=ru&sa=X&ved=0ahUKEwi7gMvQwvzKAhXBnIMKHZutDpoQ6AEIHDAA#v=onepage&q=finite%20set%20of%20unambiguous%20instructions%20that%2C%20given%20some%20set%20of%20initial%20conditions%2C%20can%20be%20performed%20in%20a%20prescribed%20sequence%20to%20achieve%20a%20certain%20goal%20and%20that%20has%20a%20recognizable%20set%20of%20end%20conditions&f=false
  3. http://learnpascal.ru/vvedenie-v-paskal/algoritm.html
  4. 1) SIMPLE: the algorithm must eventually terminate. Something endless is not an algorithm
  5. Example: Do that – then that – then that. Not like do that or that – then that – but before you should do that
  6. Example: if you need to perform a mathematical algorithm you will probably use calculator or something like that, you can only do mathematical operations with that (like division, multiplication, addition, substraction, power etc). Calculator cannot do barrel roll to do that math algorithm
  7. I’ll try to give examples of that properties later
  8. 1) Finiteness – we need 5 steps to get result 2) Discreteness – each step is discrete 3) Clarity – we have comands like lay orange and cut 4) Accuracy - cut the orange in half vertically (NOT HORISONTALLY) but also that tutorial is specially designed for oranges. 5) Mass character – using that tutorial we can cut not only that but anyof the oranges in the world 6) Definiteness – if we follow these steps we will always have 6 pieces of orange in the end
  9. I won’t spend a lot of time on classification. Here I’d like to stress that in general algorithms never contain random processes. Here randomized means that in such of algorithms are used another algorithm for generating a sequence of numbers whose properties approximate the properties of sequences of random numbers.  2 – clear 3 – example of making a soup. We can put water to boil and peel and cut potatoes during that.
  10. Обозначение логарифма: log 𝑏 𝑁 = x Эта запись равнозначна следующей:  bx = N .
  11. I want to show you some algorithms, explain them code programming Strings/arrays are easy to understand, but the interview problems often require advanced algorithm to solve, such as dynamic programming, recursion, etc.
  12. But it’s still important to know when one sorting algorithm is better than another