SlideShare a Scribd company logo
1 of 17
UNIT 1
 Array is a container which can hold a fix
number of items and these items should be of the
same type. Most of the data structures make use of
arrays to implement their algorithms. Following are
the important terms to understand the concept of
array.
 Element – Each item stored in an array is
 called an element.
 Index – Each location of an element in
 an array has a numerical index, which is
used
 to identify the element.
 The sequential representation uses an array to store
information corresponding to each node of a tree. Consider
the binary tree shown in Figure 1.1 . Its depth is 5 and it has
fourteen nodes. The nodes are numbered in a special way.
This numbering may obtained by preorder traversing the
tree and as each node is accessed , assigning it a node
number. The root is assigned 1, each left successor of a node
is assigned twice the number of its predecessor, and each
right successor is assigned one more than twice the
number of its predecessor. With nodes numbered in this
way, the predecessor of node i is numbered i/2 (integer
divide), its left successor is numbered 2*i, and its right
successor 2*i+1.
 A type of list is known as an ordered list. The
structure of an ordered list is a collection of items
where each item holds a relative position that is based
upon some underlying characteristics of the item. The
ordering is typically either ascending or descending
and we assume that list items have a meaningful
comparison operation that is already defined . Many of
the list operations are the same as those of the
unordered list.
 Stack :
 A stack is a linear data structure in which
elements can be inserted and deleted only from
one side of the list, called the top. A stack follows
the LIFO (Last In First Out) principle, i.e., the
element inserted at the last is the first element to
come out. The insertion of an element into stack is
called push operation, and deletion of an element
from the stack is called pop operation. In stack we
always keep track of the last element present in the
list with a pointer called top.
 The diagrammatic representation of stack is given
below :
 Queue:
 A queue is linear data structure in which elements
can be inserted only from one side of the list called
rear, and the elements can be deleted only from the
other side called the front . The queue data structure
follows the FIFO (First In First Out) principle, i.e., the
element inserted at first in the list, is the first element
to be removed from the list. The insertion of an
element in a queue is called an enqueue operation
and deletion of an element is called a dequeue
operation.
 The diagrammatic representation of queue is given
below:
Evaluate an expression represented by a string .
Expression can contain parentheses, you can assume only
binary operations allowed are +, -, *, and /. Arithmetic
expressions can be written in one of three forms :
Infix Notation: Operators are written between the
operands they operate on, e.g. 3+4 .
Prefix Notation: Operators are written before the
operands, e.g. +3 4
Postfix Notation: Operators are written after operands.
 Up to now we have been concerned only with the
representation of a single stack or a single queue in the
memory of a computer. For these two cases we have
seen efficient sequential data representations.
B(i) = T(i) = [m/n] (i-1),1<i<n
 A Linked list is a way to store a collection of
elements. Like an array these can be character or
integers. Each element in a linked list is stored in the
form of node.
 A node is a collection of two sub-elements or parts.
A data part that stores the element and a next part
that stores the link to the node.
 To represent stacks and queues sequentially. Such a
representation proved efficient if we had only one
stack or one queue. However, When several stacks and
queues co-exist, there was no efficient way to represent
them sequentially. In this section we present a good
solution to this problem using linked list.
 T(i) = Top of ith stack 1<i<n
 F(i) = Front of ith queue 1<i<m
 R(i) = Rear of ith queue 1<i<m
 Initial conditions:
 T(i) = 0 1<i<n
 F(i) = 0 1<i<m
 Boundary conditions:
 T(i) = 0 iff stack i empty
 F(i) = 0 iff queue i empty
 The manipulation of symbolic polynomials, has
become a classical example of the use of list
processing. To represent any number of different
polynomials as long as their combined size does not
exceed our block of memory. In general , we want
represent the polynomial.
 A(x) = amxem+……+a1xe1
data structures and algorithms Unit 1

More Related Content

What's hot

Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
Ghaffar Khan
 

What's hot (20)

Ds mcq
Ds mcqDs mcq
Ds mcq
 
Data Structure
Data Structure Data Structure
Data Structure
 
DATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGEDATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGE
 
Data structure
Data structureData structure
Data structure
 
Unit 4
Unit 4Unit 4
Unit 4
 
Presentation on python data type
Presentation on python data typePresentation on python data type
Presentation on python data type
 
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
 
Data structure day1
Data structure day1Data structure day1
Data structure day1
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
Data Structure Question Bank(2 marks)
Data Structure Question Bank(2 marks)Data Structure Question Bank(2 marks)
Data Structure Question Bank(2 marks)
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
 
02 Stack
02 Stack02 Stack
02 Stack
 
Introduction To Data Structures
Introduction To Data StructuresIntroduction To Data Structures
Introduction To Data Structures
 
Data Structures
Data StructuresData Structures
Data Structures
 
L 15 ct1120
L 15 ct1120L 15 ct1120
L 15 ct1120
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 

Similar to data structures and algorithms Unit 1

Ch 1 intriductions
Ch 1 intriductionsCh 1 intriductions
Ch 1 intriductions
irshad17
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
Jazz Jinia Bhowmik
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
Deepa Rani
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبيانات
Rafal Edward
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and tests
priyanshukumar97908
 

Similar to data structures and algorithms Unit 1 (20)

unit 5 stack & queue.ppt
unit 5 stack & queue.pptunit 5 stack & queue.ppt
unit 5 stack & queue.ppt
 
Ch 1 intriductions
Ch 1 intriductionsCh 1 intriductions
Ch 1 intriductions
 
