This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:programming:algorithms [2012/05/16 10:03] – raivo.sell | en:programming:algorithms [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | <note important> | + | |
- | Algoritm on samm-sammuline tegevusjuhis, | + | |
- | Lihtsustatud voodiagrammi elemendid: | + | |
- | ===== Algus ===== | + | The algorithm is a step-by-step instruction, |
+ | |||
+ | Simplified flowchart elements: | ||
- | Ring. | + | ==== Start ==== |
+ | |||
+ | Circle. | ||
{{: | {{: | ||
- | ===== Lõpp ===== | + | ==== End ==== |
- | Täidetud ring suurema ringi sees. | + | Filled circle inside bigger circle. |
{{: | {{: | ||
- | ===== Tegevus või avaldis ===== | + | ==== Action or expression |
- | Ristkülik, mille sisse on kirjutatud tegevuse nimetus või lühikirjeldus. Võib sisaldada ka koondatud ühetüübilisi tegevusi. | + | Rectangle. Inside rectangle a name of the action, name of the sub-routine or short description can be written. Similar actions can be included into one general action. |
- | {{:method:algorithms:tegevus.png|}} | + | {{:images:programming:algorithm_action.png|}} |
- | ===== Liikumine ===== | ||
- | Nool, mille suund näitab algoritmi kulgemist - järgmine täitmisele minev samm. | + | ==== Sequence ==== |
+ | |||
+ | Arrow, by pointing next activity. | ||
{{: | {{: | ||
- | ===== Kontrollplokk | + | ==== Condition / Decision |
- | + | ||
- | Romb, mille sisse on kirjutatud loogiline võrdlustehe. Tegemist on algoritmi hargnemisega, | + | |
- | {{: | + | Diamond (rhombus). Inside diamond is a logical expression and in most cases two arrows are drawn out from diamond. One is when logical expression results True (Yes/1) and other when expression result is False (No/0). Always both arrows have to be labeled. In special case only one arrow can be used as output from diamond. The case is when logical expression can clearly result only one solution, e.g. True. This is the case where for example endless cycle is used in program code (e.g. //while (true)//). |
- | ===== Andmevahetus ===== | + | {{: |
- | Trapets, mille sisse on kirjutatud tegevuse nimi. robotite juures tähendab üldjuhul kas andurite või täiturite kasutamist. soovi korral võib lihtsuse huvides selle objekti asendada tavalise tegevuse objektiga (ristkülik). | + | < |
+ | ==== Data exchange ==== | ||
- | {{: | + | Trapezoid. Inside trapezoid a name or activity is described. In robotics it is usually used to communicate with sensors and user. For simplification also normal rectangle action can be used instead of trapezoid. |
- | ===== Näited ===== | + | {{: |
- | Voodiagrammide koostamiseks võib kasutada tavalist kontoritarkvara nn MS Word või MS Excel, OpenOffice/ | + | ==== Examples ==== |
- | Mikrokontrollerite tarkvara algoritmide voodiagrammidel üldjuhul programmi lõppu ei ole ja kogu tegevus on ühes lõputus tsüklis. Lõputu tsükli väljumistingimus ei saa kunagi tõeseks ja sellepärast on lubatud selle tähistamine rombiga, millel on ainult üks väljund. tingimus ise on märgitud lihtsalt true või 1. Diagrammide koostamisel tuleks jälgida, et kui programmis on hargnemised, | + | Drawing flowchart diagrams one can use common office suits like MS Word or MS Excel or OpenOffice/ |
- | Järgnevad näited illustreerivad plokkide kasutamist algoritmi juures. Esimene näide | + | Flowcharts describing microcontroller software usually do not have ends, instead whole main activity in an endless cycle. The exit condition of the endless cycle will never be true and therefore this is the case where condition block (diamond) can be represented only on exiting arrow. Condition it self can be notes simply True or 1. Creating diagrams it is important to keep in eye on the fact that if the program has forks, it can be done only through the diamond object. Junctions (two arrows are joining) can be described by special symbol, but in simple cases, one may simply have an arrow point to another arrow instead. |
- | {{: | + | < |
+ | Following examples illustrate the use of flowchart elements for describing simple algorithm. First example is simple routine by describing one way flow without any cycle or decision points. | ||
- | Järgnev diagramm kirjeldab süsteemi, mis kontrollib | + | {{: |
+ | < | ||
+ | Following example describes a system which detects | ||
- | {{:method:algorithms:naide2.png?550|}} | + | {{:images:programming:algorithm_example2.png?550|}} |