0% found this document useful (0 votes)
4 views16 pages

Lec 1

The document is a lecture on Data Structures and Algorithms, explaining how data is organized in memory for efficient use. It covers types of data structures, including primitive and non-primitive structures, as well as linear and non-linear classifications. Major operations on data structures such as insertion, deletion, sorting, updating, and searching are also discussed, along with examples of arrays and pointers in programming.

Uploaded by

bnhatm216
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 views16 pages

Lec 1

The document is a lecture on Data Structures and Algorithms, explaining how data is organized in memory for efficient use. It covers types of data structures, including primitive and non-primitive structures, as well as linear and non-linear classifications. Major operations on data structures such as insertion, deletion, sorting, updating, and searching are also discussed, along with examples of arrays and pointers in programming.

Uploaded by

bnhatm216
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/ 16

Data Structure

& Algorithems
Lecture 1
By: Maryam Fahd Hajeb
is a way to store and organize
data in computer’s memory so
that it can be used efficiently.
Data Structure
is a set of algorithms that we can
use in any programming
language to structure the data in
Data Structure
the memory.
is a set of step-by-step
instructions to solve a given
Algorithem problem or achieve a specific
goal.
Non- Linear
Primitive
Data
Structure Non-

Types Linear

Primitive
Data Structure Types

Primitive Data Structure Non-Primitive Data Structure


are primitive data types. is divided into two types:
The int, char, float, double, Linear & Non-linear
and pointer are the primitive
data structures that can
hold a single value.
Non-Primitive Data Structure

Linear Data Structure Non-linear Data Structure

- The arrangement of data in a - the elements are arranged in a


sequential manner. random manner.
- one element is connected to only - one element is connected to the 'n'
one another element in a linear form. number of elements.
- Arrays, Linked list, Stacks, and - trees and graphs
Queues.
Static - The size is allocated at

- The size is allocated at Data the run time. Therefore,


the maximum size is
the compile time.
Therefore, the maximum
Structure flexible.

size is fixed. Classification - Linked List.

Array.
-
Dynamic
Data Structures Examples

Arrays Trees
Stack

Linked Queue
Lists
Data Structures Major Operations

Insertion Deletion Sorting

Updating Searching
- is a variable that stores the memory
address as its value.

- A pointer variable points to a data type


(like int or string) of the same type.

Pointers
#include <iostream>
using namespace std;
int main()
{
int a = 15;
int *p;

Example 1:
p = &a;

cout<<"a = "<<a<<", a address =


"<<p<<endl;
*p = 500;
cout<<"a = "<<a<<", a address =
"<<&a<<endl;
cout<<*p <<"\t"<< p <<endl;

return 0;
}
Array
- Arrays are used to store multiple values in a single
variable.
- The name of an array is a pointer to the first value.
- Types of array :
- One dimensional.
- Multi dimensional.
#include <iostream>
using namespace std;
int main()
{
int x[5]={12,10,70,50,33};// compile time
cout<<x<<endl;
Example 2:
for(int i=0;i<5;i++)
cout<<"x["<<i<<"]="<<x[i]<<" "<<&x[i]<<endl;
}
#include <iostream>
using namespace std;
int main()
{
int array_len;
cout<<"Enter the length of the array:"<<endl;
cin >> array_len;
int x[array_len];

Example 3:
for(int i=0;i<array_len;i++)
{
cout<<"Enter value for element "<<i+1<<" :"<<endl;
cin>> x[i];
}
cout<<"Array x elements and addresses:"<<endl;
for(int i=0;i<array_len;i++)
{
cout<<"x["<<i<<"]="<<x[i]<<endl;
}
return 0;
}
THANKS!
DO YOU HAVE ANY QUESTIONS?
CREDITS: This presentation template was
created by Slidesgo, including icons by Flaticon,
infographics & images by Freepik and
illustrations by Storyset
Please keep this slide as attribution

You might also like