Posts

Showing posts with the label algorithm analysis

Types of Algorithms analysis

To analyse the given algorithm we need to know on which inputs the algorithm will takes less time and long time. We have already seen that an algorithm can be represented in the form of an expression.  That means we represent the algorithm with multiple expressions: one of the case where it takes less time and other for the case where it takes the more time. In general the first case is called the ‘Best Case’ and second case is called the ‘Worst Case’ of the algorithm. To analyse an algorithm we need some kind of syntax and that forms the base for asymptotic analysis/notation. There are three types of analysis: Worst Case: Defines the input for which the algorithm takes long time. Input is the one for which the algorithm runs the slower. Best Case: Defines the input for which the algorithm takes lowest time. Input is the one for which the algorithm runs the fastest. Average Case: Provides a prediction about the running time of the algorithm. Assumes that the

Basics of Data Structures and Algorithms

Data Structure: Data Structure is a particular way of storing and organizing data in a computer. So, that it can be used efficiently. We can also say in the way of data structure is a special format for organizing and storing data. General data structure types include arrays, files, linked list, stacks, queues, trees, graphs and so on. Depending on the organization of the elements, data structures are classified into two types. Linear Data Structures:  Elements are accessed in a sequential order. But, it not compulsory to store all elements in sequentially. Ex: Linked List, stacks and Queues. Non-Linear Data Structures:  Elements of this data structures are sorted/accessed in a non-linear order. Ex: Trees and Graphs. Algorithms: The formal definition of an algorithm is the step-by-step instructions to solve a given problem. Let us consider the problem of preparing an omelet. For preparing omelet, general steps we follow are: Get the frying pan Get the oil a. Do we hav