You are on page 1of 4

What is data structure?

Data structures refers to the way data is organized and manipulated.

What is a linked list?

A linked list is a sequence of nodes in which each node is connected to the node following it.
This forms a chain-like link of data storage.

In what areas do data structures applied?

Data structures is important in almost every aspect where data is involved. In general, algorithms
that involve efficient data structure is applied in the following areas: numerical analysis,
operating system, A.I., compiler design, database management, graphics, and statistical analysis,
to name a few.

Refer this link:

http://career.guru99.com/top-50-data-structure-interview-questions/

http://dharanyadevi.blogspot.in/2012/05/interview-viva-and-basics-of-data.html

http://www.vidyarthiplus.in/2011/09/data-structure-and-algorithm-viva.html

Stack
Stack is a linear data structure which follows a particular order in which the operations are
performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).

INSERTION DELETION AT TOP

Mainly the following three basic operations are performed in the stack:

Push: Adds an item in the stack. If the stack is full, then it is said to be an Overflow
condition.
Pop: Removes an item from the stack. The items are popped in the reversed order in
which they are pushed. If the stack is empty, then it is said to be an Underflow condition.
Peek: Get the topmost item.

Implementation:
There are two ways to implement a stack:

Using array
Using linked list
Application of Stack :

1. Balancing of symbols
2. Recursive Function
3. Expression Evaluation
4. Expression Conversion
o Infix to Postfix
o Infix to Prefix
o Postfix to Infix
o Prefix to Infix

Queue
Queue is a linear structure which follows a particular order in which the operations are performed. The
order is First In First Out (FIFO).

INSERT REAER DELETE FRONT

The difference between stacks and queues is in removing. In a stack we remove the item the most
recently added; in a queue, we remove the item the least recently added.

Operations on Queue:
Mainly the following four basic operations are performed on queue:

Enqueue: Adds an item to the queue. If the queue is full, then it is said to be an Overflow
condition.
Dequeue: Removes an item from the queue. The items are popped in the same order in which
they are pushed. If the queue is empty, then it is said to be an Underflow condition.
Front: Get the front item from queue.
Rear: Get the last item from queue.

Applications of Queue:
Queue is used when things dont have to be processed immediatly, but have to be processed
in First InFirst Out order like Breadth First Search. This property of Queue makes it also useful
in following kind of scenarios.

1) When a resource is shared among multiple consumers. Examples include CPU scheduling,
Disk Scheduling.
2) When data is transferred asynchronously (data not necessarily received at same rate as sent)
between two processes. Examples include IO Buffers, pipes, file IO, etc.

Linked List
Like arrays, Linked List is a linear data structure. Unlike arrays, linked list elements are not
stored at contiguous location; the elements are linked using pointers.

Why Linked List?


Arrays can be used to store linear data of similar types, but arrays have following limitations.
1) The size of the arrays is fixed: So we must know the upper limit on the number of elements in
advance. Also, generally, the allocated memory is equal to the upper limit irrespective of the
usage.
2) Inserting a new element in an array of elements is expensive, because room has to be created
for the new elements and to create room existing elements have to shifted.

For example, in a system if we maintain a sorted list of IDs in an array id[].

id[] = [1000, 1010, 1050, 2000, 2040].

And if we want to insert a new ID 1005, then to maintain the sorted order, we have to move all
the elements after 1000 (excluding 1000).
Deletion is also expensive with arrays until unless some special techniques are used. For
example, to delete 1010 in id[], everything after 1010 has to be moved.

Advantages over arrays


1) Dynamic size
2) Ease of insertion/deletion

Drawbacks:
1) Random access is not allowed. We have to access elements sequentially starting from the first
node. So we cannot do binary search with linked lists.
2) Extra memory space for a pointer is required with each element of the list.

Representation in C:
A linked list is represented by a pointer to the first node of the linked list. The first node is called
head. If the linked list is empty, then value of head is NULL.
Each node in a list consists of at least two parts:
1) data
2) pointer to the next node

TREE

Trees: Arrays, Linked Lists, Stack and queues, which are linear data structures, trees are hierarchical data
structures.
http://quiz.geeksforgeeks.org/binary-tree-set-1-introduction/

GRAPH

http://www.geeksforgeeks.org/graph-and-its-representations/

Define graph in DS

graph. (data structure) Definition: A set of items connected by edges. Each item is called a
vertex or node. Formally, a graph is a set of vertices and a binary relation between vertices,
adjacency.

Difference between directed and undirected graph

The difference is the same as between one directional and bidirectional streets - in directed
graph, the direction matters and you can't use the edge in the other direction. An undirected
graph can be simulated using a directed graph by using pairs of edges in both directions

You might also like