0% found this document useful (0 votes)
27 views10 pages

Sumit Dsa

The document provides an overview of various data structures, databases, data warehouses, big data, algorithms, and memory management concepts like stack and heap. It explains the importance of data structures for efficient data management and introduces key concepts such as time complexity using Big O notation, best-case, worst-case, and average-case analysis. Additionally, it discusses abstract data types (ADT) and their operations, particularly focusing on arrays as an example.

Uploaded by

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

Sumit Dsa

The document provides an overview of various data structures, databases, data warehouses, big data, algorithms, and memory management concepts like stack and heap. It explains the importance of data structures for efficient data management and introduces key concepts such as time complexity using Big O notation, best-case, worst-case, and average-case analysis. Additionally, it discusses abstract data types (ADT) and their operations, particularly focusing on arrays as an example.

Uploaded by

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

===================================================================================

=DATA STRATURE
===================================================================================
=======

Data Structure ek aisa way hai jisme data ko organize aur manage kiya jata hai
taaki us data par asani se operations perform kiye ja saken, jaise data ko store
karna, retrieve karna, sort karna, etc.

Samjho ki aapko ek library me kitaaben arrange karni hain. Agar kitaaben haphazard
(bina kisi order ke) rakhi hui hongi, to unko dhoondhna mushkil hoga. Lekin agar
aap unhe alphabetically ya category-wise arrange karoge, to jaldi se mil jayengi.
Data structure kuch aise hi kaam karta hai.

Types of Data Structures:


Array (सरणी):

Fixed size ka ordered collection of elements hota hai.


Har element ko ek index number se access kiya ja sakta hai.

Data Structure kyun zaroori hai?


Efficient data management: Data structures ki madad se hum data ko efficiently
store aur access kar sakte hain.
Optimized algorithms: Sahi data structure select karne se algorithms fast aur
optimized hote hain.
Complex problems ko solve karna: Jaise graphs aur trees complex data ko represent
karte hain aur unhe aasani se manage karte hain.
===================================================================================
===DATABASE========================================================================
======================

Database ek organized collection hota hai data ka, jise hum efficiently store,
retrieve, update, aur manage kar sakte hain. Database ko use karke hum large amount
of data ko systematic tareeke se store karte hain taaki usse aasani se access kiya
ja sake.

Key Concepts of Database:


Table (तालिका):

Database ke andar data tables me stored hota hai. Ek table rows (rows) aur columns
(columns) ka collection hoti hai.
Row (पंक्ति): Har row ek record ko represent karti hai.
Column (स्तंभ): Har column kisi specific type ke data ko represent karta hai.
Example: Student ka table, jisme har row ek student ka data (ID, naam, marks, etc.)
hoga aur columns me wo specific information hogi.

===================================================================================
==DATAWAREHOUSE====================================================================
======================
Data Warehouse ek centralized system hota hai jahan large amount of data ko long
term ke liye store kiya jata hai. Iska main purpose analysis, reporting, aur
decision-making ke liye historical data ko store karna hota hai.
Key Concepts:
Structured Data: Data warehouse me structured data store kiya jata hai, jo
databases aur tables ke format me organized hota hai (jaise relational databases).

===================================================================================
===BIG
DATA===============================================================================
===============

Big Data ka matlab hai extremely large aur complex data sets jo traditional
databases ke through process nahi kiya ja sakte. Big Data ka main purpose real-time
processing aur unstructured data ko handle karna hota hai.

Key Characteristics (3Vs of Big Data):


Volume: Bahut large amount of data hota hai, jo petabytes ya exabytes tak ho sakta
hai.
Velocity: Data high speed se generate aur process hota hai, jaise live data
streaming.
Variety: Data alag-alag sources se aata hai aur unstructured, semi-structured ya
structured ho sakta hai (jaise text, images, videos, sensors data).

===================================================================================
====ALGORTHOM======================================================================
======================

Algorithm ek step-by-step procedure hota hai jo kisi problem ko solve karne ke liye
follow kiya jata hai. Ye ek finite set of instructions hota hai jo clearly defined
steps me bataata hai ki kaise kisi specific problem ko solve kiya jaye.

===================================================================================
====STACK AND
HEAP===============================================================================
========

Stack ek special memory area hai jo LIFO (Last In, First Out) principle par kaam
karta hai. Stack mainly static memory allocation ke liye use hota hai, jisme memory
ko compile-time par allocate aur deallocate kiya jata hai

Pros of Stack:
=============

Fast memory access.


Automatic memory management.
Suitable for small, short-term variables.

Cons of Stack:
=============

Memory size limited hota hai.


Large data ko stack me store nahi kiya ja sakta (stack overflow).

