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

Class 01

The document provides an overview of Data Structures (DS) and Algorithms (A), explaining their definitions, importance, and types. It distinguishes between linear and non-linear data structures, detailing examples such as arrays, stacks, queues, trees, and graphs, along with basic operations like traversal, search, insertion, deletion, and sorting. Understanding these concepts is essential for efficient data management and problem-solving in computer science.

Uploaded by

marmasunmoon9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Class 01

The document provides an overview of Data Structures (DS) and Algorithms (A), explaining their definitions, importance, and types. It distinguishes between linear and non-linear data structures, detailing examples such as arrays, stacks, queues, trees, and graphs, along with basic operations like traversal, search, insertion, deletion, and sorting. Understanding these concepts is essential for efficient data management and problem-solving in computer science.

Uploaded by

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

ECE 2103: Data Structure and Algorithms Md.

Omaer Faruq Goni


Page 01 Assistant Professor, ECE, RUET
Monday, November 25, 2024 9:57 AM 01609620061
omaerfaruq@ece.ruet.ac.bd

What is DS? Data Structure Introduction https://www.w3schools.com/dsa/dsa_intro.php


Why should we study DS? • Concepts and Examples of Elementary Data Objects, https://www.tutorialspoint.com/data_structures_alg
Types of DS • Necessity of Structured Data, orithms/index.htm
Linear VS Nonlinear DS • Types of Data Structure, https://www.programiz.com/dsa
Basic Operations on DS https://www.javatpoint.com/data-structure-
• Ideas on Linear and Nonlinear Data Structure.
introduction

Data Structures is about how data can be stored in different structures.

Algorithms is about how to solve different problems, often by searching through and manipulating data structures.
Theory about Data Structures and Algorithms (DSA) helps us to use large amounts of data to solve problems efficiently.

What are Data Structures?


A data structure is a way to store data.
We structure data in different ways depending on what data we have, and what we want to do with it.

Family tree
First, let's consider an example without computers in mind, just to get the idea.

If we want to store data about people we are related to, we use a family tree as the data structure. We choose a family tree as the data
structure because we have information about people we are related to and how they are related, and we want an overview so that we can
easily find a specific family member, several generations back.

With such a family tree data structure visually in front of you, it is easy to see, for example, who my mother's mother is—it is 'Emma,' right?
But without the links from child to parents that this data structure provides, it would be difficult to determine how the individuals are related.
Data structures give us the possibility to manage large amounts of data efficiently for uses such as large databases and internet indexing
services.

Data structures are essential ingredients in creating fast and powerful algorithms. They help in managing and organizing data, reduce
complexity, and increase efficiency.

What are Algorithms?


An algorithm is a set of step-by-step instructions to solve a given problem or achieve a specific goal.

Pommes Frites Recipe


A cooking recipe written on a piece of paper is an example of an algorithm, where the goal is to make a certain dinner. The steps needed to
make a specific dinner are described exactly.

When we talk about algorithms in Computer Science, the step-by-step instructions are written in a programming language, and instead of
food ingredients, an algorithm uses data structures. Algorithms are fundamental to computer programming as they provide step-by-step
instructions for executing tasks. An efficient algorithm can help us to find the solution we are looking for, and to transform a slow program
into a faster one.

Class 01 Page 1
into a faster one.

Algorithm 1: Add two numbers entered by the user

Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 6: Stop

By studying algorithms, developers can write better programs.

Algorithm examples:
○ Finding the fastest route in a GPS navigation system
○ Navigating an airplane or a car (cruise control)
○ Finding what users search for (search engine)
○ Sorting, for example sorting movies by rating

Class 01 Page 2
Page 02
26 November 2024 6:51 AM

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.

Depending on your requirement and project, it is important to choose the right data
structure for your project. For example, if you want to store data sequentially in the
memory, then you can go for the Array data structure.

Primitive Data Structures are basic data structures provided by programming languages to represent single values, such as integers, floating-
point numbers, characters, and booleans.

Non-primitive or Abstract Data Structures are higher-level data structures that are built using primitive data types and provide more complex
and specialized operations. Some common examples of abstract data structures include arrays, linked lists, stacks, queues, trees, and graphs.

Linear data structures

In linear data structures, the elements are arranged in sequence one after the other. Since elements are arranged in particular order, they are easy
to implement.

