Turn Desktop View Off
by Dinesh Thakur

The function free() is used to de-allocate the memory allocated by the functions malloc ( ), calloc ( ), etc, and return it to heap so that it can be used for other purposes. The argument of the function free ( ) is the pointer to the memory which is to be freed. The prototype of the function is as below.



 
by Dinesh Thakur

The function is used to allocate contiguous blocks of memory of same size during the execution of the program. So, it may be applied for creating arrays of fundamental types as well as structures. The function malloc ( ) may also be used for the same purpose. The prototype of the function calloc () is given below.



 
by Dinesh Thakur

1 The process of extracting common properties from particular examples. In programming, it typically means replacing the specific numbers and strings in a particular instance of a problem by variables and functions, so that the same program can solve many problems of the same kind.

 
by Dinesh Thakur

Both the malloc() and the calloc() functions are used to allocate dynamic memory. Each operates slightly different from the other. malloc() takes a size and returns a pointer to a chunk of memory at least that big:



 
by Dinesh Thakur

The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur.



 
by Dinesh Thakur

malloc allocates memory for object in heap but doesn't invoke object's constructor to initiallize the object. new allocates memory and also invokes constructor to initialize the object. malloc() and free() do not support object semantics.



 
by Dinesh Thakur

The function realloc () is used to resize the memory allocated earlier by function malloc () to a new size given by the second parameter of the function. The function realloc(ptr,n) uses two arguments.the first argument ptr is a pointer to a block of memory for which the size is to be altered. The second argument n specifies the new size. The size may be increased or decreased.



 
by Dinesh Thakur

The malloc () function is used to allocate memory and has the following prototype:



 
by Dinesh Thakur

1.) “new and delete” are preprocessors while “malloc() and free()” are functions. we dont use brackets will calling new or delete.

2.) No need of allocate the memory while using “new” but in “malloc()” we have to use “sizeof()”.



 
by Dinesh Thakur

Record and record structures : The ::struct::record package provides a mechanism to group variables together as one data structure, similar to a 'C' structure. The members of a record can be variables or other records. However, a record can not contain circular record, i.e. records that contain the same record as a member.

 
by Dinesh Thakur

Consider the following three examples. What do they all have in common?

Chocolate Cream Pie :

(1) Heat milk, marshmallows and chocolate in 3-quart saucepan over low heat, stirring constantly, until chocolate and marshmallows are melted and blended. Refrigerate about 20 minutes, stirring occasionally until mixture mounds slightly when dropped from a spoon.

 
by Dinesh Thakur

Analysis of Algorithms (AofA) is a field in computer science whose overall goal is an understanding of the complexity of algorithms. While an extremely large amount of research is devoted to worst-case evaluations, the focus in these pages is methods for average-case and probabilistic analysis. Properties of random strings, permutations, trees, and graphs are thus essential ingredients in the analysis of algorithms.



 
by Dinesh Thakur

Following steps must be followed to plan any algorithm :

 

(1) Device Algorithm : Creating an algorithm is an art in which may never be fully automated. When we get the problem, we should first analyse the given problem clearly and then write down some steps on the paper.

 
by Dinesh Thakur

A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.

 
by Dinesh Thakur

The heap is where malloc(), calloc(), and realloc() get memory. Getting memory from the heap is much slower than getting it from the stack. On the other hand, the heap is much more flexible than the stack. Memory can be allocated at any time and deallocated in any order. Such memory isn't deallocated automatically; you have to call free().