HEAP
====
Heap ek memory area hai jisme dynamic memory allocation hota hai, matlab memory ko
runtime par allocate kiya jata hai. Jab aapko program ke execution ke dauran
(runtime) memory ki zaroorat hoti hai, to heap se memory allocate ki jati hai.

Pros of Heap:
============
Large amount of memory allocate kiya ja sakta hai.
Memory ko runtime ke hisaab se manage kiya ja sakta hai.
Cons of Heap:
============
Slower Access: Stack ke mukable heap memory access karna thoda slow hota hai.
Memory Fragmentation: Heap me alag-alag sizes ke data ko allocate karne ke baad
memory fragmented ho sakti hai.

===================================================================================
===========notestion===============================================================
======================

. Big O Notation (O)


===================
Purpose: Worst-case time complexity ko represent karta hai.
Explanation: Iska use karte hain jab hume samajhna hota hai ki ek algorithm ka
performance worst-case scenario me kaisa hoga. Big O notation ye batata hai ki
input size badhne par algorithm ka running time ya memory usage kitna slow hoga.

Example: Agar algorithm ki complexity O(n) hai, to iska matlab hai ki jaise-jaise
input size (n) badhta hai, waise algorithm ka time linear tareeke se badhta hai.
=======
Example Time Complexities:
=========================

O(1): Constant time.


O(log n): Logarithmic time (e.g., Binary Search).
O(n): Linear time (e.g., Linear Search).
O(n^2): Quadratic time (e.g., Bubble Sort).

2. Big Omega Notation (Ω)


========================

Purpose: Best-case time complexity ko represent karta hai.


Explanation: Big Omega notation ye batata hai ki best-case scenario me algorithm
kitni fast ho sakti hai. Iska use tab hota hai jab hume kisi algorithm ki minimum
performance ki guarantee dekhni ho.

Example: Agar algorithm ki complexity Ω(n) hai, to iska matlab hai ki best-case me
algorithm ka time complexity linear hoga.
========
Example Time Complexities:
==========================

Ω(1): Constant time in the best case.


Ω(log n): Logarithmic time in the best case.
Ω(n): Linear time in the best case.
3. Big Theta Notation (Θ)
=======================
Purpose: Exact time complexity ko represent karta hai.
Explanation: Big Theta notation batata hai ki algorithm ki performance best-case
aur worst-case ke beech consistent hai. Jab ek algorithm ki average-case
performance aur worst-case performance ek jaise ho, tab hum Big Theta use karte
hain.
Example: Agar algorithm ki complexity Θ(n) hai, iska matlab hai ki algorithm ka
time complexity best-case, worst-case, aur average-case scenario me linear hi
rahega.
=========
Example Time Complexities:
=========================

Θ(1): Constant time.


Θ(log n): Logarithmic time.
Θ(n): Linear time.

LOG(N)
========
LOG KA MATLAB HOTA HAI KI N KO KITNE BAAR ADA(THODO) KARO
XE=
N=8
8,6,4,2
LOG HOGA VO LOG 4 HOGA KYO KI N KO HAM NE 4 BAR TODA HAI

***LOG(N) TIME IS THE BEST TIME ***

===============================================================================best
case worst case and average case with
notestion=========================================================

1. Best Case Analysis (Zindagi ke lucky moments)


================================================

Best case wo situation hoti hai jab algorithm ko sab kuch bilkul sahi milta hai,
aur wo minimum kaam karta hai. Yani ki algorithm sabse kam steps me apna kaam kar
leta hai. Jaise agar aapka exam me wahi question aajaye jo aapne sabse achi tarah
prepare kiya tha.

Example with Linear Search: Sochiye aapko ek array me koi number dhoondhna hai.
Agar wo number array ke bilkul pehle wale position par ho, to aapko bas ek
comparison karna padega

&)Best Case Time Complexity: 𝑂(1)O(1) hoti hai, kyun ke aapko pehle hi element mil
gaya.
Example with Binary Search: Agar aap sorted array me Binary Search use kar rahe
hain aur pehla comparison hi sahi ho jaaye, to aapka kaam turant khatam ho jata
hai.

2. Worst Case Analysis (Zindagi ke unlucky moments)


==============================================
Worst case wo hota hai jab algorithm ko sabse zyada kaam karna padta hai. Isme sab
kuch ulta hota hai, aur program ko maximum steps lene padte hain. Jaise exam me
wahi question aajaye jo aapne bilkul nahi padhe ho.

Example with Linear Search: Agar wo number array ke sabse last position par ho ya
array me ho hi na, to aapko poora array check karna padega.

&)Worst Case Time Complexity: 𝑂(𝑛)O(n) hoti hai, kyunki aapko har element ko check
karna padega.

Example with Binary Search: Binary Search me worst case tab hota hai jab aapko
array ko baar baar half karte hue ek single element tak pahuchna padta hai, phir
bhi number nahi milta.

