0% found this document useful (0 votes)
9 views12 pages

DataStructure&Algorithm

Uploaded by

dotaqeel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
9 views12 pages

DataStructure&Algorithm

Uploaded by

dotaqeel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 12

Data Structures and Algorithms

What is Data Structure?


• A particular way of storing and organizing data in a
computer so that it can be used efficiently and effectively.

• Data Structures are the programmatic way of storing data so


that data can be used efficiently.

• A group of data elements grouped together under one name.

For example, an array of integers


• For example, we have some data which has, player's name
“Ahmed" and age 26. Here “Ahmed" is of String data type
and 26 is of integer data type.

• We can organize this data as a record like Player record, which


will have both player's name and age in it.

• Now we can collect and store player's records in a file or


database as a data structure. For example: “Ahmed" 26,
“Ali" 31, “Aslam" 33.
Characteristics of a Data Structure

• Correctness − Data structure implementation should implement


its interface correctly.

• Time Complexity − Running time or the execution time of


operations of data structure must be as small as possible.

• Space Complexity − Memory usage of a data structure


operation should be as little as possible.
Types of Data Structures

Data structure is divided into two types:


•Linear data structure
•Non-linear data structure

Linear Data Structure :


•The arrangement of data in a sequential manner is known as a
linear data structure.
•The data structures used for this purpose are Arrays, Linked list,
Stacks, and Queues.
•We can traverse either forward or backward
Non-linear data structure :

•When one element is connected to the 'n' number of elements known


as a non-linear data structure.

•The best example is trees and graphs.

•In this case, the elements are arranged in a random manner.

•Can’t be traversed in a single run.


Data Structure

Linear Non-Linear

Static Dynamic Tree Graph

Array

Linked List Stack Queue


Major Operations
The major or the common operations that can be performed on the
data structures are:

•Searching: We can search for any element in a data structure.

•Sorting: We can sort the elements of a data structure either in an


ascending or descending order.

•Insertion: We can also insert the new element in a data structure.


•Updating: We can also update the element, i.e., we can replace
the element with another element.

•Deletion: We can also perform the delete operation to remove the


element from the data structure.

•Traversing: Traversing the data structure means visiting each


element of the data structure in order to perform some specific
operation like searching or sorting.
What is algorithm?

• A finite set of instructions which accomplish a particular task.

• A method or process to solve a problem.

• Transforms input of a problem to output.


Algorithm = Input + Process + Output
• Algorithm is a step-by-step procedure, which defines a set of
instructions to be executed in a certain order to get the desired
output.

• Algorithms are generally created independent of underlying


languages, i.e. an algorithm can be implemented in more than one
programming language.

• From the data structure point of view, following are some


important categories of algorithms -
Search - Algorithm to search an item in a data structure.

Swap - Algorithm to swap an items in a data structure.

Sort - Algorithm to a sort items in a certain order.

Insert - Algorithm to insert item in a data structure.

Update - Algorithm to update an existing item in a data


structure.

Delete - Algorithm to delete an existing item from a data


structure.

You might also like