Memory leaks occur when the programmer forgets to free up memory after the program no longer needs it. Other times, a programmer may try to access a chunk of memory that has already been freed, leading to dangling pointers that can cause serious bugs or even crashes.
Showing posts with label Data Structure. Show all posts
Showing posts with label Data Structure. Show all posts
Saturday, 14 September 2013
Garbage collection .. !!
1.Garbage collection is the systematic recovery of pooled computer storage that is being used by a program when that program no longer needs the storage. This frees the storage for use by other programs (or processes within a program). It also ensures that a program using increasing amounts of pooled storage does not reach its quota (in which case it may no longer be able to function).
2.Garbage collection is an automatic memory management feature in many modern programming languages, such as Java and languages in the .NET framework. Languages that use garbage collection are often interpreted or run within a virtual machine like theJVM. In each case, the environment that runs the code is also responsible for garbage collection.
3.In older programming languages, such as C and C++, allocating and freeing memory is done manually by the programmer. Memory for any data that can't be stored within a primitive data type, including objects, buffers and strings, is usually reserved on the heap. When the program no longer needs the data, the programmer frees that chunk of data with an API call. Because this process is manually controlled, human error can introduce bugs in the code.
2.Garbage collection is an automatic memory management feature in many modern programming languages, such as Java and languages in the .NET framework. Languages that use garbage collection are often interpreted or run within a virtual machine like theJVM. In each case, the environment that runs the code is also responsible for garbage collection.
3.In older programming languages, such as C and C++, allocating and freeing memory is done manually by the programmer. Memory for any data that can't be stored within a primitive data type, including objects, buffers and strings, is usually reserved on the heap. When the program no longer needs the data, the programmer frees that chunk of data with an API call. Because this process is manually controlled, human error can introduce bugs in the code.
BUBBLE SORT - ALGORITHM !!
Let A be a list of n numbers .Sorting A refers to the operation of rearranging the elements of A so they are in increasing order .i.e .. so that ...
A[1] < A[2] < A[3] < ..... < A[N]
For example , suppose A is is originally in the list ..
8,4,19,2,7,13,5,16
After sorting ..
2,4,5,7,8,13,16,19
BUBBLE(DATA,N)
Here DATA is an array with N elements .This algorithm sorts the elements in DATA.
1.Repeat Steps 2 and 3 for i=1 to N-1.
2. set PTR = 1 [initialize pass pointer PTR ]
3. Repeat while PTR <= i - j [Executes pass ]
(a) If DATA[PTR]>DATA[PTR + 1] ,then
Interchange DATA[PTR] and DATA[PTR + 1]
[End of if structure ]
(b) Set PTR = PTR + 1
[End of inner loop ]
[End of step 1 outer loop]
4. EXIT
A[1] < A[2] < A[3] < ..... < A[N]
For example , suppose A is is originally in the list ..
8,4,19,2,7,13,5,16
After sorting ..
2,4,5,7,8,13,16,19
BUBBLE(DATA,N)
Here DATA is an array with N elements .This algorithm sorts the elements in DATA.
1.Repeat Steps 2 and 3 for i=1 to N-1.
2. set PTR = 1 [initialize pass pointer PTR ]
3. Repeat while PTR <= i - j [Executes pass ]
(a) If DATA[PTR]>DATA[PTR + 1] ,then
Interchange DATA[PTR] and DATA[PTR + 1]
[End of if structure ]
(b) Set PTR = PTR + 1
[End of inner loop ]
[End of step 1 outer loop]
4. EXIT
Thursday, 12 September 2013
TRAVERSING BINARY TREES !!
1.Process the root R.
2.Traverse the left subtree of R in preorder.
3.Traverse the right subtree of R in preorder.
INORDER
1.Traverse the left subtree of R in inorder.
2.Process the root R.
3.Traverse the right subtree of R in inorder.
POSTORDER
1.Traverse the left subtree of R in postorder.
2.Traverse the right subtree of R in postorder.
3.Process the root R.
Subscribe to:
Posts (Atom)