3. Average Case Analysis (Zindagi ke normal moments)


===============================================
Average case wo hota hai jab algorithm na zyada aasani se kaam karta hai, na hi
zyada mushkil se. Yani yeh ek typical scenario hai. Jaise kabhi easy questions
aajate hain aur kabhi mushkil, dono mila ke overall balance ban jata hai.
Example with Linear Search: Agar Linear Search me aapko element array ke beech me
kahi milta hai, toaapko roughly aadha array check karna padta hai.

Average Case Time Complexity: 𝑂(𝑛)


O(n) hoti hai, kyunki aapko aadha array check karna padta hai.
Example with Binary Search: Binary Search me average case me array ko kuch baar
divide karna padta hai jab tak number milta hai.

&)Average Case Time Complexity: 𝑂(log 𝑛)O(logn), kyunki array ko divide karke
search efficient ho jati hai.

Linear Search aur Binary Search ki Analysis:


=======================================
1)Linear Search (Algorithm 1):
==========================
&)Yeh algorithm pehle element se shuru karta hai aur har element ko ek-ek karke

&)Best Case: 𝑂(1)O(1), agar pehla hi element target ho.


check karta hai.

&)Worst Case: 𝑂(𝑛)O(n), agar target last element ho ya hohina.


&)Average Case: 𝑂(𝑛)O(n), kyunki average me aadha array check karna padta hai.

Binary Search (Algorithm 2):


=========================
Binary Search array ko aadha karta hai aur beech ka element check karta hai. Fir
array ke appropriate half me search karta hai.

Best Case: 𝑂(1) agar pehla hi comparison sahi ho.


Worst Case: 𝑂(log⁡)jab
𝑛 tak ek element bacha ho, aap array ko half karte rehte

Average Case: 𝑂(log⁡),


𝑛
hain.
kyunki search karte waqt array ko baar baar divide karna
efficient hota hai.

Space Complexity:
================
Space complexity yeh batata hai ke ek algorithm kitna zyada memory use karta hai,
time ke ilawa.

Linear Search: Iska space complexity 𝑂(1) hota hai kyunki sirf ek index store
karna hota hai
============
.Binary Search:

version𝑂(log⁡)O(logn)
𝑛
============ Iterative version ka space complexity O(1) hota hai, lekin recursive
hota hai recursion ke call stack ki wajah se.

Time Complexity ko Seconds me Kyun Nahi Nape?


======================================
Har computer ka processing power alag hota hai. Isliye hum time ko seconds me
naapne ke bajaye, uska algorithm ka input size ke sath badhne ka pattern dekhte
hain. Is process ko asymptotic analysis kehte hain.

================================================================================ABS
TRACT DATA
TYPES(ADT)=========================================================================
===========

Abstract Data Types (ADT)** ko hum aise samajh sakte hain jaise ek "naksha" ya
"blueprint" jo batata hai ki kisi data structure par kya-kya operations (kaam) ho
sakte hain, lekin yeh nahi batata ki unko kaise kiya jayega. ADT ek tarah se rules
set karta hai ki hum kin kaamon ko kar sakte hain, jaise data ko insert karna,
delete karna, ya search karna, lekin us data ko kaise store ya manage kiya ja raha
hai, yeh chhupa ke rakhta hai.

Array ADT:
=========
Array ek ADT hai jo elements ka collection hota hai, aur har element ko ek unique
index ke through access kiya ja sakta hai. Array me jo basic kaam (operations) hum
kar sakte hain, wo kuch is tarah ke hote hain:

1. get(i): Yeh function array ke kisi particular index **i** par jo element hai,
usse return karta hai.
2. set(i, num): Is function se hum array ke kisi index **i** par koi naya element
(jaise **num**) set kar sakte hain.

### Array ke Operations:


Array me hum kuch basic operations perform kar sakte hain, jaise:

-Max()**: Array me sabse bada element find karna.


- Min()**: Array me sabse chhota element find karna.
- Search(num)**: Array me kisi particular element ko dhoondhna.
- Insert(i, num)**: Kisi index **i** par naya element insert karna.
- Append(x)**: Array ke last me ek naya element jodna.

Static aur Dynamic Arrays:


========================
1. **Static Arrays**: Static array ka size ek baar set hone ke baad badla nahi ja
sakta.
2. **Dynamic Arrays**: Dynamic array ka size badla ja sakta hai (resize kar sakte
hain) jab zarurat pade.
### Memory Representation of Arrays:
=================================
- Array ke elements memory me **contiguous** yaani ek ke baad ek memory locations
me store hote hain.
- Array ke kisi bhi element ko **constant time** me access kiya ja sakta hai, iska
time complexity hota hai **O(1)**.
- Static array ka size badalna mushkil hota hai, lekin **dynamic array** me hum
array ko ek nayi, badi memory location par reallocate kar sakte hain, jo thoda
time-consuming hota hai.

