Posts

Showing posts from 2020

Data Structures - Linear Data Structures

Image
Data structure is an organizational way of storing data in the computer and it reduce the time and cost of data access. And also it can reduce the storage space of data. In this post, I am going to consider about Linear Data Structures (LDS). Under LDS, there are few popular data structures that are commonly used. 1. Array 2. Linked List 3. Stack 4. Queue Array Array is a data structure used to store data that are in same data type at contiguous spaces. The size of an array must be assigned before storing data. Each and every storage space can accessed separately. The index of array list starts from 0 and end with size -1.             Ex: int[] arr = new int[5];        or     int[] arr;                    or              int[] arr = {1,2,3,4,5};                     arr[0] = 1;                                        arr = new int[] {1,2,3,4,5};     When considering the size of array is equal to n.  Accessing Time   O(1)  because data are stored at near by spaces   Search Time        O(n

SOLID Principles

Image
In Object-Oriented Programming (OOP) Concept, SOLID principles are the acronym for five Object-Oriented Design (OOD) principles. These SOLID principles are used to improve the understand-ability, flexibility and maintainability of the code.   S.O.L.I.D. Stands For? 1.      S - Single-responsibility principle 2.      O - Open-closed principle 3.      L - Liskov substitution principle 4.      I - Interface segregation principle 5.      D - Dependency Inversion Principle   Let’s see what is the exact meaning of each principle using an example. Ex: There is an online store. A registered customer can place an order and purchase them using the card or make payment when delivering the order. Let’s move to the principles again.   1.      Single-Responsibility Principle The common definition of this principle is “A class should have one and only one reason to change, meaning that a class should have only one job.” When we consider the above online store, there is a class