Introduction
 Values or sets of values
 A “Data Item” refers to a single set of values
 Group Items
 Elementary Items
 Collections of data are frequently organized
into a hierarchy of fields, records, and files.
 An entity is something that has certain
attributes.
 Entities with similar attributes form an entity
set.
 Each attribute of an entity set has a range of
values.
 Data with given attributes
 Meaningful or processed data
Data Processing Information
 The logical or mathematical model of a
particular organization is called data
structure.
OR
 A data structure is the arrangement of data in
a computer’s memory (or sometimes on a
disk)
It should have two qualities:
1. It should be able to create the model as close
to reality as possible.
2. It should be simple enough to process the
data efficiently when needed.
 There are two types of data:
1. Primitive: integers, real, character, Boolean.
2. Non-primitive: Linked-lists, stacks, queues,
trees & graphs
 Linear: elements form a sequence or a linear
list. Examples:Arrays, Linked Lists, Stacks,
Queues.
 Non-linear: Data is not arranged in sequence.
The insertion and deletion of data is not
possible in a linear fashion. Examples:Trees &
Graphs
 A list of a finite number “n” of similar data.
 If elements of an array are referenced as
“1,2,3, … ,n”
 The array is called “A”.
 Then the elements of “A” are denoted by
subscript notation “a₁, a₂, a₃, … an
 Or by the parenthesis notation
A(1), A(2), A(3), … , A(N)
 Or by the bracket notation
A[1], A[2], A[3], … , A[N]
 A linked list is a linear data structure where
each element is a separate object
 A linked list has two parts: one is info and the
other is link part. Info part gives information
and link part is address of next node.
 Each element has two items : the data and a
reference to next node
 The last node has reference to null
 The first node is called the head. It is not a
separate node but reference to first node.
 If the list is empty then the head is a null
reference.
 It is dynamic data structure.
 The nodes can grow and shrink on demand.
 Good for applications dealing with unknown
number of objects.
 Tree or branched data structure consists of
sets of elements (nodes) which could be
linked to other elements.
 Trees represent hierarchies, while graphs
represent more general relations such as
maps of city.
Tree Graph
 Every circle in a tree is called a node, and every
line an edge.
 Root is the node without parent
 Leaf is a node without child.
 Internal nodes are neither leaf or root.
 Path is called a sequence of nodes connecting
with edges.
 Stacks also called a last in first out system.
 Queue also called a first in first out system
 Graphs contain a relationship between pairs
of elements which is not necessarily
hierarchical in nature.
1. Traversing: Assessing each record exactly
once so that certain items in the record may
be processed. Also called visiting the record.
2. Searching: Finding the location of the record
with a given key value, or finding the
locations of all records which satisfy one or
more conditions.
3. Inserting: Adding a new record to the structure.
4. Deleting: Removing a record from the structure.
5. Sorting: Arranging the records in some logical
order.
6. Merging: Combing the records in two different
sorted files into a single sorted file.
 Data type defined in terms of operations on
it, and its implementation is hidden.
 It is easier to replace the implementation and
it will not interfere with anything in the
program.
 An ADT has 2 parts:
1. A name or type specifying a set of data
(dictionary)
2. Descriptions of all the operations (or methods)
that do things with that type (e.g., find, insert,
remove).The descriptions indicate what the
operations do, not how they do it.
 Examples: Interfaces in Java
(roughly) header files and typedef in C
 An Algorithm is a well defined list of steps for
solving a particular problem.
 The time and space it uses are two major
measures of the efficiency of an algorithm.
 The complexity of an algorithm is the
function which gives the running time and/or
space in terms of the input size.
 Refers to a choice between algorithmic
solutions of a data processing problems that
allows one to decrease the running time of an
algorithmic solution by increasing the space
to store that data and vice versa.
 Linear search searches for a specified value in
a list by checking every element in the list.
 Binary search method halves the number of
elements checked (in each iteration),
reducing the time taken to locate the given
item in the list.
Binary Search Linear Search
Works only on sorted items. such as
1,2,3,4,5,6 etc.
Works on sorted as well as unsorted
items.
12,4,5,3,2,1 etc.
Very efficient if the items are sorted Very efficient if the items are less
and present in the beginning of the
list. such as
Suppose your list items are :
12,3,4,5,1
and you want to search 12 number
then you get beginning in the list.
Works well with arrays and not on
linked lists.
Works with arrays and linked lists.
Number of comparisons are less More number of comparisons are
required if the items are present in
the later part of the array or its
elements are more.

Data structure & algorithms introduction

  • 1.
  • 2.
     Values orsets of values  A “Data Item” refers to a single set of values  Group Items  Elementary Items
  • 3.
     Collections ofdata are frequently organized into a hierarchy of fields, records, and files.  An entity is something that has certain attributes.  Entities with similar attributes form an entity set.  Each attribute of an entity set has a range of values.
  • 4.
     Data withgiven attributes  Meaningful or processed data Data Processing Information
  • 5.
     The logicalor mathematical model of a particular organization is called data structure. OR  A data structure is the arrangement of data in a computer’s memory (or sometimes on a disk)
  • 6.
    It should havetwo qualities: 1. It should be able to create the model as close to reality as possible. 2. It should be simple enough to process the data efficiently when needed.
  • 7.
     There aretwo types of data: 1. Primitive: integers, real, character, Boolean. 2. Non-primitive: Linked-lists, stacks, queues, trees & graphs
  • 9.
     Linear: elementsform a sequence or a linear list. Examples:Arrays, Linked Lists, Stacks, Queues.  Non-linear: Data is not arranged in sequence. The insertion and deletion of data is not possible in a linear fashion. Examples:Trees & Graphs
  • 10.
     A listof a finite number “n” of similar data.
  • 11.
     If elementsof an array are referenced as “1,2,3, … ,n”  The array is called “A”.  Then the elements of “A” are denoted by subscript notation “a₁, a₂, a₃, … an
  • 12.
     Or bythe parenthesis notation A(1), A(2), A(3), … , A(N)  Or by the bracket notation A[1], A[2], A[3], … , A[N]
  • 13.
     A linkedlist is a linear data structure where each element is a separate object  A linked list has two parts: one is info and the other is link part. Info part gives information and link part is address of next node.
  • 14.
     Each elementhas two items : the data and a reference to next node  The last node has reference to null  The first node is called the head. It is not a separate node but reference to first node.  If the list is empty then the head is a null reference.
  • 15.
     It isdynamic data structure.  The nodes can grow and shrink on demand.  Good for applications dealing with unknown number of objects.
  • 16.
     Tree orbranched data structure consists of sets of elements (nodes) which could be linked to other elements.  Trees represent hierarchies, while graphs represent more general relations such as maps of city.
  • 17.
  • 18.
     Every circlein a tree is called a node, and every line an edge.  Root is the node without parent  Leaf is a node without child.  Internal nodes are neither leaf or root.  Path is called a sequence of nodes connecting with edges.
  • 19.
     Stacks alsocalled a last in first out system.  Queue also called a first in first out system  Graphs contain a relationship between pairs of elements which is not necessarily hierarchical in nature.
  • 20.
    1. Traversing: Assessingeach record exactly once so that certain items in the record may be processed. Also called visiting the record. 2. Searching: Finding the location of the record with a given key value, or finding the locations of all records which satisfy one or more conditions.
  • 21.
    3. Inserting: Addinga new record to the structure. 4. Deleting: Removing a record from the structure. 5. Sorting: Arranging the records in some logical order. 6. Merging: Combing the records in two different sorted files into a single sorted file.
  • 22.
     Data typedefined in terms of operations on it, and its implementation is hidden.  It is easier to replace the implementation and it will not interfere with anything in the program.
  • 23.
     An ADThas 2 parts: 1. A name or type specifying a set of data (dictionary) 2. Descriptions of all the operations (or methods) that do things with that type (e.g., find, insert, remove).The descriptions indicate what the operations do, not how they do it.  Examples: Interfaces in Java (roughly) header files and typedef in C
  • 25.
     An Algorithmis a well defined list of steps for solving a particular problem.  The time and space it uses are two major measures of the efficiency of an algorithm.
  • 26.
     The complexityof an algorithm is the function which gives the running time and/or space in terms of the input size.
  • 27.
     Refers toa choice between algorithmic solutions of a data processing problems that allows one to decrease the running time of an algorithmic solution by increasing the space to store that data and vice versa.
  • 28.
     Linear searchsearches for a specified value in a list by checking every element in the list.  Binary search method halves the number of elements checked (in each iteration), reducing the time taken to locate the given item in the list.
  • 29.
    Binary Search LinearSearch Works only on sorted items. such as 1,2,3,4,5,6 etc. Works on sorted as well as unsorted items. 12,4,5,3,2,1 etc. Very efficient if the items are sorted Very efficient if the items are less and present in the beginning of the list. such as Suppose your list items are : 12,3,4,5,1 and you want to search 12 number then you get beginning in the list. Works well with arrays and not on linked lists. Works with arrays and linked lists. Number of comparisons are less More number of comparisons are required if the items are present in the later part of the array or its elements are more.

Editor's Notes

  • #8 Basic data types such as integer, real, character, and boolean are known as primitive data structures. These data types consist of characters that cannot be divided. Simple data types. These data structures are normally directly operated upon by machine-level instructions. Non-primitive data structures are more complex data structures. These data structures are derived from the primitive data structures. They stress on formation of sets of homogeneous and heterogeneous data elements.
  • #13 Linear arrays are called one-dimensional arrays because each element in such an array is referenced by one subscript. A two dimensional array is collection of similar data elements where each element is referenced by two subscripts. (such arrays are called matrices in mathematics, and tables in business applications.)