Data Structures

  Home  Databases Programming  Data Structures


“Data structure is a specialized format for organizing and storing some data. Generally Data Structure types include array, file, record, table, tree, and so on. Interview Questions and Answers about any data structure is designed to organize your data to suit a specific knowledge so that it can be help full to you in your career. Data Structures Interview Questions and Answers are a simple guide to learn the basics of the Data Structures.”



48 Data Structures Questions And Answers

21⟩ What is a data structure node class?

A node class is a class that, relies on the base class for services and implementation, provides a wider interface to users than its base class, relies primarily on virtual functions in its public interface depends on all its direct and indirect base class can be understood only in the context of the base class can be used as base for further derivation

can be used to create objects. A node class is a class that has added new services or functionality beyond the services inherited from its base class.

 117 views

23⟩ Tell how to check whether a linked list is circular ?

Create two pointers, each set to the start of the list. Update each as follows:

while (pointer1)

{

pointer1 = pointer1->next;

pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next;

if (pointer1 == pointer2)

? ? ? ? ? ? {

print (”circularn”);

}

}

 136 views

24⟩ What is impact of signed numbers on the memory using Data Structures?

Sign of the number is the first bit of the storage allocated for that number. So you get one bit less for storing the number. For example if you are storing an 8-bit number, without sign, the range is 0-255. If you decide to store sign you get 7 bits for the number plus one bit for the sign. So the range is -128 to +127.

 131 views

27⟩ How memory is reserved using a declaration statement in data structure?

Memory is reserved using data type in the variable declaration. A programming language implementation has predefined sizes for its data types.

For example, in C# the declaration int i; will reserve 32 bits for variable i.

A pointer declaration reserves memory for the address or the pointer variable, but not for the data that it will point to. The memory for the data pointed by a pointer has to be allocated at runtime.

The memory reserved by the compiler for simple variables and for storing pointer address is allocated on the stack, while the memory allocated for pointer referenced data at runtime is allocated on the heap.

 150 views

28⟩ Is Pointer a variable in data structure?

Yes, a pointer is a variable and can be used as an element of a structure and as an attribute of a class in some programming languages such as C++, but not Java. However, the contents of a pointer is a memory address of another location of memory, which is usually the memory address of another variable, element of a structure, or attribute of a class.

 149 views

30⟩ What is significance of ” * ” ?

The symbol “*” tells the computer that you are declaring a pointer.

Actually it depends on context.

In a statement like int *ptr; the ‘*’ tells that you are declaring a pointer.

In a statement like int i = *ptr; it tells that you want to assign value pointed to by ptr to variable i.

 138 views

32⟩ Why do we Use a Multidimensional Array in data structure?

A multidimensional array can be useful to organize subgroups of data within an array. In addition to organizing data stored in elements of an array, a multidimensional array can store memory addresses of data in a pointer array and an array of pointers.

Multidimensional arrays are used to store information in a matrix form.

e.g. a railway timetable, schedule cannot be stored as a single dimensional array.

One can use a 3-D array for storing height, width and length of each room on each floor of a building.

 140 views

36⟩ What is a queue in data structure?

A Queue is a sequential organization of data in data structure. A queue is a first in first out type of data structure. An element is inserted at the last position and an element is always taken out from the first position.

 136 views

38⟩ What is the relationship between a queue and its underlying array?

Data stored in a queue is actually stored in an array. Two indexes, front and end will be used to identify the start and end of the queue.

When an element is removed front will be incremented by 1. In case it reaches past the last index available it will be reset to 0. Then it will be checked with end. If it is greater than end queue is empty.

When an element is added end will be incremented by 1. In case it reaches past the last index available it will be reset to 0. After incrementing it will be checked with front. If they are equal queue is full.

 136 views

39⟩ Why is the isEmpty() member method called?

The isEmpty() member method is called within the dequeue process to determine if there is an item in the queue to be removed i.e. isEmpty() is called to decide whether the queue has at least one element. This method is called by the dequeue() method before returning the front element.

 127 views