Data Structures 101: Introduction to Data Structures and Algorithms.

Data Structure

A data structure can simply be defined in layman's terms as a way of storing data on a computer. This storing of data has to be done in an effective way to enable efficient retrieval and processing operations. An array is one of the most commonly used data structure. Other complex data structures entail stacks, queues and linked lists.

Characteristic Description of Data Structures

  1. Linear - For this type, data is arranged in a linear sequence e.g., in an array.
  2. Non-Linear - This is the exact opposite of the linear type, where no sequence is followed during storage e.g., Tree and Graphs.
  3. Homogeneous - All elements stored are usually of the same type e.g., in an array.
  4. Non-Homogeneous - All elements stored are usually of different data types.
  5. Static - These are those whose sizes and associated memory locations are fixed.
  6. Dynamic - These expand or shrink depending on the application needs.

Algorithm

An algorithm is a defined set of instructions or logic written so as to enable a particular problem to be solved.

Every algorithm must satisfy the following characteristics:

  1. Input - There should be 0 or more inputs supplied to the algorithm.
  2. Output - There should be at least 1 output obtained.
  3. Definiteness - Every step of the algorithm should be clear and well-defined.
  4. Finiteness - The algorithm should have finite number of steps. (Big O notation - Time and Space complexity)
  5. Correctness - Every step of the algorithm must gebnerte a correct output.

NB:- An algorithm is said to be efficient and fast if it takes less time to execute and consumes less memory.