100% found this document useful (1 vote)
2K views17 pages

Data Structure and Algorithm

Basic DSC PPT

Uploaded by

Shruti Wali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views17 pages

Data Structure and Algorithm

Basic DSC PPT

Uploaded by

Shruti Wali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

DATA STRUCTURE AND

ALGORITHM
-SHREYA
Introduction to Data Structures

 A data structure is a storage that is used to store and organize


data. It is a way of arranging data on a computer so that it can
be accessed and updated efficiently.
 A data structure is not only used for organizing the data. It is
also used for processing, retrieving, and storing data.
Classification
 Primitive Data Structures are the data structures
consisting of the numbers and the characters that
come in-built into programs.

 Non-Primitive Data Structures are those data


structures derived from Primitive Data Structures.
Difference:

Primitive data structure Non Primitive Data structure

Primitive data structure is the data structure that allows Non-Primitive data structure is a data structure that allows
you to store only single data type values. you to store multiple data type values.

Primitive data structure always contains some value i.e. You can store a NULL value in the non-primitive data
these data structures do not allow you to store NULL structures.
values.

The size of the primitive data structures is dependent on The size of the non-primitive data structure is not fixed.
the type of the primitive data structure.
Arrays

 An array in C is a fixed-size collection of similar data items stored


in contiguous memory locations.

 It can be used to store the collection of primitive data types such


as int, char, float, etc., and also derived and user-defined data
types such as pointers, structures, etc.
Types of Arrays

ARRAYS

Three
One -Dimensional Two dimensional Dimensional
 One dimensional:
 The simplest type of arrays, one-dimensional arrays, contains a single row
of elements. These arrays are usually indexed from 0 to n-1, where ‘n’ is
the size of the array. Utilizing its assigned index number, each element in
an array can be conveniently accessed.
 Two Dimensional Array:
 Two-dimensional array type are arrays that contain arrays of elements.
These are also referred to as matrix arrays since they can be thought
of as a grid that lays out the elements into rows and columns. Each
element within the two-dimensional array can be accessed individually
by its row and column location. This array type is useful for storing data
such as tables or pictures, where each element may have multiple
associated values.
 Multi-Dimensional
 Multi-Dimensional arrays are a powerful data structure used to store
and manage data organizationally. This type of arrays consist of
multiple arrays that are arranged hierarchically. They can have any
number of dimensions, the most common being two dimensions
(rows and columns), but three or more dimensions may also be
used.
Array Operations

Traversal: Array traversal refers to the process of accessing each element of an array in a
sequential order from the beginning to the end or from the end to the beginning.
Search: Search is the process of finding a specific element within an array. This is done by
comparing the target element with each element in the array until a match is found. There are
various search algorithms that can be used.
Sorting: Sorting is the process of arranging the elements in an array in a specific order. The
most common sorting algorithms are bubble sort, insertion sort, selection sort, merge sort, and
quicksort.
 Insertion: Insertion is the process of adding a new element to an array. Depending on the
application, the new element can be inserted at the beginning, end, or any other location
within the array.
 Here's a simple algorithm in simple language to perform an insertion in an array:
 Define the array and the element to be inserted.
 Determine the position where the element should be inserted.
 Shift the elements after the insertion position to the right by one index to make room for
the new element.
 Insert the new element at the desired position.
 Update the length of the array
 Deletion: Deletion is the process of removing an existing element from an array.
Depending on the application, the element to be deleted can be at any location
within the array. When deleting an element, the other elements in the array may
need to be shifted to fill the gap left by the deleted element.
 Here is the algorithm to delete an element from an array in C:
 Initialize the array and the index of the element to be deleted.
 Traverse the array from the index of the element to be deleted until the end of the
array.
 Shift each element one position to the left.
 Decrement the size of the array by 1.
Classification:

Data
Structures

LINEAR Data Non linear Data


Structures Structures

Array Linked Graphs


List Tree
Stack
 Linear data structure: Data structure in which data
elements are arranged sequentially or linearly, where each
element is attached to its previous and next adjacent
elements, is called a linear data structure.

 Non-linear data structure: Data structures where data


elements are not placed sequentially or linearly are called
non-linear data structures. In a non-linear data structure,
we can’t traverse all the elements in a single run only.
Difference

Linear Search Binary Search

n linear search input data need not to be in In binary search input data need to be in
sorted. sorted order.

It is also called sequential search. It is also called half-interval search

Multidimensional array can be used. Only single dimensional array is used.

Linear search performs equality comparisons Binary search performs ordering comparisons
THANK YOU

You might also like