Set - 2

Question 6 :

What is placement new?

Answer :

When you want to call a constructor directly, you use the placement new. Sometimes you have some raw memory that's already been allocated, and you need to construct an object in the memory you have. Operator new's special version placement new allows you to do it.

class Widget{
	public :
		Widget(int widgetsize);
		Widget* Construct_widget_int_buffer(void *buffer,int widgetsize){
			return new(buffer) Widget(widgetsize);

This function returns a pointer to a Widget object that's constructed within the buffer passed to the function. Such a function might be useful for applications using shared memory or memory-mapped I/O, because objects in such applications must be placed at specific addresses or in memory allocated by special routines.

Question 7 :

List out the areas in which data structures are applied extensively ?

Answer :

Compiler Design, Operating System, Database Management System, Statistical analysis package, Numerical Analysis, Graphics, Artificial Intelligence, Simulation

Question 8 :

If you are using C language to implement the heterogeneous linked list, what pointer type will you use?

Answer :

The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.

Question 9 :

What is the data structures used to perform recursion?

Answer :

Stack. Because of its LIFO (Last In First Out) property it remembers its caller so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls. Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.

Question 10 :

Whether Linked List is linear or Non-linear data structure?

Answer :

According to Access strategies Linked list is a linear one.

According to Storage Linked List is a Non-linear one