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 etc. SQL allows

Materialized View uses and Benefits in Database #DOTC_Mdb

Materialized View uses and Benefits in Database. Hello Everyone, Today we will discuss about Materialized view as it’s play important role in database. We already discussed about Simple Views and complex views in my previous blog. Before Materialized view go through my previous blog which related to simple view. https://dheeraj60.blogspot.com/2020/05/benefits-of-creating-and-using-view-in.html As we know View is not a database object and not like table which is stored in database, but view can be created from base table a view is an SQL statement that’s stored in the database. This statement, or view, has a name.A view looks and acts a lot like a table. It has columns and rows, and can be included in SELECT queries just like a table. In other word we can say View is a virtual/logical table which is basically used for security purpose. Let’s understand   about   Materialized view : A materialized view is a view that stores the results of the view’s query. Whenever you query the ma

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 some common columns or conditions and also by using alias to fulfill the condition.   There are various types of Joins as li