However, when the complexity of the program increases, the linear data structures might not be the best choice because of operational
complexities.

1. Array Data Structure


In an array, elements in memory are arranged in continuous memory. All the elements of an array are of the same type. And, the type of
elements that can be stored in the form of arrays is determined by the programming language.

Class 01 Page 3
An array with each element represented by an index

2. Stack Data Structure


In stack data structure, elements are stored in the LIFO principle. That is, the last element stored in a stack will be removed first.

It works just like a pile of plates where the last plate kept on the pile will be removed first.

3. Queue Data Structure


Unlike stack, the queue data structure works in the FIFO principle where first element stored in the queue will be removed first.

It works just like a queue of people in the ticket counter where first person on the queue will get the ticket first.

4. Linked List Data Structure


In linked list data structure, data elements are connected through a series of nodes. And, each node contains the data items and address to the
next node.

Non-linear data structures

Unlike linear data structures, elements in non-linear data structures are not in any sequence. Instead they are arranged in a hierarchical manner
where one element will be connected to one or more elements.
Non-linear data structures are further divided into graph and tree based data structures.

1. Graph Data Structure


In graph data structure, each node is called vertex and each vertex is connected to other vertices through edges.

Class 01 Page 4
Graph data structure example
Popular Graph Based Data Structures:
• Spanning Tree and Minimum Spanning Tree
• Strongly Connected Components
• Adjacency Matrix
• Adjacency List

2. Trees Data Structure


Similar to a graph, a tree is also a collection of vertices and edges. However, in tree data structure, there can only be one edge between two
vertices.

Tree data structure example

Popular Tree based Data Structure

• Binary Tree
• Binary Search Tree
• AVL Tree
• B-Tree
• B+ Tree
• Red-Black Tree

Linear Data Structures Non Linear Data Structures


The data items are arranged in sequential order, one after the other. The data items are arranged in non-sequential order (hierarchical
manner).
All the items are present on the single layer. The data items are present at different layers.
It can be traversed on a single run. That is, if we start from the first It requires multiple runs. That is, if we start from the first element
element, we can traverse all the elements sequentially in a single it might not be possible to traverse all the elements in a single pass.
pass.
The memory utilization is not efficient. Different structures utilize memory in different efficient ways
depending on the need.
The time complexity increase with the data size. Time complexity remains the same.
Example: Arrays, Stack, Queue Example: Tree, Graph, Map

Class 01 Page 5
Page 03
26 November 2024 7:08 AM

Basic Operations of Data Structures


In the following section, we will discuss the different types of operations that we can perform to manipulate data in every data structure:

1. Traversal: Traversing a data structure means accessing each data element exactly once so it can be administered. For example, traversing
is required while printing the names of all the employees in a department.
2. Search: Search is another data structure operation which means to find the location of one or more data elements that meet certain
constraints. Such a data element may or may not be present in the given set of data elements. For example, we can use the search
operation to find the names of all the employees who have the experience of more than 5 years.
3. Insertion: Insertion means inserting or adding new data elements to the collection. For example, we can use the insertion operation to
add the details of a new employee the company has recently hired.
4. Deletion: Deletion means to remove or delete a specific data element from the given list of data elements. For example, we can use the
deleting operation to delete the name of an employee who has left the job.
5. Sorting: Sorting means to arrange the data elements in either Ascending or Descending order depending on the type of application. For
example, we can use the sorting operation to arrange the names of employees in a department in alphabetical order or estimate the top
three performers of the month by arranging the performance of the employees in descending order and extracting the details of the top
three.
6. Merge: Merge means to combine data elements of two sorted lists in order to form a single list of sorted data elements.
7. Create: Create is an operation used to reserve memory for the data elements of the program. We can perform this operation using a
declaration statement. The creation of data structure can take place either during the following:
a. Compile-time
b. Run-time
For example, the malloc() function is used in C Language to create data structure.

8. Selection: Selection means selecting a particular data from the available data. We can select any particular data by specifying conditions
inside the loop.
9. Update: The Update operation allows us to update or modify the data in the data structure. We can also update any particular data by
specifying some conditions inside the loop, like the Selection operation.
10. Splitting: The Splitting operation allows us to divide data into various subparts decreasing the overall process completion time.

Class 01 Page 6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy