Lec 1
Lec 1
& 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
Array.
-
Dynamic
Data Structures Examples
Arrays Trees
Stack
Linked Queue
Lists
Data Structures Major Operations
Updating Searching
- is a variable that stores the memory
address as its value.
Pointers
#include <iostream>
using namespace std;
int main()
{
int a = 15;
int *p;
Example 1:
p = &a;
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