Professional Documents
Culture Documents
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.
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.
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).
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).
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.
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.
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.
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