Skip to main content

Overview of Algorithm in Computer Science and uses in Programming Language #DOTC_Mdb

Overview of  Algorithm in Computer Science and uses in Programming Language.

 

Hello Everyone ,

Today we will discuss about Algorithm as it’s very important for any Programmer to understand Algorithm to make program in simpler way. In simple word an algorithm can be defined as a step by step procedure for accomplishing a task. In the world of programming, an algorithm is a well-structured computational procedure that takes some values as input some values as output. Algorithms can have a wide variety of applications. In math, they can help calculate functions from points in a data set. Aside from their use in programming itself, they play major roles in things like file compression and data encryption.

Before Going to Importance of algorithm just need to understand how algorithm works to write any simple program.

For example Suppose  we write a simple program  in Pl/SQL to check if there is any records in table then update the table else insert the records in a table.

So doing this I come up with below Algorithm in PL/SQL:

 

1. Declare 1 variables, for storing the value from using function count in SQL.

 

2. We need to put that value in variable by using count function from that table by using select statement.

 

3. Check with conditional statement IF the count is greater than 0, It allows user to update the data in a table else automatically it will insert the records in table as it will check the condition as value stored in variable.

As this is a simple check condition program so we use only 3 steps and step-by-step process to create our program is what is known as Algorithm.

 

Below is the implementation Program for above requirement by using algorithim.

Declare

v_count number;

BEGIN

Select count(*) into v_count from employee;

If v_count >1

Update employee set salary =200000 where dept_id=20;

Else

Insert into employee values(‘20’,200000);

END IF;

END;

This is Anonymous block and we use simple step defined in algorithm.

Let’s take one another example in any language like C , C++ , Java etc to check whether the number is odd or even .

So I will come up with below Algorithm:

 

1. First, declare 2 variables.

First variable for storing the number from  the user will enter, 1 for storing the remainder after modulus by 2 in the second variable.

 

2. Provide the user a message informing to enter a number.

 

3. Allow the user to enter a number and store it in the first variable.

 

4. Divide in modulus by 2 and store the remainder in the second variable.

 

5. Check with conditional statement IF the remainder is equal to 0,  Display the result as Entered number is an even number  ELSE Display  the result as Entered number is an odd number.

 

Below is the implementation Program in C  for above requirement by using algorithm.

#include <stdio.h>

int main() {

    int i;

    printf("Enter any number: ");

    scanf("%d", &i);

    // checking if variable i is perfectly divisible by 2

    if(i % 2 == 0)

        printf("%d Entered number is an even number.", i);

    else

        printf("%d  Entered number is an even number ", i);

   

    return 0;

}

 

In Above Program we simply use above algorithm to write the program in simple manner.

Now we need to understand how algorithm play important role in computer Programming.

Importance of Algorithm in Computer Programming:

1. Improve the efficiency of a computer program: In computer programming, there are different ways of solving a problem. However, the efficiency of the methods available vary. Some methods are well suited to give more accurate answers than others. Algorithms are used to find the best possible way of solving a problem. In programming, efficiency can be used to mean different things. One of them is the accuracy of the software. With the best algorithm, a computer programmer will be able to give very accurate result. Another way of looking at the efficiency of software is performance. An algorithm can be used to improve the performance at which a program executes a problem. A single algorithm has the potential of reducing the time that a program takes to solve a problem in short period of time.

2. Utilization of resources : As we know computer has different resources. One of them is computer memory. During the execution phase, a computer program will require some amount of memory. Some programs use more memory space than others. The usage of computer memory depends on the algorithm that has been used. Apart from memory, and the algorithm can determine the amount of processing power that is needed by a program so right choice of an algorithm will ensure that a program consumes the least amount of memory and your program can work fast if you use the resources by using correct algorithm.

 

In Computer Programming there are different type of Algorithm and Different algorithms play different roles in programming. It dependends on you or programmer who can select the right algorithm to use.

Searching algorithms, Sorting algorithms ,Tree and graph-based algorithms,Compression algorithms, Pathfinding algorithm and  many others.

 

So finally , We can say Algorithm plays important role in computer programming as if you follow the algorithm your program is more efficient and also you can use steps to follow the program as per requirement and we can say for programmers it’s very easy for them to write the pieces of code in efficient manner as well as they can utilize correct resources to improve the performance of any code either written in C, C++ , Java etc.

Note: By creating algorithm you will be able to evaluate all the possible solution to specific problem.

Please go through this blog carefully and let me know if you have any doubts. Algorithm is very important for computer science graduate and also for the candidate who is preparing for interview and  Interviewer can ask the importance of algorithm in computer language. In next blog I will come up with another Topic.

Thanks


Comments

Post a Comment

Popular posts from this blog

SQL and Classification of SQL in Oracle Database #Diksha Oracle Training Centre

  SQL and Classification of SQL in Oracle Database.   SQL is Structured Query Language , which is used for storing, manipulating and retrieving data stored in a relational database .SQL is the standard language for RDBMS. All the Relational Database Management Systems (RDMS) like Oracle, MySQL, Sybase, Informix, IBM DB2 and Microsoft SQL Server use SQL as their standard database language. Oracle is one of the more secured database as compared to other databases. Importance of   SQL : SQL and PL/SQL is a backend process where all data is stored and retrieved in GUI which created either by any programming languages like Java, C++, PHP etc. so we need to have very secure database so that there will be no impact for users. SQL allows users to access data in the relational database management systems. SQL is used to communicate with a database.SQL and PL/SQL allows users to create and drop databases tables , views , stored procedures , functions , packages , trigger et...

Top 50 Interview Questions On SQL and PL/SQL #DOTC_Mdb

                    Top 50 Interview Questions On SQL and PL/SQL. Today we will Discuss Top 50 interview questions and answers of SQL and PL/SQL which is frequently asked in interview.     Question 1: What is SQL and Classification of SQL? Answer SQL is a Structure Query Language which is vastly used in RDBMS database like Oracle, Sybase, DB2 , Microsoft SQL server etc.   Classification of SQL is as below: DDL (Data Definition Language):  Commands are  create , alter , drop , truncate etc DML (Data Manipulation Language) : Commands are  insert,update and delete . TCL (Transaction Control Language ) : Commands are  Commit , Rollback and Save point. DCL (Data Control Language) : Commands are Grant , Revoke Question 2:    What is meant by Joins? What are the types of join? Answer Joins are basically used to extract/get data from multiple tables using s...

Aggregate Functions and Group By Clause in Oracle with Examples #Diksha Oracle Training Centre

  Aggregate Functions and Group By Clause Oracle with Examples.   Hello Everyone, Today I will   discuss about   Aggregate function in SQL by using Group By Clause and different clauses with some examples . Please go tjrough my previous blogs in Archive folder for classification of SQL, Commands and   SQL joins for your understanding.   Aggregate Functions Allows us to perform a calculation on a set of values to return a single value . We can use Group by Clause to group the result-set by one or more columns. Also we can use Having clause to restrict or filter the data as per our requirement. Note: Whenever we use Aggregate function in SQL we can’t able to use where condition. To restrict or filter the record we need to use having clause instead of Where. Below is the most commonly used Aggregate function in SQL.   MAX : Max function   used to get the maximum values in a set of values. COUNT : This function used to count rows in ...