You are on page 1of 18

Data Structures

Through C/C++

By

Yaman Singhania

http://www.computercareer.in

Introduction to Data Structures


What is DATA STRUCTURE?
A Data Structure is the way of Organizing the data for minimizing the use of memory and
for the use of updation or it is arranging the data in the main memory. In other words,
data structures are used to store the data or acts as a container.
Data Structures are basically divided into two parts :
1). Linear Data Structure
2). Non-Linear Data Structure
Linear Data Structure >
In Linear Data Structure A Sequence is followed.
Sequence means every data item will have an ancestor and a successor.
Example of Linear Data Structures are :
1. Queue
2. Linked List
3. Arrays
4. Stack

http://www.computercareer.in/

Introduction to Data Structures


Non-Linear Data Structures :
In Non-Linear Data Structures, No Sequence but hierarchy is followed.
Example of Non-Linear Data Structures are :
1. Tree
2. Graph
3. Tables
4. Sets
Data Structures stores data of different data types.What is DataType?
A Datatype is a collection of values in which operations can be performed.
Three Types of DataType in Data Structures are :
1. Primitive DataTypes
2. Abstract DataTypes (or User-Defined DataTypes)
3. Polymorphic DataTypes
4.

VISIT : OUR PROGRAMMING BLOG

http://www.computercareer.in/

Introduction to Data Structures


Primitive DataType : Primitive DataTypes are previously defined by the
Developers/Programmers and cannot be broken further.
For examples : int, float, Double, char, etc.
Abstract DataType : Abstract DataTypes are created by using Primitive DataTypes.
* Here the specification of the operations are separated from representation of the value
and implementation of the operation.
For examples : Array, Structure, Constructor etc.
Polymorphic DataType : Polymorphic DataTypes are independent of the value stored in the
list.
To perform Practical Codings ,
DOWNLOAD TURBO C : http://yamanturboc.blogspot.in/

http://www.computercareer.in/

Common Terms
Data : Data are the Raw Facts and Figures. Data word is always plural.
Information : Processed Data which have some meaningful values is called information.
Entity : Entity is Anything which have certain property and Attributes.
Domain : Domain is Set of Values which the Attributes can have.
Record : Collection of Homogeneous Entities are Record.
File : Collection of Homogeneous Records.
Key : A key is used to uniquely identify the record. Key is of following types:
Primary Key : Primary key uniquely identifies the identify a record in database table.
Unique Key : The Unique constraint uniquely identifies each record in a database table.
The Unique and Primary Key constraints both provide a guarantee for uniqueness for a
column or set of columns. A Primary Key constraint automatically has
a Unique constraint defined on it.
Candidate Key : A Candidate Key is a set of one or more fields/columns that can identify a
record uniquely in a table. There can be multiple Candidate Keys in one table. Each
Candidate Key can work as Primary Key.

Download : TURBO C

http://www.computercareer.in/

Common Terms and Array


Alternate Key : A Alternate key is a key that can be work as a primary key. Basically it is a
candidate key that currently is not primary key.
Compound Key : Composite Key is a combination of more than one fields/columns of a
table. It can be a Candidate key, Primary key.
Foreign Key : A Foreign Key is A Non Key Attribute whose values are derived from the
Primary Key of Another Table.
Let us Start Learning Data Structures from Linear Data Structures.

ARRAY Array is a Collection of data items consisting


Homogeneous DataType.

Types of Array
1. One -Dimentional
2. Two -Dimentional
3. Multi Dimentional
http://www.computercareer.in/

Array
How to Declare?
Int a[50];

Visit Our Programming Blog : www.computercareer.in/blog/

For Input and To print, We Use Loops ( for, while, do - while, do) .
Write A Program to take Input from User and Print the Array.
int a[5], i;
for( ( i = 0 ; i < = a[ i ] ; i++)
{
printf( Enter 5 numbers in an Array /n );
scanf(%d, &a[ i ]);
}
for( i = 0; i < = a[ i ] ; i++)
{
printf(%d, a[ i ]);
}}
DOWNLOAD : TURBO C
http://www.computercareer.in/

Array Program s
Write A Program to Perform Linear Search in An Array?
Download Our TURBO C
Write A Program to Perform Selection Sort in An Array?
to Perform Codings.
Write A Program to Perform Binary Search in An Array?
Write A Program to Perform Insertion Sort in An Array?
Write A Program to Perform Bubble Sort in An Array?
Write A Program to Illustrate Address Manipulation in 2-D Array?
To Learn Array, It is Necessary to Learn ALL THESE ARRAY PROGRAMS on Tips. Use Our Turbo C.