UNITIII LDS.pdf
UNITIII LDS.pdfUNITIII LDS.pdf
UNITIII LDS.pdf
 
Introduction to Data Structure
Introduction to Data StructureIntroduction to Data Structure
Introduction to Data Structure
 
Data Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptxData Structures & Algorithms Unit 1.pptx
Data Structures & Algorithms Unit 1.pptx
 
1.3 Linked List.pptx
1.3 Linked List.pptx1.3 Linked List.pptx
1.3 Linked List.pptx
 
Data structures notes
Data structures notesData structures notes
Data structures notes
 
Review of basic data structures
Review of basic data structuresReview of basic data structures
Review of basic data structures
 
linked list (c#)
 linked list (c#) linked list (c#)
linked list (c#)
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
chapter-4-data-structure.pdf
chapter-4-data-structure.pdfchapter-4-data-structure.pdf
chapter-4-data-structure.pdf
 
1.1 ADS data-structure.pdf
1.1 ADS data-structure.pdf1.1 ADS data-structure.pdf
1.1 ADS data-structure.pdf
 
Data Structure
Data StructureData Structure
Data Structure
 
General Data structures
General Data structuresGeneral Data structures
General Data structures
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبيانات
 
Notes of bca Question paper for exams and tests
Notes of bca Question paper for exams and testsNotes of bca Question paper for exams and tests
Notes of bca Question paper for exams and tests
 
Unit ii(dsc++)
Unit ii(dsc++)Unit ii(dsc++)
Unit ii(dsc++)
 
Data Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptxData Structures and algoithms Unit - 1.pptx
Data Structures and algoithms Unit - 1.pptx
 
chapter three ppt.pptx
chapter three ppt.pptxchapter three ppt.pptx
chapter three ppt.pptx
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

data structures and algorithms Unit 1

  • 2.  Array is a container which can hold a fix number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. Following are the important terms to understand the concept of array.  Element – Each item stored in an array is  called an element.  Index – Each location of an element in  an array has a numerical index, which is used  to identify the element.
  • 3.  The sequential representation uses an array to store information corresponding to each node of a tree. Consider the binary tree shown in Figure 1.1 . Its depth is 5 and it has fourteen nodes. The nodes are numbered in a special way. This numbering may obtained by preorder traversing the tree and as each node is accessed , assigning it a node number. The root is assigned 1, each left successor of a node is assigned twice the number of its predecessor, and each right successor is assigned one more than twice the number of its predecessor. With nodes numbered in this way, the predecessor of node i is numbered i/2 (integer divide), its left successor is numbered 2*i, and its right successor 2*i+1.
  • 4.
  • 5.  A type of list is known as an ordered list. The structure of an ordered list is a collection of items where each item holds a relative position that is based upon some underlying characteristics of the item. The ordering is typically either ascending or descending and we assume that list items have a meaningful comparison operation that is already defined . Many of the list operations are the same as those of the unordered list.
  • 6.  Stack :  A stack is a linear data structure in which elements can be inserted and deleted only from one side of the list, called the top. A stack follows the LIFO (Last In First Out) principle, i.e., the element inserted at the last is the first element to come out. The insertion of an element into stack is called push operation, and deletion of an element from the stack is called pop operation. In stack we always keep track of the last element present in the list with a pointer called top.
  • 7.  The diagrammatic representation of stack is given below :
  • 8.  Queue:  A queue is linear data structure in which elements can be inserted only from one side of the list called rear, and the elements can be deleted only from the other side called the front . The queue data structure follows the FIFO (First In First Out) principle, i.e., the element inserted at first in the list, is the first element to be removed from the list. The insertion of an element in a queue is called an enqueue operation and deletion of an element is called a dequeue operation.
  • 9.  The diagrammatic representation of queue is given below:
  • 10. Evaluate an expression represented by a string . Expression can contain parentheses, you can assume only binary operations allowed are +, -, *, and /. Arithmetic expressions can be written in one of three forms : Infix Notation: Operators are written between the operands they operate on, e.g. 3+4 . Prefix Notation: Operators are written before the operands, e.g. +3 4 Postfix Notation: Operators are written after operands.
  • 11.  Up to now we have been concerned only with the representation of a single stack or a single queue in the memory of a computer. For these two cases we have seen efficient sequential data representations. B(i) = T(i) = [m/n] (i-1),1<i<n
  • 12.  A Linked list is a way to store a collection of elements. Like an array these can be character or integers. Each element in a linked list is stored in the form of node.
  • 13.  A node is a collection of two sub-elements or parts. A data part that stores the element and a next part that stores the link to the node.
  • 14.  To represent stacks and queues sequentially. Such a representation proved efficient if we had only one stack or one queue. However, When several stacks and queues co-exist, there was no efficient way to represent them sequentially. In this section we present a good solution to this problem using linked list.
  • 15.  T(i) = Top of ith stack 1<i<n  F(i) = Front of ith queue 1<i<m  R(i) = Rear of ith queue 1<i<m  Initial conditions:  T(i) = 0 1<i<n  F(i) = 0 1<i<m  Boundary conditions:  T(i) = 0 iff stack i empty  F(i) = 0 iff queue i empty
  • 16.  The manipulation of symbolic polynomials, has become a classical example of the use of list processing. To represent any number of different polynomials as long as their combined size does not exceed our block of memory. In general , we want represent the polynomial.  A(x) = amxem+……+a1xe1