• Home
  • About
  • Contact
  • ado.net
  • angular
  • c#.net
  • design patterns
  • linq
  • mvc
  • .net core
    • .Net Core MVC
    • Blazor Tutorials
  • sql
  • web api
  • dotnet
    • SOLID Principles
    • Entity Framework
    • C#.NET Programs and Algorithms
  • Others
    • C# Interview Questions
    • SQL Server Questions
    • ASP.NET Questions
    • MVC Questions
    • Web API Questions
    • .Net Core Questions
    • Data Structures and Algorithms

Sunday, August 2, 2020

Introduction to Data Structure and Algorithm

 Admin     August 02, 2020     Algorithm, Data Structure     No comments   

In this article, I am going to give you a brief introduction to Data Structure and Algorithm. At the end of this article, you will understand what is Data Structure and Algorithm, its type, and why we need data structure and algorithm as well as Variables and Data Types.

Variables:
let's take an simple mathematical equation.
x + y – 10 = 20 eq1.1
For now, we don’t need to worry about the equation. As we all can observe, the eq1.1 has some names which hold values(data). Similarly, in programming something required to hold data, and we called them variables. In eq1.1, x & y are variables which holds some data.

Data Types:
In eq1.1, x & y holds some data and the data may be integers or floats like 0,1, 0.5, -6.4 , -2 etc. A data type is a set of some predefined values like Integers, Floating points, character, strings etc. There are two types of data types.
  1. System – defined Data types (also called as Primitive data types)
  2. User – defined Data types
System Defined Data Types
Primitive data type defined by the system .It is provided by programming language. Example – int, float, char, bool, etc.

Allocation of bits for each primitive data type depends on programming language, operating system, and compiler. Different programming language may allocate different size for the same primitive data type.

User-Defined Data Types
In many cases to solve a problem, system-defined data types are not enough. To overcome this situation many programming languages allow the users to define their own data type called user define data types.

Data Structures in C/C++ and classes in java are good examples. Generally, user-defined data type is a combination of much primitive data type.
struct usrdef {
     int sysdef1;
    float sysdef2;
    bool sysdef3;
};
Data Structure
In computer science, a data structure is a data organization, management, and storage format that enables efficient access and modification. More precisely, a data structure is a collection of data values, the relationships among them, and the functions or operations that can be applied to the data.

In simple words, a data structure is a way of storing and organizing data so that it can be used efficiently.

Types of Data Structure:
Data Structure classified mainly into two types.
Linear Data Structure:- A Linear data structure have data elements arranged in a sequential manner and each member element is connected to its previous and next element.
Example:- LinkedList, stacks, queue, trees, graphs, etc.

Non-Linear Data Structures:- A non-linear data structure has no set sequence of connecting all its elements and each element can have multiple paths to connect to other elements.
Example:- Trees, Graphs.

For a better understanding of the classification of data structure please have a look at the following diagram.
Types of Data Structure

Key Differences between Linear and Non-Linear Data Structure
Differences between Linear and Non - Linear Data Structure

Advantages of Data Structures or why we need Data Structure?
We need data structures, few of them are as follows:
  1. They are essential ingredients in creating a fast and powerful algorithm.
  2. They help to manage and organize data.
  3. They make code cleaner and easier to understand.
Abstract Data Types
Basic operation like addition, multiplication, division, subtraction supported by primitive data type but for the user-defined data type, we need to define operations. such operations can be defined at the time of implementation.

In general, user-defined data types are defined along with their operations. The combination of data structures along with their operations is called Abstract Data Types (ADTs). It mainly consists of two parts.
  1. Declaration of data
  2. Declaration of operations
What is an Algorithm?
An algorithm is a set of one – by – one instruction to solve a particular problem.

Example:- Adding two numbers given by the users
Step 1: Start
Step 2: Declare variables no1, no2, and summation.
Step 3: Read values no1 and no2 that is provided by the user.
Step 4: Add no1 and no2 and assign the result to summation.
             summation ← num1 + num2
Step 5: Display summation
Step 6: Stop
Properties of a good algorithm
  1. Input and output should be clearly defined.
  2. Each step in the algorithm should be clear and unambiguous.
  3. Algorithms should be most effective among many different ways to solve a problem.
The algorithm should be written in such a way that it can be used in different programming languages. No coding is allowed.

In the next article, I am going to discuss the Analysis of Algorithm in detail. Here, in this article, I try to give a brief introduction to Data Structure and Algorithm and I hope you enjoy this article. I hope you enjoy this Introduction to Data Structure and Algorithm article. I would like to have your feedback. Please post your feedback, question, or comments about this article.

Summary:
I hope this post will be helpful to understand the Introduction to Data Structure and Algorithm
Please share this post with your friends and colleagues.
For any queries please post a comment below.
Happy Coding 😉
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post

0 comments:

Post a Comment

If you like this website, please share with your friends on Facebook, Twitter, LinkedIn.

Join us on Telegram

Loved Our Blog Posts? Subscribe To Get Updates Directly To Your Inbox

Like us on Facebook

Popular Posts

  • What is Dependency Injection(DI)
    Hi friends! Today we are going to learn about Dependency Injection and in our last session we have come across Static classes and where it s...
  • C# Programming Examples on Sorting
    Today i am going to tell you some of the Sorting programming questions in C#. Q1- Write a C# program to perform Selection sort. Ans:  Sel...
  • Calling Web API Service in a Cross-Domain Using jQuery AJAX
    In this article, I am going to discuss Calling Web API Service in a Cross-Domain Using jQuery AJAX . Please read our previous article befor...
  • ViewBag in ASP.NET Core MVC
    In this article, I am going to discuss the use of ViewBag in ASP.NET Core MVC application with examples. Please read our previous article ...
  • Recursion And Back Tracking
    In this article, I am going to discuss Recursion And BackTracking in detail. Please read our previous article where we discussed Master Th...
  • What is Abstract Class and When we should use Abstract Class
    Hi friends! In our previous sessions we have seen  Difference Between Class and Struct . And in our last session  we learnt Usability of Sec...
  • Binary to Decimal Conversion in C# with Examples
    In this article, I am going to discuss the Binary to Decimal Conversion in C# with some examples. Please read our previous article where w...

Blog Archive

Contact Form

Name

Email *

Message *

Tags

.Net .Net Core .Net Core MVC Algorithm Angular Anonymous Types Asp.Net Asp.Net MVC Blazor C# Data Structure Database Design Patterns Entity Framework Entity Framework Core Filters Interview Question Management Studio Programming Programs SQL Server SSMS Web API

Copyright © C# Techtics | All Right Reserved.

Protected by Copyscape