## Interview and Exam Questions and Answers

This set contains a list of commonly asked questions. They are short interview questions aimed at freshers interview, campus placement drives, and also for job interviews. You can use these to have a quick grasp and brush-up of your fundamentals. These questions can be viewed on a mobile phone also because this website is built on responsive web design.

## What operations are implemented in a *linked list*?

Various operations implemented on a linked list are insert, delete, traverse and search.

## How do you define singly-linked list?

Singly linked lists contain nodes which have a data field as well as a next field, which points to the next node in the linked list.

A singly linked list whose nodes contain two fields: an integer value and a link to the next node.

## Draw the structure of a linked list.

first part represent data and second part represent address of next node

## Draw the structure of a linked list.

first part represent data and second part represent address of next node

## Write an algorithm for inserting a node at the beginning of the circular-linked list, when the list is not empty.

If the list is not empty, the following algorithm is used to insert a node in the linked list.

- Allocate a memory for a new node.
- Assign a value to the data field of the new node.
- Make the next field of new node point to the successor of LAST.
- Make the next field of LAST point to new node.

## Write an algorithm for *inserting* a node in a Singly-Linked list, if list is empty .

- Allocate memory for the new node.
- Assign a value to the data field of the new node.
- Make the next field of the new node point to NULL.
- Make START point to the new node

## Write algorithm for *inserting* node at the beginning of Singly-Linked list, if list is not empty .

To insert a node at the beginning of the linked list algorithm is:

- Allocate memory for the new node.
- Assign value to the data field of the new node.
- Make the next field of the new node point to the first node in the list.
- Make START point to the new node.

## How does the representation of a node in a doubly-linked list differ from that in a singly-linked list?

Unlike singly-linked list, in which each node stores the address of only the next node in the list, each node in a doubly-linked list holds the address of its previous node also.

## What are different types of linked list?

Singly-linked list, Doubly-linked list and Circular linked list

## Write an algorithm to insert a node between two nodes in the list, when the list is not empty.

If the list is not empty, the following algorithm is used to insert a node between two nodes in the linked list.

- Identify the nodes between which th new node is to be inserted. Mark them as previous and current. To locate previous and current, execute the following steps:
- Make current point to the first node.
- Make previous point to NULL.
- Repeat step d and e until current.info>newnode.info or previous=LAST
- Make previous point to current.
- Make current point to the next node in sequence.

- Allocate a memory fo new node.
- Assign a value to the data field of the new node.
- Make the next field of new node point to current.
- Make the next field of previous point to the new node.

## My C/C++ Videos on Youtube

Here is the complete playlist for video lectures and tutorials for the absolute beginners. The language has been kept simple so that anybody can easily understand them. I have avoided complex jargon in these videos.