#include(iostream.h>
#include<conio.h>
int Lsearch(int[ ],int,int);
int main( )
{ For more, and To Learn All the Array Programs,
Please Visit : http://www.computercareer.in/blog
OR
Click Here

http://www.computercareer.in/

Stack and Queue


Stack is A Linear Data Structure in which we can Insert New Data & Delete the
existing data at a point called Top of the Stack. Stack always follow LIFO (Last in
First Out) Rule.

Stack can be represented as Array and Linked List.


Kindly Visit : http://www.computercareer.in/blog OR Click Here

http://www.computercareer.in/

Stack and Queue


Operations of Stack are :
1. Push To Insert a new element in the stack, we use PUSH.
2. Pop To Delete an existing element from the stack, we use POP.
3. IsOverflow To check Whether Stack is full or not, we use IsOverflow.
4. IsUnderflow To check Whether Stack is Empty or not, we use IsUnderflow.
5. Peek To Access the Top of the element of the Stack without deleting, we use
Peek.
We have Various Algorithms for these Operations to make you clear better the
concept of Stack.To Learn those Algorithms,
Visit : http://www.computercareer.in/blog OR Click Here
Download CTurbo : Click Here

http://www.computercareer.in/

Applications of Stack and Queue


Applications of Stack Are:
1. Infix to Postfix
2. Postfix to Infix
3. Infix to Prefix
4. Prefix to Infix
Queue
Queue is a Linear Data Structure in which we can Insert
and Delete items from Opposite ends.
There are two ends : front and rear. If we are inserting element from front and we
have to delete element from Rear.
Queue always follows FIFO (First In First Out).

http://www.computercareer.in/

Queue and Stack Programs


Types of Queues are :
1. Simple Queue
3. Priority Queue

2. Circular Queue
4. DeQueue (Doubled-Ended Queue)

Write A Program to Perform Insertion and Deletion in Circular Queue


Write A Program to Perform Infix to Postfix Conversion in Stack
Write A C Program for Implementing Queue Using Stack.
Write A Program to Perform Pushing in Stack.
For Solutions , Visit : http://www.computercareer.in/blog
We have Working Solutions of these Programs and We keep on adding
something New to Our Blog..So Dont forget to check out Website Daily and Be
Regular! ;)

http://www.computercareer.in/

Linked List
A Linked List is a data structure consisting of a group of nodes which together
represent a sequence.

Types of Linked Lists :


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 line of nodes.
Doubly Linked List : In a doubly linked list, each node contains, besides the nextnode link, a second link field pointing to the previous node in the sequence.
The two links may be called forward(s) and backwards,
Circular Linked List : In Circular Linked List, First Node contains the address of the
Last Node.

http://www.computercareer.in/

Operations in Linked List and Programs


Insertion in Linked List can be done by three ways :
1. Insertion At Beginning
2. Insertion At End
3. Insertion At Specified Position
Deletion in Linked List can be done by three ways :
1. Deletion from Beginning
2. Deletion from End
3. Deletion from Specified Position
Write A Program to Insert an Element at Beginning in Linked List.
Write A Program to Delete an Element from Beginning in Linked List.
For the Solutions of there Programs,
Kindly Visit : http://www.computercareer.in/blog or Click Here

http://www.computercareer.in/

Tree
A Tree is a Non-linear data structure made up of nodes or vertices and edges
without having any cycle. The tree with no nodes is called the Null or
Empty tree. A tree that is not empty consists of a root node and potentially
many levels of additional nodes that form a hierarchy.
Binary Tree - A binary tree is one in which each
node has at most two descendants. A node
can have just one but it cant have more than two.
Insertion in Binary Search Trees :
To insert any element in Binary Search Tree, we have
to compare with the root of node. If found Greater,
then insert at Right of root node. If found Smaller, then
Insert at left of root node.

http://www.computercareer.in/

Tree
Deletion from A Binary Tree
There are four possible cases that we need to consider :
1. No node in the Tree contains specified Data.
2. Node containing the data has no children.
3. Node containing the data has exactly one child.
4. Node containing the data has two children.

Kindly Check Our Blog for Programs related to Tree Data Structure.
http://www.computercareer.in/blog

http://www.computercareer.in/

Graph
A Non-Linear Data Structure that consist of a set of nodes called Vertexes and a
set of edges that relate the nodes to each other is called Graph.
Type of Graph :
Directed Graph When Edges in a Graph have A Direction, the graph is called
Diagraph or Directed Graph.

UnDirected Graph When Edges in a Graph has no direction, the graph is called
UnDirected Graph.
Graphs can be represented as array, linked lists and queues.
Check Our blog, http://www.computercareer.in/blog

http://www.computercareer.in/

Yaman Singhania

Thanks
For Watching

Visit : http://www.computercareer.in
http://www.facebook.com/Ysinghania500

You might also like