# Data Structure Interview Questions and Answers

## Data Structure interview questions

These Data Structure questions have been designed for various interviews, competitive exams and entrance tests. We have covered questions on both basic and advanced concepts which will help you improve your skills to face interview questions on Data Structure.

## Who is this Data Structure interview questions designed for?

All the developers, programmers and software engineers will find these questions extremely useful. All freshers, BCA, BE, BTech, MCA and college students wanting to make a career in Software Development will be highly benefited by these questions.

## Data Structure interview questions topics

This section covers Data Structure topics like - binary search, linked list, queue, binary trees, stack, heap, hashing, recursion, merge sort etc.

## 1. What is data structure?

A data structure refers to the format for organizing and storing data. It makes data access more efficient. Data structure types include the array, the file, the record, the table, the tree, and so on.

## 2. When is a binary search best applied?

Binary search is a type of algorithm. It is best applied to search in a list in which the elements are already in order or sorted.

The binary search algorithm starts searching the list from the middle. If the middle value is not the correct one, then it will go on to search the top or the bottom half in a similar manner. The idea behind binary search itself is to cut down your search space by half after each comparison. And this is only possible if the dataset is sorted.

## 3. What is a linked list?

A linked list is a sequence of nodes in which each node is connected to the node following it. A linked list consists of nodes where each node contains a data field and a reference to the next node in the list. The elements in a linked list are linked using pointers.

## 4. What is a queue?

A queue is an ordered collection of items. In a queue, the addition of new items happens at one end, called the "rear" and the removal of existing items occurs at the other end, commonly called the "front". As an element enters the queue, it starts at the rear and makes its way toward the front.

This makes queue as FIFO(First in First Out) data structure, which means that element inserted first will be removed first.

## 5. What are binary trees?

A binary tree is one type of data structure that has two nodes, a left node, and a right node. It is made of nodes, where each node contains a "left" reference, a "right" reference, and a data element. The topmost node in the tree is called the root.

Binary trees are used to implement binary search trees and binary heaps.

## 6. What is a stack?

A stack is a data structure in which data is inserted and removed according to the last-in first-out (LIFO) principle, leaving the most recently added data on top.  You can think of a stack of books; you can remove only the top book, also you can add a new book on the top.