Types of Data Structure and Algorithms
Types of Data Structure and Algorithms

Types of Data Structure and Algorithms

Types of Data structures are classified into two types: Primitive and Non-Primitive.

Primitive Type:

  • Primitive data structures are the basic building blocks of any programming language. They include integers, floating-point numbers, characters, strings, and Booleans.
  • Primitive data structures are typically stored in a contiguous block of memory and can be accessed directly using their memory address.
DATA STRUCTUREDESCRIPTIONEXAMPLE
INTEGERNumbers with our decimal point1,2,3,4,5,300
FLOATNumbers with decimal point2.5, 5.6, 4.8, 67.8
CHARACTERSingle CharacterA, B, C, F, D
STRINGTextHello, Data DSA
BOOLEANLogical values true or falseTRUE AND FALSE

Non-Primitive:

  • Non-primitive data structures are more complex than primitive data structures and are typically used to store collections of data.
  • Examples of non-primitive data structures include arrays, linked lists, stacks, queues, trees, and graphs.
  • Non-primitive data structures are typically stored in a non-contiguous block of memory and must be accessed using a pointer.

Primitive data structures are typically more efficient than non-primitive data structures because they are stored in a contiguous block of memory and can be accessed directly using their memory address. However, non-primitive data structures are more versatile than primitive data structures and can be used to store more complex collections of data.

Types of Algorithms:

  1. Simple recursive algorithms
  • A Simple recursive algorithm calls itself with modified inputs until it reaches a base case, where the solution can be computed directly without further recursion.
  • These algorithms are characterized by their straightforward implementation and reliance on the concept of recursion, making them easy to understand and implement for problems that exhibit repetitive or self-similar structures.

2. Divide and conquer algorithms

  • Divide the problem into smaller subproblems of the same type, and solve these subproblems recursively.
  • Combine the solutions to the subproblems into a solution to the original problem.
    Examples: Quick sort and merge sort

3. Dynamic programming algorithms

  • They work based on memorization.
  • To find the best solution.

4. Greedy algorithms

  • We take the best we can without worrying about future consequences.
  • We hope that by choosing a local optimum solution at each step, we will end up at a global optimum solution.

5. Brute force algorithms

  • It simply tries all possibilities until a satisfactory solution is found.

6. Randomized algorithms

  • Use a random number at least once during the computation to make a decision.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *