what is an algorithm? what are the characteristics of an algorithm.
Answers
Answer:
A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer is called Algorithm.
★ Characteristics of an algorithm:-
- Each of its steps, and their inputs/outputs should be clear and must lead to only one meaning.
- Input - An algorithm should have 0 or more well-defined inputs.
- Output - An algorithm should have 1 or more well-defined outputs, and should match the desired output.
☛ᴀʟɢᴏʀɪᴛʜᴍ ɪs ᴀ sᴛᴇᴘ-ʙʏ-sᴛᴇᴘ ᴘʀᴏᴄᴇᴅᴜʀᴇ, ᴡʜɪᴄʜ ᴅᴇғɪɴᴇs ᴀ sᴇᴛ ᴏғ ɪɴsᴛʀᴜᴄᴛɪᴏɴs ᴛᴏ ʙᴇ ᴇxᴇᴄᴜᴛᴇᴅ ɪɴ ᴀ ᴄᴇʀᴛᴀɪɴ ᴏʀᴅᴇʀ ᴛᴏ ɢᴇᴛ ᴛʜᴇ ᴅᴇsɪʀᴇᴅ ᴏᴜᴛᴘᴜᴛ. ᴀʟɢᴏʀɪᴛʜᴍs ᴀʀᴇ ɢᴇɴᴇʀᴀʟʟʏ ᴄʀᴇᴀᴛᴇᴅ ɪɴᴅᴇᴘᴇɴᴅᴇɴᴛ ᴏғ ᴜɴᴅᴇʀʟʏɪɴɢ ʟᴀɴɢᴜᴀɢᴇs, ɪ.ᴇ. ᴀɴ ᴀʟɢᴏʀɪᴛʜᴍ ᴄᴀɴ ʙᴇ ɪᴍᴘʟᴇᴍᴇɴᴛᴇᴅ ɪɴ ᴍᴏʀᴇ ᴛʜᴀɴ ᴏɴᴇ ᴘʀᴏɢʀᴀᴍᴍɪɴɢ ʟᴀɴɢᴜᴀɢᴇ.
☛ғʀᴏᴍ ᴛʜᴇ ᴅᴀᴛᴀ sᴛʀᴜᴄᴛᴜʀᴇ ᴘᴏɪɴᴛ ᴏғ ᴠɪᴇᴡ, ғᴏʟʟᴏᴡɪɴɢ ᴀʀᴇ sᴏᴍᴇ ɪᴍᴘᴏʀᴛᴀɴᴛ ᴄᴀᴛᴇɢᴏʀɪᴇs ᴏғ ᴀʟɢᴏʀɪᴛʜᴍs
sᴇᴀʀᴄʜ − ᴀʟɢᴏʀɪᴛʜᴍ ᴛᴏ sᴇᴀʀᴄʜ ᴀɴ ɪᴛᴇᴍ ɪɴ ᴀ ᴅᴀᴛᴀ sᴛʀᴜᴄᴛᴜʀᴇ.
sᴏʀᴛ − ᴀʟɢᴏʀɪᴛʜᴍ ᴛᴏ sᴏʀᴛ ɪᴛᴇᴍs ɪɴ ᴀ ᴄᴇʀᴛᴀɪɴ ᴏʀᴅᴇʀ.
ɪɴsᴇʀᴛ − ᴀʟɢᴏʀɪᴛʜᴍ ᴛᴏ ɪɴsᴇʀᴛ ɪᴛᴇᴍ ɪɴ ᴀ ᴅᴀᴛᴀ sᴛʀᴜᴄᴛᴜʀᴇ.
ᴜᴘᴅᴀᴛᴇ − ᴀʟɢᴏʀɪᴛʜᴍ ᴛᴏ ᴜᴘᴅᴀᴛᴇ ᴀɴ ᴇxɪsᴛɪɴɢ ɪᴛᴇᴍ ɪɴ ᴀ ᴅᴀᴛᴀ sᴛʀᴜᴄᴛᴜʀᴇ.
ᴅᴇʟᴇᴛᴇ − ᴀʟɢᴏʀɪᴛʜᴍ ᴛᴏ ᴅᴇʟᴇᴛᴇ ᴀɴ ᴇxɪsᴛɪɴɢ ɪᴛᴇᴍ ғʀᴏᴍ ᴀ ᴅᴀᴛᴀ sᴛʀᴜᴄᴛᴜʀᴇ.
ᴄʜᴀʀᴀᴄᴛᴇʀɪsᴛɪᴄs ᴏғ ᴀɴ ᴀʟɢᴏʀɪᴛʜᴍ:-
ɴᴏᴛ ᴀʟʟ ᴘʀᴏᴄᴇᴅᴜʀᴇs ᴄᴀɴ ʙᴇ ᴄᴀʟʟᴇᴅ ᴀɴ ᴀʟɢᴏʀɪᴛʜᴍ. ᴀɴ ᴀʟɢᴏʀɪᴛʜᴍ sʜᴏᴜʟᴅ ʜᴀᴠᴇ ᴛʜᴇ ғᴏʟʟᴏᴡɪɴɢ ᴄʜᴀʀᴀᴄᴛᴇʀɪsᴛɪᴄs −
- ᴜɴᴀᴍʙɪɢᴜᴏᴜs − ᴀʟɢᴏʀɪᴛʜᴍ sʜᴏᴜʟᴅ ʙᴇ ᴄʟᴇᴀʀ ᴀɴᴅ ᴜɴᴀᴍʙɪɢᴜᴏᴜs. ᴇᴀᴄʜ ᴏғ ɪᴛs sᴛᴇᴘs (ᴏʀ ᴘʜᴀsᴇs), ᴀɴᴅ ᴛʜᴇɪʀ ɪɴᴘᴜᴛs/ᴏᴜᴛᴘᴜᴛs sʜᴏᴜʟᴅ ʙᴇ ᴄʟᴇᴀʀ ᴀɴᴅ ᴍᴜsᴛ ʟᴇᴀᴅ ᴛᴏ ᴏɴʟʏ ᴏɴᴇ ᴍᴇᴀɴɪɴɢ.
- ɪɴᴘᴜᴛ − ᴀɴ ᴀʟɢᴏʀɪᴛʜᴍ sʜᴏᴜʟᴅ ʜᴀᴠᴇ 0 ᴏʀ ᴍᴏʀᴇ ᴡᴇʟʟ-ᴅᴇғɪɴᴇᴅ ɪɴᴘᴜᴛs.
- ᴏᴜᴛᴘᴜᴛ − ᴀɴ ᴀʟɢᴏʀɪᴛʜᴍ sʜᴏᴜʟᴅ ʜᴀᴠᴇ 1 ᴏʀ ᴍᴏʀᴇ ᴡᴇʟʟ-ᴅᴇғɪɴᴇᴅ ᴏᴜᴛᴘᴜᴛs, ᴀɴᴅ sʜᴏᴜʟᴅ ᴍᴀᴛᴄʜ ᴛʜᴇ ᴅᴇsɪʀᴇᴅ ᴏᴜᴛᴘᴜᴛ.
- ғɪɴɪᴛᴇɴᴇss − ᴀʟɢᴏʀɪᴛʜᴍs ᴍᴜsᴛ ᴛᴇʀᴍɪɴᴀᴛᴇ ᴀғᴛᴇʀ ᴀ ғɪɴɪᴛᴇ ɴᴜᴍʙᴇʀ ᴏғ sᴛᴇᴘs.
- ғᴇᴀsɪʙɪʟɪᴛʏ − sʜᴏᴜʟᴅ ʙᴇ ғᴇᴀsɪʙʟᴇ ᴡɪᴛʜ ᴛʜᴇ ᴀᴠᴀɪʟᴀʙʟᴇ ʀᴇsᴏᴜʀᴄᴇs.
- ɪɴᴅᴇᴘᴇɴᴅᴇɴᴛ − ᴀɴ ᴀʟɢᴏʀɪᴛʜᴍ sʜᴏᴜʟᴅ ʜᴀᴠᴇ sᴛᴇᴘ-ʙʏ-sᴛᴇᴘ ᴅɪʀᴇᴄᴛɪᴏɴs, ᴡʜɪᴄʜ sʜᴏᴜʟᴅ ʙᴇ ɪɴᴅᴇᴘᴇɴᴅᴇɴᴛ ᴏғ ᴀɴʏ ᴘʀᴏɢʀᴀᴍᴍɪɴɢ ᴄᴏᴅᴇ.