CLASS1 Fundamentals of Data Structures

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 21

Introduction

to
Data Structure

A data structure is any data representation and its associated
operations. Even an integer or floating point number stored on
the computer can be viewed as a simple data structure.

More typically, a data structure is meant to be an organization


or structuring for a collection of data items. A sorted list of
integers stored in an array is an example of such a structuring.

Given sufficient space to store a collection of data items, it is


always possible to search for specified items within the
collection, print or otherwise process the data items in any
desired order, or modify the value of any particular data item.

Thus, it is possible to perform all necessary operations on any


data structure. However, using the proper data structure can
make the difference between a program running in a few
seconds and one requiring many days.
Definition:

A data structure is a scheme for organizing data in the


memory of a computer. A data structure is a particular
way of storing and organizing data in a computer so
that it can be used efficiently.

Different kinds of data structures are suited to different


kinds of applications, and some are highly specialized
to specific tasks.
Some of the more commonly used data structures include
lists, arrays, stacks, queues, heaps, trees and graphs. The
way in which the data is organized affects the
performance of a program for different tasks.

Data structures are generally based on the ability of a


computer to fetch and store data at any place in its
memory, specified by an address — a bit string that can
be itself stored in memory and manipulated by the
program.
Computer programmers decide which data structures to
use based on the nature of the data and the processes that
need to be performed on that data.

When selecting a data structure to solve a problem, you


should follow these steps.

1. Analyze your problem to determine the basic operations


that must be supported.

2. Quantify the resource constraints for each operation.

3. Select the data structure that best meets these


requirements.
Data structure are classified into two type such as linear or
non-linear.

Linear: A data structure is said to be linear if its elements


form a sequence. The elements of linear data structure
represents by means of sequential memory locations. The
other way is to have the linear relationship between the
elements represented by means of pointers or links. Ex-
Array and Link List.

Non-linear: A data structure is said to be non-linear if its


elements a hierarchical relationship between elements such
as trees and graphs. All elements assign the memory as
random form and you can fetch data elements through
random access process.
Arrays

The simplest type of data structure is a linear (or one


dimensional) array. By a linear array, we mean a list of a finite
number n of similar data elements referenced respectively by a
set of n consecutive numbers, usually 1, 2, 3, …n. If we choose
the name A for the array, then the elements of A are denoted by
subscript notation:

a1, a2, a3, ……., 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]

Regardless of the notation, the number K in A[K] is called a


subscript and A[K] is called a
subscripted variable.
Stack

A stack is a linear structure in which items may be added or


removed only at one end. The stack is a common data
structure for representing things that need to maintained in a
particular order.

For instance, when a function calls another function, which in


turn calls a third function, it’s important that the third function
return back to the second function rather than the first. One
way to think about this implementation is to think of
functions as being stacked on top of each other; the last one
added to the stack is the first one taken off. In this way, the
data structure itself enforces the proper order of calls.
Stacks are also called last-in first-out (LIFO) lists. Other names
used for stacks are “piles” and Notes “push-down” lists. Stack
has many important applications in computer science.
Queues

A queue, also called a first-in-first-out (FIFO) system, is a linear


list in which deletions can take place only at one end of the list,
the “front” of the list, and insertions can take place only at the
other end of the list, the “rear” of the list. The features of a

Queue are similar to the features of any queue of customers at a


counter, at a bus stop, at railway reservation counter, etc. A queue
can be implemented using arrays or linked lists. A queue can be
represented as a circular queue.

This representation saves space when compared to the linear


queue. Finally, there are special cases of queues called Dequeues
which allow insertion and deletion of elements at both the end.
Linked List

A linked list, or one-way list, is a linear collection of data


elements, called nodes, where the linear order is given by
means of pointers. That is, each node is divided into two parts:
the first part contains the information of the element, and the
second part, called the link field or next pointer field, contains
the address of the next node in the list.
Tree

A tree is an acyclic, connected graph. A tree contains no


loops or cycles. The concept of tree is one of the most
fundamental and useful concepts in computer science. Trees
have many variations, implementations and applications.

Trees find their use in applications such as compiler


construction, database design, windows, operating system
programs, etc. A tree structures is one in which items of
data are related by edges.
Graph

All the data structures (Arrays, Lists, Stacks, and


Queues) except Graphs are linear data structures. Graphs
are classified in the non-linear category of data
structures. A graph G may be defined as a finite set V of
vertices and a set E of edges (pair of connected vertices).

The notation used is as follows:

Graph G = (V,E)
From the above graph, we may observe that the set of vertices for
the graph is V = {1,2,3,4,5},
and the set of edges for the graph is
E = {(1,2), (1,5), (1,3), (5,4), (4,3), (2,3)}.

The elements of E are always a pair of elements.


THANKS

You might also like