86
practice, the state is stored in one or more data structures. For some
such computational process, the algorithm must be rigorously defined:
specified in the way it applies in all possible circumstances that could
arise. That is, any conditional steps must be systematically dealt with,
case-by-case; the criteria for each case must be clear (and computable).
Because an algorithm is a precise list of precise steps, the order of
computation is always critical to the functioning of the algorithm.
Instructions are usually assumed to be listed explicitly, and are
described as starting "from the top" and going "down to the bottom",
an idea that is described more formally by flow of control. So far,
this discussion of the formalization of an algorithm has assumed the
premises of imperative programming. This is the most common
conception, and it attempts to describe a task in discrete, "mechanical"
means. Unique to this conception of formalized algorithms is the
assignment operation, setting the value of a variable. It derives from the
intuition of "memory" as a scratchpad. There is an example below of
such an assignment.
10
Blok-sxemalarni tuzishda foydalaniladigan asosiy sodda geometrik
figuralar quyidagilardan iborat
Nomi
Belgilanishi
Bajaradigan vazifasi
Jarayon
Bir yoki bir nechta
amallarni bajarilishi natijasida
ma‘lumotlarning uzgarishi
Qaror
Biror shartga boglik
ravishda algoritmning bajarilish
yo‘nalishini tanlash
SHakl
uzgartirish
Dasturni
uzgartiruvchi
buyruk yoki buyruklar
turkumini uzgartirish amalini
bajarish
Avval
aniqlangan
jarayon
Oldindan ishlab chikilgan
dastur yoki algoritmdan
foydalanish
Kiritish
Chiqarish
Axborotlarni kayta ishlash
mumkin bo‘lgan shaklga
10
Richard L. Halterman Fundamentals of C++ Programming. Copyright © 2008–2016. All rights reserved. pg.82
87
utkazish yoki
olingan natijani
tasvirlash
Displey
kompyuterga ulangan
displeydan axborotlarni kiritish
yoki chiqarish
Hujjat
Axborotlarni kogozga
chiqarish yoki kogozdan kiritish
Blok-sxemalar bilan ishlashni yaxshilab o‗zlashtirib
olish zarur, chunki
bu usul algoritmlarni ifodalashning qulay vositalaridan biri bo‗lib
programma tuzishni osonlashtiradi, programmalash qobiliyatini
mustahkamlaydi. Algoritmik tillarda blok - sxemaning asosiy strukturalariga
maxsus operatorlar mos keladi.
Shuni aytish kerakni, blok-sxemalardagi yozuvlar odatdagi yozuvlardan
katta
farq
qilmaydi.
Misol sifatida
ax
2
+bx+c=0
kvadrat tenglamani yechish algoritmining blok-
sxemasi quyida keltirilgan.
Kvadrat tenglamani yechish algoritmi chiziqli algoritmlar.
Har qanday murakkab algoritmni ham uchta asosiy struktura
yordamida tasvirlash mumkin. Bular ketma-ketlik, ayri va takrorlash
strukturalaridir. Bu strukturalar asosida chiziqli, tarmoqlanuvchi va
takrorlanuvchi hisoblash jarayonlarining algoritmlarini tuzish mumkin.
Umuman
olganda, algoritmlarni shartli ravishda quyidagi turlarga ajratish
mumkin:
chiziqli algoritmlar;
tarmoqlanuvchi algoritmlar;
88
takrorlanuvchi yoki siklik algoritmlar;
ichma-ich joylashgan siklik algoritmlar;
rekurrent algoritmlar;
takrorlanishlar soni oldindan no‘malum algoritmlar;
ketma-ket yaqinlashuvchi algoritmlar.
Faqat ketma-ket bajariladigan amallardan tashkil
topgan algoritmlarga-
chiziqli algoritmlar deyiladi. Bunday algoritmni ifodalash uchun ketma-
ketlik strukturasi ishlatiladi. Strukturada bajariladigan amal mos keluvchi
shakl bilan ko‗rsatiladi. Chiziqli algoritmlar blok-sxemasining umumiy
strukturasini quyidagi ko‗rinishda ifodalash mumkin:
Do'stlaringiz bilan baham: