## DEV Community # Introduction to Data structures and Algorithms.

Have heard a lot techies talk about data structures and algorithms, Honestly speaking data structures and algorithms is a challenging topic. It needs consistency ,resilience and a lot of practice to crack it. Let's dive in:

1: What is an algorithms A finite sequence of steps for accomplishing some computational task.
2: what is a data structure Is an arrangement of data in memory locations to represent values of the carrier set of an abstract data type.

Properties of an algorithm

-The inputs must be specified, that is algorithm should have some inputs.
-The outputs must be specified, That is atleast one output should be returned by the algorithm after the completion of the specific task based on the given inputs.
-Definiteness- Every statement of the algorithm should be unambiguous.
-Effectiveness- Writing an algorithm is a prior process of actual implementation of the algorithm. So I need to analyze the algorithm in a finite amount of time with a pen and paper to judge the performance for giving the final version of the algorithm.
-finiteness- No infinite loop should be allowed in an algorithm. Characteristics of an algorithm

-It's a step by step procedure for solving any problem an algorithms recognizes.
-Being finite set of instructions, if followed it accomplishes a particular task.
-Being a sequence of computational steps it transforms inputs to valuable or required output.

Types of an algorithm

-recursive algorithm- Its the most interesting because it calls itself repeatedly until the problem is solved.
-Divide and conquer algorithm- Its divides the algorithm into two parts. The first parts divide the problem on hand into smaller subproblems of the same type. The second part the smaller problems are solved the added together to give the final solution.
-Dynamic programming algorithms- Solves complex problems by breaking them into multiple simple sub problems and the its solves each of them once and then stores them for future reference.
-Greedy algorithm- Used for solving optimization problems. Its not guaranteed to be able to find an optimal solution. Its components are:

1: The first one is a candidate set from which we try to find a solution.
2: A selection function that helps choose the best possible candidate.
3: A feasibility function that helps in deciding if the candidate can be used to find a solution.
4: Solution function that tells when we have found a solution to the problem.

-Brute force Algorithms- Its the simplest algorithms in the concept.it blindly iterates all possible solution to search one or more than one solution that may solve a function.

Data structures
A data structure is not language specific you can use any programming language. its a set of algorithm that we can use to structure the data in the memory. By so doing 'n' number of algorithm are proposed and now all these algorithms are termed as "Abstract data types" ADT gives us the blueprint while data structure provides the implementation part. Types of data structures

-Primitive data structures- These are primitive data types. i.e. char, int, float, double and pointer are primitive data structures that can hold a single value.
-Non primitive data structures- Are divided into two types:
1. Linear data structures- its the arrangement of data in a sequential manner examples are: Arrays, linked lists, Stacks and Queues. A element is connected to only one another element in a linear form.
2. Non-linear data structures- This one element is connected to the 'n' number of elements. example: Trees and Graphs.

Data structures can also be classified as:

• Static data structure- Here the size is allocated at the compile time, So the maximum size is fixed.
• Dynamic data structure- Here the size is allocated at the run time, so the maximum size is flexible.

Major operations on data structures

• Searching- we can search any element in a data structure.
• Sorting- We can sort the elements of a data structure in an ascending or descending order.
• Insertion- we can insert new elements in a data structure.
• Updation- we can replace the element with another element.
• Deletion- we can delete an element from the data structure.

Merits of a data structure

• Efficiency- when the chosen data structure for implementing a certain ADT is good. Then its efficient in time and space.
• Reusability-Multiple client programs can use the data structure.
• Abstraction- ADT specifies a data structure that provides a level of abstraction, This means a client cannot see the internal working of the data structure, so it doesn't have to stress about the implementation part.

Conclusion

I bet by the end of the article you will have a glimpse of what data structures and algorithms are, implementation, types and how there are used. Cheers am open to comments and additions.