Posts

Showing posts from July, 2019

What is Bubble sort exactly is ?

Image
Bubble sort  algorithm    Bubble sort is a very simple and very  easy to implement  sorting technique Default arrange in  ascending order  logic  let's take an example, an example, we have a list of numbers stored in array                                                                                       logic start with comparison of first two element and if the left element is greater than right element they swap their position  Comparison proceeds till the end of array  logical illustration  ALGORITHM  Modified ALGORITHM :- Bubble_Sort(A,N): A is array of values and N is the number of element    Repeat step 2,3,&4 for round =1,2,3,....

Memory Management

Total memory allocation of a Program are divided into 4 parts  Instruction Data Stack   Heap what they store ? Instruction   --- store all lines and instruction in program . Data  --   global and static variable. Stack --  function , local , variable, variable in  function ,recursion time memory                           and loop (any memory that are needed for operation)                           time and various memory that are required at time while performing job . Heap -- dynamic created memory.(by malloc , new )  Instruction   and Data     both memory size are fix at the time of program start . 2. Stack and Heap     memory co...

What is Memory Leak? Discuss the importance.

Image
What is Memory Leak? First we have to understand memory management. Memory leak occurs when programmers create a memory in heap and forget to delete it. Memory leaks are particularly serious issues for programs like daemons and servers  Memory leakage occurs in C++ when programmers allocates memory by using new keyword and forgets to deallocate the memory by using delete() function or delete[] operator. One of the most memory leakage occurs in C++ by using wrong delete operator. The delete operator should be used to free a single allocated memory space, whereas the delete [] operator should be used to free an array of data values. In c /* Function with memory leak */ #include <stdlib.h> void f () { int *ptr = ( int *) malloc ( sizeof ( int )); /* Do some work */ return ; /* Return without freeing ptr*/ }  In c++ // Program with memory leak #include <bits/stdc++.h> using ...