# Data Structure Interview Questions and Answers

#### Question 1. What is data-structure?

Answer. Data Structure is a way of organizing all data items that considers not only the elements stored but also their relationship to each other.

#### Question 2. What Are The Goals Of Data Structure?

Answer. It must rich enough in structure to reflect the actual relationship of data in real world. The structure should be simple enough for efficient processing of data.

#### Question 3. What is Data types?

Answer. A particular kind of data item, as defined by the values it can take, the programming language used, or the operations that can be performed on it.

#### Question 4. What is Primitive Data Structure?

Answer. Primitive data structures are basic structures and are directly operated upon by machine instructions.

#### Question 5. What is Linear data structures?

Answer. A data structure is said to be Linear, if its elements are connected in linear fashion by meAnswer of logically or in sequence memory locations.

#### Question 6. What is algorithm?

Answer. Algorithm is a step by step procedure, which defines a set of instructions to be executed in certain order to get the desired output.

#### Question 7. What is Memory Allocations in Data Structures?

Answer. Memory allocation is the process of setting aside sections of memory in a program to be used to store variables, and instances of structures and classes.

#### Question 8. What is Malloc( ) Function?

Answer. The malloc( ) function allocates a block of memory in bytes. The user should explicitly give the block sixe it requires of the use. The malloc( ) is like a request to the RAM of the system to allocate memoty.

#### Question 9. What is Calloc( ) Function?

Answer. This function works exactly similar to malloc( ) function except for the fact that it needs two arguments as against one argument required by malloc( ).

#### Question 10. What is Free( ) Function?

Answer. The free( ) function is used to de-allocate the previously allocated memory using malloc( ) or calloc( ) functions.

#### Question 11. What is Realloc( ) Function?

Answer. This function is used to resize the size of memory block, which is already allocated. It found use of in two situations :

• If the allocated memory block is insufficient for current application.
• If the allocated memory is much more than what is required by the current application.

#### Question 12. What is Recursion?

Answer. Recursion is one of the most powerful tools in a programming language, but one of the most threatening topics-as most of the beginners and not surprising to even experienced students feel.

#### Question 13. Types of Recursion in data structure?

Answer. There are two types of Recursion

• Direct recursion.
• Indirect recursion.

#### Question 14. What is Arrays?

Answer. An array is a data structure used to process multiple elements with the same data type when a number of such elements are known.

#### Question 15. What is One Dimensional Arrays?

Answer. A one-dimensional array is one in which only one subscript specification is needed to specify a particular element of the array.

#### Question 16. What is Two Dimensional Array?

Answer. Two dimensional arrays are also called table or matrix, two dimensional arrays have two subscripts. Two dimensional array in which elements are stored column by column is called as column major matrix.

#### Question 17. What is Strings?

Answer. Strings in C are stored as null character, '', terminated character arrays.

#### Question 18. What is Arrays of Strings?

Answer. An array of strings is just a two dimensional array of characters.

#### Question 19. What is Stacks?

Answer. A stack is a non-primitive linear data structure. It is an ordered list in which addition of new data item and deletion of already existing data item is done from only one end, known as top of stack(TOS).

#### Question 20. What is Push Operation?

Answer. The push operation is used to insert an element into the stack. The new element is added at the topmost position of the stack.

#### Question 21. What is Pop Operation?

Answer. The pop operation is used to delete the topmost element from the stack.

#### Question 22. What is Queue?

Answer. Queue is an abstract data structure, somewhat similar to stack. In contrast to stack, queue is opened at both end. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue).

#### Question 23. Why we do use Queue?

Answer. As queues follows FIFO method, they are used when we need to work on data-items in exact sequence of their arrival.

#### Question 24. What is Linked List in Data Structure?

Answer. There is a special data structure called Linked list that provides a more flexible storage system and it does not require the use of arrays.

#### Question 25. What is Singly Linked list in Data Structure?

Answer. A Singly Linked list is one in which all nodes are linked together in some sequential manner. Hence, it also called linear linked list. Clearly it has the beginning and the end.

#### Question 26. What is Doubly Linked list in Data structure?

