pseudocode - What's the difference between pseudo code and Algorithm? -


what's difference between pseudo code , algorithm? can give me example? tried search online i'm still confused algorithm. pseudo code written in words, that. fail understand algorithm. there difference between alogrithm , code?

an algorithm sequence of steps no fixed representation. can described in high-level description, pseudocode or code in language.

more generically, program written in language, pseudocode or concrete sequence of steps can considered algorithm.

there's no fixed format pseudocode - can similar language or combination of languages, or can natural language description of algorithm.


as example, insertion sort algorithm.

a high-level description is:

keep sorted list starts off empty. each element in original list, insert correct position in sorted list. return sorted list.

a pseudo-code representation (as per wikipedia) is:

for ← 1 length(a)     x ← a[i]     j ←     while j > 0 , a[j-1] > x         a[j] ← a[j-1]         j ← j - 1     a[j] ← x 

and can write in java, c++, c or other language.

these representations of insertion sort algorithm.

* - there few variants of insertion sort, , these can all, in own right, considered algorithms, , there's ambiguity in above high-level description (which can lead different variants), let's ignore these aspects now.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -