0% found this document useful (0 votes)
90 views

Data Structure Introduction

Data structures and algorithms are fundamental concepts in computer science. There are several types of data structures including linear structures like arrays, linked lists, stacks and queues, as well as non-linear structures like trees and graphs. Common operations on data structures include traversing, searching, inserting, deleting, sorting and merging data. Algorithms use these data structures and apply sequence, selection and iteration logic to solve problems in a well-defined series of steps.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

Data Structure Introduction

Data structures and algorithms are fundamental concepts in computer science. There are several types of data structures including linear structures like arrays, linked lists, stacks and queues, as well as non-linear structures like trees and graphs. Common operations on data structures include traversing, searching, inserting, deleting, sorting and merging data. Algorithms use these data structures and apply sequence, selection and iteration logic to solve problems in a well-defined series of steps.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 17

Data Structure and Algorithm

Introduction and Overview

Data Structure Introduction and Overview


1
Data Structure
 Data are organized in different ways in computer’s
memory.

 One of the Logical or Mathematical models of a


particular organization of data is called Data Structure.

This model depends on the actual relationships of the data in


the real world.
The structure should be simple and ease of operation of the
model.

Data Structure Introduction and Overview


2
Types of Data Structures
 There are several types data structures that are used
frequently.

 Linear Data Structures: Having sequential relationships. Every


item is related to its previous and next item. Such as -
 Arrays
 Linked Lists
 Stacks
 Queues

 Non-linear Data Structures: Having non sequential


relationships. Every
E item is attached to many other items. Such
as -
 Trees
 Graphs

Data Structure Introduction and Overview


3
Arrays
 The most simplest form of data structure is a linear (or
one dimensional) array.
 A collection of a finite number similar data elements.
 Every element is referenced by a set of n consecutive
numbers usually from 1, 2, … n. n
 Linear arrays are denoted by

 Subscript notation: a1, a2, a3, …. an


Subscript
 Parenthesis Notation: A(1), A(2), A(3), …., A(N) variable
 Bracket Notation: A[1], A[2], A[3], ….., A[N]

Data Structure Introduction and Overview


4
Arrays (Cont.)
 Dimension of array depends on subscript.
 One-dimensional array element is referenced by one subscript.

1 2 3 4 N
 Two-dimensional array element is referenced by two subscript.
 Tables, Matrix etc.

1
2 0 1 2 3 4 N
3 0 1 2 3 4 N
1 2 3 4 N
Data Structure Introduction and Overview
5
Linked Lists
 A linked list is a linear collection of data elements (or a
chain of structures) called nodes.
 Each node contain two parts:
 Info – Contains the information of the element
 Link – Contains the address of the next node ( or pointer to the
next element).
 It is one of the simpler of the advanced data structures.
 Here is a diagram to illustrate: Information part

Next Pointer field


Start

Fig: Linked List


Data Structure Introduction and Overview
6
Stacks
 A stack which is also called a LIFO (last-in-first-out)
system is a linear list in which
 Insertion and Deletion can take place only at one end,
called the top
 Two types of Operations:

 PUSH – Add data into stack


 POP – Delete data from stack

Data Structure Introduction and Overview


7
Basic operations of a Stack

New Push

Pop Peek

?
Data Structure Introduction and Overview
8
Queues

 A queue also called a FIFO (first-in-first-out) type linear


list.
 Addition and deletion operations can take place at
different end.

 Addition or Insertions – at one end of the list called front.

 Deletion – at the other end of the list called rear.

Data Structure Introduction and Overview


9
Basic operations of a queue

New Add into


queue
Front

Rear

Delete from
queue Empty? ?

Full?

Data Structure Introduction and Overview


10
Trees
 The data structure which reflects hierarchical relationship
between various elements is called a rooted tree graph
or simply a tree.
 It begins with a root node, which contains the original
key value.
 The root node has some child nodes;
 each child node might have its own child nodes and so on.

Student

SID Name Address Age

FN MN LN StrNO H# APTNO

Data Structure Introduction and Overview


11
Graphs

 Some data structures contain a relationships between


pairs of elements which is not necessarily hierarchical in
nature. This type data structure is called a graph.
 It contains -
 Nodes
 Edges

Data Structure Introduction and Overview


12
Data structure Operations

 There are a number of operations to be performed in the


organization of data. The following operations play a
major role:
 Traversing: Accessing each record exactly once so that certain
items in the record may be processed.

 Searching: Finding the location of the record with a given key


value. or finding the location of all records which satisfy one or
more conditions.
 Linear Search
 Binary Search

Data Structure Introduction and Overview


13
Data structure Operations (Cont)
 Inserting: Adding a new record to the data structure.

 Deleting: Removing a record from the structure.

 Sorting: Arranging the records in some logical order.


 Bubble Sort
 Quick Sort etc.

 Merging: Combining the records in two different sorted list into a


single one sorted list.

Data Structure Introduction and Overview


14
Algorithms

 An algorithm is a well-defined list of steps for solving a


particular problems.

 Complexity of an algorithm: The complexity of an


algorithm is the function f(n) which gives the running
time and /or storage space requirement of the algorithm
in terms of the size n of the input data.

Data Structure Introduction and Overview


15
Algorithm
 An algorithm is composed of some input and output
variables, steps, control structures ,comments, and
termination criteria.
 An algorithm and their equivalent programs are more
easily understood if they mainly use self-contained
modules an three types of logic or control flow. These
are:
 Sequence logic or sequential logic
 Selection logic or conditional logic
 Iteration logic or repetitive logic

Data Structure Introduction and Overview


16
The End

Data Structure Introduction and Overview


17

You might also like