




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
DBMS NOtes for b.tech students. They can refer for the exam.
Typology: Schemes and Mind Maps
1 / 153
This page cannot be seen from the preview
Don't miss anything!
Recognized under 2(f) and 12 (B) of UGC ACT 1956
(Affiliated to JNTUH, Hyderabad, Approved by AICTE - Accredited by NBA & NAAC – ‘A’ Grade - ISO 9001:2015 Certified)
Maisammaguda, Dhulapally (Post Via. Hakimpet), Secunderabad – 500100, Telangana State, India
Prerequisites: A course on ―Programming for Problem Solving‖.
Course Objectives:
To impart the basic concepts of data structures
Exploring basic data structures such as stacks queues and lists.
Introduces a variety of data structures such as hash tables, search trees, heaps, graphs.
To understand concepts about searching and sorting techniques
Introduction : Abstract data types, Singly linked list: Definition, operations: Traversing,
Searching, Insertion and deletion, Doubly linked list: Definition, operations: Traversing,
Searching, Insertion and deletion ,Circular Linked List: Definition, operations: Traversing,
Searching, Insertion and deletion.
Stack: Stack ADT, array and linked list implementation, Applications- expression conversion
and evaluation. Queue : Types of Queue: Simple Queue, Circular Queue, Queue ADT- array
and linked list implementation. Priority Queue, heaps.
Searching: Linear and binary search methods. Sorting: Selection Sort, Bubble Sort, Insertion
Sort, Quick Sort, Merge Sort, Heap Sort. Time Complexities .Graphs: Basic terminology,
representation of graphs, graph traversal methods DFS,BFS
Dictionaries: linear list representation, skip list representation, operations - insertion, deletion
and searching. Hash Table Representation: hash functions, collision resolution- separate
chaining, open addressing-linear probing, quadratic probing, double hashing, rehashing,
extendible hashing.
Binary Search Trees: Various Binary tree representation, definition, BST ADT,
Implementation, Operations- Searching, Insertion and Deletion, Binary tree traversals,
threaded binary trees,
AVL Trees :Definition, Height of an AVL Tree, Operations – Insertion, Deletion and
Searching, B-Trees: B-Tree of order m, height of a B-Tree, insertion, deletion and searching,
B+ Tree.
S.No Topic Page
General data structure types include the array, the file, the record, the table, the tree, and so on.
Any data structure is designed to organize data to suit a specific purpose so that it can be accessed
and worked with in appropriate ways
In computer science, an abstract data type (ADT) is a mathematical model for data types
where a data type is defined by its behavior (semantics) from the point of view of a user
of the data, specifically in terms of possible values, possible operations on data of this type,
and the behavior of these operations. When a class is used as a type, it is an abstract type that
refers to a hidden representation. In this model an ADT is typically implemented as a class, and
each instance of the ADT is usually a n object of that class.
In ADT all the implementation details are hidden
Linear data structures are the data structures in which data is arranged in a list or in a
sequence.
Non linear data structures are the data structures in which data may be arranged in a
hierarchic al manner
List is basically the collection of elements arrange d in a sequential manner. In memory
we can store the list in two ways: one way is we can store the elements in sequential
memory locations. That means we can store the list in arrays.
The other way is we can use pointers or links to associate elements sequentially.
This is known as linked list.
The linked list is very different type of collection from an array. Using such lists, we can
store collections of information limited only by the total amount of memory that the OS will allow
us to use.Further more, there is no need to specify our needs in advance. The linked list is very
flexible dynamic data structure : items may be added to it or deleted from it at will. A programmer
need not worry about how many items a program will have to accommodate in advance. This
allows us to write robust programs which require much less maintenance.
Introduction: Abstract data types, Singly linked list: Definition, operations: Traversing, Searching,
Insertion and deletion, Doubly linked list: Definition, operations: Traversing, Searching, Insertion and
deletion, Circular Linked List: Definition, operations: Traversing, Searching, Insertion and deletion
temp->link=head;
head=temp;
Insertions: To place an elements in the list there are 3 cases :
case 1:Insert at the beginning
temp
head is the pointer variable which contains address of the first node and temp contains address of
new node to be inserted then sample code is
After insertion:
Code for insert front:-
template
void list
struct node
cout<<"Enter data into node:";
cin>>item;
temp=create_node(item);
if(head==NULL)
head=temp;
else
{ temp->link=head;
head=temp;
t=head;
while(t->link!=NULL)
t=t->link;
t->link=temp;
case 2:Inserting end of the list
temp
head is the pointer variable which contains address of the first node and temp contains address of new
node to be inserted then sample code is
After insertion the linked list is
Code for insert End:-
template
void list
struct node
int n;
cout<<"Enter data into node:";
cin>>n;
temp=create_node(n);
if(head==NULL)
head=temp;
else
{ t=head;
while(t->link!=NULL)
t=t->link;
t->link=temp;
t=head;
head=head->link;
cout<<"node "<<t->data<<" Deletion is sucess";
delete(t);
head=temp;
else
while(c<pos)
{ c++;
prev=cur;
cur=cur->link;
prev->link=temp;
temp->link=cur;
Deletions: Removing an element from the list, without destroying the integrity of the list itself.
To place an element from the list there are 3 cases :
Case 1: Delete a node at beginning of the list
head
head is the pointer variable which contains address of the first node
sample code is
head
code for deleting a node at front
template
void list
struct node
if(head==NULL)
cout<<"List is Empty\n";
else
{ t=head;
struct node
cur=prev=head;
while(cur->link!=NULL)
{ prev=cur;
cur=cur->link;
prev->link=NULL;
cout<<"node "<<cur->data<<" Deletion is sucess";
free(cur);
head=head->link;
cout<<"node "<<t->data<<" Deletion is sucess";
delete(t);
Case 2. Delete a node at end of the list
head
To delete last node , find the node using following code
head
code for deleting a node at end of the list
template
void list
struct node
cur=prev=head;
if(head==NULL)
cout<<"List is Empty\n";
else
{ cur=prev=head;
if(head->link==NULL)
cout<<"node "<<cur->data<<" Deletion is sucess";
free(cur);
head=NULL;
Traversing the list: Assuming we are given the pointer to the head of the list, how do we get the end
of the list.
template
void list
struct node
if(head==NULL)
cout<<"List is Empty\n";
else
{ t=head;
while(t!=NULL)
{ cout<<t->data<<"->";
t=t->link;
#include<iostream.h>
#include<stdlib.h>
template
struct node
T data;
struct node
template
class list
int item;
struct node
public:
list();
void display();
struct node
void insert_end();
void insert_front();
void Insert_at_pos(int pos);
void delete_end();
void delete_front();
void Delete_at_pos(int pos);
void Node_count();
template
list
head=NULL;
template
void list
struct node
if(head==NULL)
cout<<"List is Empty\n";
else
{ t=head;
while(t!=NULL)
{ cout<<t->data<<"->";
t=t->link;
template
struct node
{struct node
t=new struct node
t->data=n;
t->link=NULL;
return t;
template
void list
{struct node
int n;
cout<<"Enter data into node:";
cin>>n;
temp=create_node(n);
if(head==NULL)
head=temp;
else
{ t=head;
while(t->link!=NULL)
t=t->link;
t->link=temp;
cout<<"node "<<t->data<<" Deletion is sucess";
delete(t);
template
void list
struct node
int c=0;
t=head;
if(head==NULL)
cout<<"List is Empty\n";
else
{ while(t!=NULL)
{ c++;
t=t->link;
cout<<"Node Count="<<c<<endl;
template
void list
{struct node
int c=1;
cout<<"Enter data into node:";
cin>>item
temp=create_node(item);
if(head==NULL)
head=temp;
else
{ prev=cur=head;
if(pos==1)
else
temp->link=head;
head=temp;
while(c<pos)
{ c++;
prev=cur;
cur=cur->link;
prev->link=temp;
temp->link=cur;
template
void list
struct node
int c=1;
if(head==NULL)
cout<<"List is Empty\n";
else
{ prev=cur=head;
if(pos==1)
head=head->link;
cout<<cur->data <<"is deleted sucesfully";
delete cur;
else
while(c<pos)
{ c++;
prev=cur;
cur=cur->link;
prev->link=cur->link;
cout<<cur->data <<"is deleted sucesfully";
delete cur;
int main()
int ncount,ch,pos;
list
while(1)
cout<<"\n Operations on Linked List"<<endl;
cout<<"\n1.Insert node at End"<<endl;
cout<<"2.Insert node at Front"<<endl;
cout<<"3.Delete node at END"<<endl;
cout<<"4.Delete node at Front"<<endl;
cout<<"5.Insert at a position "<<endl;
cout<<"6.Delete at a position "<<endl;
cout<<"7.Node Count"<<endl;
cout<<"8.Display nodes "<<endl;
cout<<"9.Clear Screen "<<endl;
NULL 20 30 NULL 10
Method -1:
struct node
int data;
struct node *prev;
struct node * next;
Method -2:
class node
public:
int data;
node *prev;
node * next;
Operations on Doubly linked list:
Insertion of a node
Deletions of a node
Traversing the list
Doubly linked list ADT:
template
class dlist
public:
int data;
struct dnode
dlist()
head=NULL;
void display();
struct dnode
void insert_end();
void insert_front();
void delete_end();
void delete_front();
void dnode_count();
head
temp
head
void Insert_at_pos(int pos);
void Delete_at_pos(int pos);
Insertions: To place an elements in the list there are 3 cases
1. At the beginning
2. End of the list
3. At a given position
case 1:Insert at the beginning
head is the pointer variable which contains address of the first node and temp contains address of new
node to be inserted then sample code is
Code for insert front:-
template
void DLL
struct dnode
cout<<"Enter data into node:";
cin>>data;
temp=create_dnode(data);
if(head==NULL)
head=temp;
else
{ temp->next=head; head-
prev=temp;
head=temp;
temp->next=head;
head->prev=temp;
head=temp;