CIE Important Questions
NEHA UNNISA
Asst Professor
CSE Department ( H & S)
C PROGRAMMING
Algorithm | Pseudocode |
---|---|
It is defined as a sequence of well-defined steps. These steps provide a solution/ a way to solve a problem in hand. | It can be understood as one of the methods that helps in the representation of an algorithm. |
It is a systematic, and a logical approach, where the procedure is defined step-wise | It is a simpler version of coding in a programming language. |
Algorithms can be represented using natural language, flowchart and so on. | It is written in plain English, and uses short phrases to write the functionalities that s specific line of code would do. |
This solution would be translated to machine code, which is then executed by the system to give the relevant output. | There is no specific syntax which is actually present in other programming languages. This means it can't be executed on a computer. |
pseudocode for bubble sort
function BUBBLESORT(ARRAY)
# loop through the array multiple times
loop INDEX from 0 to size of ARRAY – 1
# consider every pair of elements except the sorted ones
loop INDEX2 from 0 to size of ARRAY – 2 – INDEX
if ARRAY[INDEX2] > ARRAY[INDEX2 + 1] then
# swap elements if they are out of order
TEMP = ARRAY[INDEX2]
ARRAY[INDEX2] = ARRAY[INDEX2 + 1]
ARRAY[INDEX2 + 1] = TEMP
end if
end loop
end loop
end function
Comments
Post a Comment