DATA STRUCTURES



Admission Enquiry Form

What is an Algorithm ?

A sequence of steps or instructions to solve a particular problem. An algoritm has following properties:

Finiteness

The number of steps involved in an Algorithm to solve a problem must be finite.

Simplicity:

The steps involved in an algorithm must be simple, so that the output can be computed easily.

Input:

To solve any problem, the algorithm must recieve some input

Output:

The algorithm must produce at leat one output which is the solution to the problem.

Correctness

The algorithm must perform the task it is designed to perform, for all input values.

Generality

The procedure used in a specific algorithm should be applicable to all algorithms of same general form.

Variables in Algorithm.

Variables are always used in Capital Letters. e.g num variable will be used as NUM in Algorithm.

How to write some Operators in Algorithm ?

<- or :=   

This is used as Assignment operator in Algorithm.


Relational Operators in Algorithm.

<  

This is used as less than operator in Algorithm.

>  

This is used as greater than operator in Algorithm.

  

This is used as less than or equal to operator in Algorithm.

  

This is used as greater than or equal to operator in Algorithm.

=  

This is used as comparison operator in Algorithm.

  

This is used as not equal to operator in Algorithm.


and,or, not  

These are used as logical operators in Algorithm.

Arithmetic operators.

Arithmetic operators are used as it is they are used in program.


Increment and Decrement Operators in Algorithm.

Increment operators are used as e.g I = I + 1 where I is a variable.

Decrement operators are used as e.g I = I - 1 where I is a variable.




How to assign value to a variable in Algorithm ?

Assigning value to a variable in Algorithm e.g NUM <- 10
or NUM := 10



How to Print a string message in Algorithm ?

Write("Welcome to Compuhelp")


How to Print a variable in Algorithm ?

Write(NUM)


How to Print string message and variable in Algorithm ?

Write(“The value is”, NUM)



How to take input in Algorithm ?

Read(NUM)


How to use comments in algorithm ?

Single and Multiline comment. e.g [This is commented statement ] . Comments are used to make your Algorithm more descriptive and meaningful.



Syntax to use if statement in Algorithm.

If condition then

          [Statements]

          [End of If Structure]

 



Syntax to use if else statement in Algorithm ?

If condition then

          [Statements]

      Else

          [Statements]

        [End of If Else Structure]

 


Syntax to use if else if statement in Algorithm ?

If condition then

          [Statements]

     Else If condition then

          [Statements]

    [End of If Else If Structure]


Syntax to use for loop in Algorithm ?

Repeat Steps 3 to 5 For I <- 1 to 5 , I <- I+1

     //Steps 3 to 5

     [End of  For Loop]   


Syntax to use while loop in Algorithm.

Repeat Steps 3 to 5 

     While condition

            //Steps 3 to 5

         [End of  While Loop]      


Syntax of break and continue in Algorithm.

•Break
•Continue

Syntax to use Array in Algorithm.

•Here A[Size] is an array.
•In algorithm array indexing starts from 1
 

How to use Functions in Algorithm.


Function with no argument and no return.

SHOW()

      [Statements]

      Return


Function with argument and no return.

SHOW(A,B)

      [Statements]

      Return


Function with no argument and with return.

SHOW()

      [Statements]

      Return NUM


Function with argument and with return.

SHOW(A,B)

      [Statements]

      Return A


Algorithm of adding two values stored in two variables and display the result using third variable.

Step 1. START

Step 2. NUM1 := 10, NUM2 := 20

Step 3. RES := NUM1 + NUM2

Step 4. Write(“The sum is “, RES)

Step 5. END