Yeh basic concepts hain jo array ke bare me samajhne ke liye zaroori hain. Agle
step me hum in concepts ko coding ke through implement kar sakte hain.

=====================================================================Array as An
Abstract Data Type in Data Structures
Notes============================================================

Array ko Abstract Data Type (ADT) ke roop me samajhna aasan hai. ADT ek tarah ka
user-defined data type hota hai, jo hum apne hisaab se methods aur operations ke
sath bana sakte hain. Jaise humne int ya float data types ka use kiya hai, waise hi
ADT me hum apne khud ke methods aur operations define kar sakte hain.

Ab samjho ki hume ek array banana hai jo ek customized array ho, jisme hum apne
tarike se values aur operations ko control kar sakein. Hum is array ka naam myArray
rakhte hain. Is array ke kuch important values aur operations honge.

Values (Parameters):
total_size: Yeh parameter array ke total memory size ko batata hai, yaani kitni
jagah reserve ki gayi hai array ke liye.
used_size: Yeh parameter batata hai ki array me kitni memory ka actual use ho raha
hai.
base_address: Yeh pointer hota hai jo array ke pehle element ka address ya memory
location store karta hai.
Example: Agar humne ek array banaya jisme total 6 elements rakhne ki jagah reserve
ki hai, lekin abhi tak sirf 3 elements use ho rahe hain, to:

total_size = 6
used_size = 3
Operations (Methods):
max(): Array me jo sabse bada element hai, use find karne ke liye method.
get(i): Array ke kisi particular index i par jo element hai, usko retrieve karne ke
liye method.
set(i, num): Array ke kisi particular index i par ek naya element set karne ke liye
method.
add(another_array): Do arrays ko mila kar ek naya array banane ke liye method.
Implementation ka idea:
Hum array ko ek structure ke roop me define kar sakte hain, jisme yeh sab values
aur methods honge. Hum in values aur methods ka code likh kar apna customized array
bana sakte hain jo heap memory me store hota hai (heap memory dynamic hoti hai,
isliye hum array ka size change kar sakte hain jab zarurat pade).

================================================================================tra
vertion of the
arrry==============================================================================
=======
element tak jana or dekh na

/******************************************************************************

Welcome to GDB Online.


GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP,
Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS,
JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <stdio.h>

void display(int arry[],int n)


{
for(int i=0;i<n;i++)
{
printf("%d\t",arry[i]);

}printf("\n");
}

int main()
{
int arry[100]={12,1,22,33,454,545};
display(arry,6);

return 0;
}

===================================================================================
insertioncode======================================================================
======================
#include <stdio.h>

void display(int arry[], int n) {


for (int i = 0; i < n; i++) {
printf("%d\t", arry[i]);
}
printf("\n");
}

int insertion(int arry[], int size, int capacity, int element, int index) {
if (size >= capacity) {
printf("chak");
return -1;
}

// Shift elements from the back to the front to make space


for (int i = size-1; i >=index; i--) {
arry[i+1]=arry[i];
}
// Insert the element at the specified index
arry[index] = element;
printf("insertion is complete\n");

return 0;
}

int main() {
int arry[100] = {12, 233, 223, 44, 22, 3};
int size = 6, capacity = 100, element = 34, index = 3;

// Perform the insertion


insertion(arry, size, capacity, element, index);
size += 1; // Update size after insertion

// Display the updated array


display(arry, size);

return 0;
}

===================================================================================
=deletion
===================================================================================
============

#include <stdio.h>

// Function to display the elements of an array


void display(int arry[], int n)
{
// Loop to print array elements up to index `n`
for (int i = 0; i <= n; i++)
{
printf("%d\t", arry[i]); // Print each element followed by a tab
}
}

// Function to delete an element at a given index and replace it with a new element
int deletion(int size, int index, int arry[], int element)
{
// Loop to shift elements to the left, starting from the specified index
for (int i = index; i < size - 1; i++)
{
arry[i] = arry[i + 1]; // Assign the next element to the current position
}
// Assign the new element to the specified index
arry[index] = element;
}
int main()
{
// Initialize an array with some predefined elements
int arry[100] = {100, 122, 23, 323, 233};
int size = 5; // Number of elements in the array
int index = 2; // Index where deletion and replacement will occur
int element = 221; // New element to insert at the specified index

size -= 1; // Reduce size by 1 as an element is being replaced/deleted

// Call the deletion function to modify the array


deletion(size, index, arry, element);

// Call the display function to print the modified array


display(arry, size);

return 0;
}

You might also like