Answer. A doubly linked list is one in which all nodes are linked together by multiple number of links which help in accessing both the successor node and predecessor node from the given node position. It provides bi-directional traversing.

#### Question 27. What is Circular Linked list in Data structure?

Answer. In a circular linked list, the last node contains a pointer to the first node of the list. We can have a circular singly linked list as well as a circular doubly linked list.

#### Question 28. What is Circular Doubly Linked list in Data structure?

Answer. A circular doubly linked list or a circular two-way linked list is a more complex type of linked list which contains a pointer to the next as well as the previous node in the sequence.

#### Question 29. What is Trees in Data Structure?

Answer. A tree is non-linear data structure in which items are arranged in a sorted sequence. It is used to impose a hierarchical structure on a collection of data items.

#### Question 30. What is Root?

Answer. It is specially designed data item in a tree. It is the first in the hierarchical arrangement of data items. The root node is the topmost node in the tree.

#### Question 31. What is Node?

Answer. Each data item in a tree is called a node.

#### Question 32. What is Degree of a Node?

Answer. The degree of a node of a tree is the number of subtrees having this node as a root. In other words, the degree is the number of descendants of a node. If the degree is zero, it is called a terminal or leaf node of a tree.

#### Question 33. What is Siblings?

Answer. The children nodes of a given parent node are called siblings.

#### Question 34. What is Edge?

Answer. It is a connecting line of two nodes. That is, the line drawn from one node to another node is called an edge.

#### Question 35. What is Binary Tree?

Answer. The binary tree is a fundamental data structure used in computer science. The binary tree is a useful data structure for rapidly storing sorted data and rapidly retrieving stored data.

#### Question 36. What is Strictly Binary Trees?

Answer. If every non-terminal node in a binary tree consists of non empty left subtree and right subtree, then such a tree is called strictly binary tree.

#### Question 37. What is Complete Binary Trees?

Answer. A complete binary tree is a binary tree that satisfies two properties. First, in a complete binary tree, every level, except possibly the last, is completely filled.

#### Question 38. What is Binary search trees?

Answer. A binary search tree, also known as an ordered binary tree, is a variant of binary tree in which the nodes are arranged in an order.

#### Question 39. What is Graph?

Answer. A graph is an abstract data structure that is used to implement the mathematical concept of graphs. It is basically a collection of vertices (also called nodes) and edges that connect these vertices.

#### Question 40. What is Graph Traversal?

Answer. Graph traversal is the problem of visiting all the nodes in a graph in a particular manner, updating and/or checking their values along the way.

#### Question 41. What is Shortest Path algorithm?

Answer. The shortest path problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is minimized.

#### Question 42. What is Sorting in Data Structure?

Answer. Sorting is nothing but storage of data in sorted order, it can be in ascending or descending order. The term Sorting comes into picture with the term Searching.

#### Question 43. What is Bubble Sort?

Answer. Bubble sorting is a simple sorting technique in which we arrange the elements of the list by forming pairs of adjacent elements.

#### Question 44. What is Selection Sort?

Answer. The selection sort technique is based upon the extension of the minimum/maximum technique.

#### Question 45. What is Insertion Sort?

Answer. An insertion sort is one that sorts a set of values by inserting values into an existing sorted file.

#### Question 46. What is Quick Sort?

Answer. It is one of the most popular sorting techniques. Quick sort possesses a very good average-case behaviour among all the sorting techniques. This is developed by C.A.R. Hoare.

#### Question 47. What is Merge Sort?

Answer. Merge sort is a sorting technique which divides the array into subarrays of size 2 and merge adjacent pairs.

#### Question 48. What is Heap Sort?

Answer. Heap Sort is one of the best sorting methods being in-place and with no quadratic worst-case scenarios.

#### Question 49. What is Shell Sort?

Answer. Shell sort is considered an improvement over insertion sort as it compares elements separated by a gap of several positions. This enables the element to take bigger steps towards its expected position.

#### Question 50. What is Radix Sort?

Answer. The idea is to consider the key one character at a time and to divide the entries, not into two sub lists, but into as many sub lists as there are possibilities for the given character from the key.