This blog is under construction

Saturday, 16 February 2013

Algorithm, Program, Data Structure and Pseudocode

What is an algorithm?

An algorithm is a set of instructions that can be used for solving a problem.  An efficient algorithm is the one that takes less running time and memory.

Algorithm to swap two numbers:
Step 1: Start
Step 2: Input two numbers(val1 and val2)
Step 3: Assign "val1" to a temporary variable (temp)
Step 4: Assign "val2" to  "val1"
Step 5: Assign "temp" to "val2"
Step 6: Display values in val1 & val2

What is a program?

Program is nothing but implementation of an algorthim using any programming language(Eg: C, C++, Java etc)

C program to swap two numbers:
int main() {
int val1, val2, temp;
printf("Enter two numbers:");
scanf("%d%d", &val1, &val2);
temp = val1;
val1= val2;
val2 = temp;
printf("After swapped: %d  %d\n", val1, va2);
return 0;

What is a pseudocode?
It is a combination of both natural and programming language which can be used to explain the generic implementation of an algorithm.

Pseudocode to swap two numbers:
swap(a, b)
t  <- a
a <- b
b <- t
return a, b

What is a data structure?

Organizing, storing and retrieving needed data to solve a problem.
Eg: Arrays, Lists, Stack etc.
char str[5][10] = {"English", "Math", "Physics", "Computer", "Biology"};

See Also:
Data Structure Programs In C


  1. perfect explanation about java programming .its very useful.thanks for your valuable training in chennai | best java training in velachery

  2. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Best Hadoop training in chennai

  3. Thanks a lot very much for the high your blog post quality and results-oriented help. I won’t think twice to endorse to anybody who wants and needs support about this area.
    datascience training in chennai

  4. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

    DevOps Training in Bangalore

  5. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
    rpa training in chennai

  6. This comment has been removed by the author.

  7. Nice Blog, The way you have explained about the things is very well and the suggestions are the best.
    Read how to Protect your computer from online hackers.