SlideShare a Scribd company logo
HEAP
GROUP : INFINITY
PRESENTATION TOPIC :Write a program to construct a Heap and perform deletion, insertion,
search, update. Also find the Smallest and Largest Elements in the Heap and Find the Common Ancestor
and Print the Path.
Presented to:
Dr. Sheak Rashed Haider Noori
Assistant Professor
Department Of CSE
Daffodil Internal University
• Presented by:
• Anirudha Dhar Parash (152-15-5742)
• S.M. Zahidul Islam (152-15-5925)
• Samyamay Howlader (152-15-5913)
• Muzahidul Islam (152-15-5585)
• Sharuk Ahmed (152-15-5796)
(Insert Function)
Anirudha Dhar
ID: 152-15-5742
INSERT FUNCTION
void insert(int num, int location)
{
int parentnode;
while (location > 0)
{
parentnode =(location - 1)/2;
if (num <= array[parentnode])
{
array[location] = num;
return;
}
array[location] = array[parentnode];
location = parentnode;
}
array[0] = num;
}
(Delete & Display Function)
S.M. Zahidul Islam
ID: 152-15-5925
DELETE FUNCTION
void delete(int array[],int size )
{
int i=size-1;
array[0]=array[i];
i--;
heap_sort(array,i);
}
void heap_sort(int array[],int size)
{
int i,c,root,temp;
for (i = 1; i <=size; i++)
{
c = i;
do
{
root = (c - 1) / 2;
if (array[root] < array[c])
{
temp = array[root];
array[root] = array[c];
array[c] = temp;
}
c = root;
}
while (c != 0);
}
}
DISPLAY FUNCTION
void display(int array[],int n)
{
int i;
if (n == 0)
{
printf("Heap is empty n");
return;
}
for (i = 0; i < n; i++)
printf("%d ", array[i]);
printf("n");
}
(Search Function)
Samyamay Howlader Niloy
ID: 152-15-5913
SEARCH FUNCTION
void search(int array[],int n)
{
int i,key;
printf("Enter the number that you search:");
scanf("%d",&key);
if (n == 0)
{
printf("Heap is empty n");
return;
}
for (i = 0; i < n; i++)
{
if(array[i]==key)
{
printf("The number is found");
}
}
}
(Max & Min Num Function)
Muzahidul Islam
ID: 152-15-5585
MAX NUM FUNCTION
void max_num(int array[],int n)
{
int i,max;
max=array[0];
for (i = 0; i < n; i++)
{
if(array[i]>max)
{
max=array[i];
}
}
printf("The maximum number in heap: %d",max);
}
MIN NUM FUNCTION
void min_num(int array[],int n)
{
int i,min;
min=array[0];
for (i = 0; i < n; i++)
{
if(array[i]<min)
{
min=array[i];
}
}
printf("The minimum number in heap: %d",min);
}
(COMMON ANCESTOR & Update Function)
Sharuk Ahmed
ID: 152-15-5796
COMMON ANCESTOR FUNCTION
void ancestor(int array[],int n,int num)
{
int i,a[100];
if (n == 0)
{
printf("Heap is empty n");
return;
}
for (i = 0; i < n; i++)
{
a[i]=array[i];
if(array[i]==num)
{
break;
}
}
printf("Common Ancestors : ");
do
{
a[i]=a[(i-1)/2];
printf("%d,",a[i]);
i=(i-1)/2;
}
while(i>=1);
printf("n");
}
UPDATE FUNCTION
void update(int array[],int n )
{
int i,key,num;
printf("enter the number that is to be delete : ");
scanf("%d",&key);
printf("enter the number that you update : ");
scanf("%d",&num);
for(i=0; i<n; i++)
{
if(array[i]==key)
{
array[i]=num;
}
}
heap_sort(array,n);
printf("the number is updated : ");
}
MAIN FUNCTION
int main()
{
int choice, num;
n = 0;
while(1)
{
printf("1.Insert the element n");
printf("2.Delete the element n");
printf("3.Display all elements n");
printf("4.Search element: n");
printf("5.Search max number: n");
printf("6.Search min number: n");
printf("7.Find the Common Ancestor: n");
printf("8.Update an element: n");
printf("9.Quit n");
printf("Enter your choice : ");
scanf("%d", &choice);
switch(choice)
{
case 1:
printf("Enter the element to be inserted to the list :
");
scanf("%d", &num);
insert(num, n);
n = n + 1;
break;
case 2:
delete(array,n);
n=n-1;
break;
case 3:
display(array,n);
break;
case 4:
search(array,n);
break;
case 5:
max_num(array,n);
break;
case 6:
min_num(array,n);
break;
case 7:
printf("Enter the element : ");
scanf("%d", &num);
ancestor(array,n,num);
break;
case 8:
update(array,n);
break;
case 9:
exit(0);
default:
printf("Invalid choice n");
}
}
}
LAIBRARY FUNCTION
&
GLOBAL VARIABLES
#include <stdio.h>
int array[100], n;
Any questions
?
Thank You!!!

More Related Content

What's hot

pycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslatepycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslate
Renyuan Lyu
 
画像Hacks
画像Hacks画像Hacks
画像Hacks
Yusuke Wada
 
3分くらいで分かるassert()
3分くらいで分かるassert()3分くらいで分かるassert()
3分くらいで分かるassert()
Ippei Ogiwara
 
A proper introduction to Elm
A proper introduction to ElmA proper introduction to Elm
A proper introduction to Elm
Johannes Ridderstedt
 
Rumus
RumusRumus
6. Php MongoDB adaugarea unui document
6. Php MongoDB adaugarea unui document6. Php MongoDB adaugarea unui document
6. Php MongoDB adaugarea unui document
Razvan Raducanu, PhD
 
Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regulares
Anel Sosa
 
Drawing on canvas
Drawing on canvasDrawing on canvas
Drawing on canvassuitzero
 
Rubyconfindia2018 - GPU accelerated libraries for Ruby
Rubyconfindia2018 - GPU accelerated libraries for RubyRubyconfindia2018 - GPU accelerated libraries for Ruby
Rubyconfindia2018 - GPU accelerated libraries for Ruby
Prasun Anand
 
Fcontratos
FcontratosFcontratos
Fcontratos
karlloss
 
R code
R codeR code
R code
Manav Goel
 
P5
P5P5
Dfs implementation in c
Dfs implementation in cDfs implementation in c
Dfs implementation in c
HapPy SumOn
 
WordPressでIoTをはじめよう
WordPressでIoTをはじめようWordPressでIoTをはじめよう
WordPressでIoTをはじめよう
Yuriko IKEDA
 

What's hot (15)

pycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslatepycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslate
 
Vcs17
Vcs17Vcs17
Vcs17
 
画像Hacks
画像Hacks画像Hacks
画像Hacks
 
3分くらいで分かるassert()
3分くらいで分かるassert()3分くらいで分かるassert()
3分くらいで分かるassert()
 
A proper introduction to Elm
A proper introduction to ElmA proper introduction to Elm
A proper introduction to Elm
 
Rumus
RumusRumus
Rumus
 
6. Php MongoDB adaugarea unui document
6. Php MongoDB adaugarea unui document6. Php MongoDB adaugarea unui document
6. Php MongoDB adaugarea unui document
 
Programa expresiones regulares
Programa expresiones regularesPrograma expresiones regulares
Programa expresiones regulares
 
Drawing on canvas
Drawing on canvasDrawing on canvas
Drawing on canvas
 
Rubyconfindia2018 - GPU accelerated libraries for Ruby
Rubyconfindia2018 - GPU accelerated libraries for RubyRubyconfindia2018 - GPU accelerated libraries for Ruby
Rubyconfindia2018 - GPU accelerated libraries for Ruby
 
Fcontratos
FcontratosFcontratos
Fcontratos
 
R code
R codeR code
R code
 
P5
P5P5
P5
 
Dfs implementation in c
Dfs implementation in cDfs implementation in c
Dfs implementation in c
 
WordPressでIoTをはじめよう
WordPressでIoTをはじめようWordPressでIoTをはじめよう
WordPressでIoTをはじめよう
 

Similar to Infinity

design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
Nitesh Dubey
 
SPL 11.1 | Problems on Loop , Nested Loop
SPL 11.1 | Problems on Loop , Nested LoopSPL 11.1 | Problems on Loop , Nested Loop
SPL 11.1 | Problems on Loop , Nested Loop
Mohammad Imam Hossain
 
#include stdio.h #include stdlib.h #include time.hdouble.pdf
#include stdio.h #include stdlib.h #include time.hdouble.pdf#include stdio.h #include stdlib.h #include time.hdouble.pdf
#include stdio.h #include stdlib.h #include time.hdouble.pdf
arjunchetri1
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manualSANTOSH RATH
 
Pnno
PnnoPnno
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
Harjinder Singh
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
argusacademy
 
Ada file
Ada fileAda file
Ada file
Kumar Gaurav
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
Trie Data Structure
Trie Data StructureTrie Data Structure
Trie Data Structure
Badiuzzaman Pranto
 
InsertionSort.pdf
InsertionSort.pdfInsertionSort.pdf
InsertionSort.pdf
mayanksanjay007
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
Prof. Dr. K. Adisesha
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++
mustkeem khan
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
mustkeem khan
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
Lakshmi Sarvani Videla
 

Similar to Infinity (20)

design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
SPL 11.1 | Problems on Loop , Nested Loop
SPL 11.1 | Problems on Loop , Nested LoopSPL 11.1 | Problems on Loop , Nested Loop
SPL 11.1 | Problems on Loop , Nested Loop
 
#include stdio.h #include stdlib.h #include time.hdouble.pdf
#include stdio.h #include stdlib.h #include time.hdouble.pdf#include stdio.h #include stdlib.h #include time.hdouble.pdf
#include stdio.h #include stdlib.h #include time.hdouble.pdf
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
Data structure new lab manual
Data structure  new lab manualData structure  new lab manual
Data structure new lab manual
 
Pnno
PnnoPnno
Pnno
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
 
Ada file
Ada fileAda file
Ada file
 
Ds
DsDs
Ds
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Trie Data Structure
Trie Data StructureTrie Data Structure
Trie Data Structure
 
InsertionSort.pdf
InsertionSort.pdfInsertionSort.pdf
InsertionSort.pdf
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++DATA STRUCTURE USING C & C++
DATA STRUCTURE USING C & C++
 
DSU C&C++ Practical File Diploma
DSU C&C++ Practical File DiplomaDSU C&C++ Practical File Diploma
DSU C&C++ Practical File Diploma
 
Solutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structuresSolutionsfor co2 C Programs for data structures
Solutionsfor co2 C Programs for data structures
 

More from S.M.Zahidul Islam sumon

Bioinfo
Bioinfo Bioinfo
Discrete math-presentation
Discrete math-presentationDiscrete math-presentation
Discrete math-presentation
S.M.Zahidul Islam sumon
 
Drone
DroneDrone
C programming
C programmingC programming
Os
OsOs
Physics ii
Physics iiPhysics ii
Block chain
Block chainBlock chain
Image processing
Image processingImage processing
Image processing
S.M.Zahidul Islam sumon
 
Data mining(1)
Data mining(1)Data mining(1)
Data mining(1)
S.M.Zahidul Islam sumon
 
Lcd bresenham
Lcd bresenhamLcd bresenham
Simulation pst
Simulation pstSimulation pst
Simulation pst
S.M.Zahidul Islam sumon
 
Software engineering
Software engineeringSoftware engineering
Software engineering
S.M.Zahidul Islam sumon
 
Technology in education
Technology in educationTechnology in education
Technology in education
S.M.Zahidul Islam sumon
 
Zah architecture 123
Zah architecture 123Zah architecture 123
Zah architecture 123
S.M.Zahidul Islam sumon
 

More from S.M.Zahidul Islam sumon (14)

Bioinfo
Bioinfo Bioinfo
Bioinfo
 
Discrete math-presentation
Discrete math-presentationDiscrete math-presentation
Discrete math-presentation
 
Drone
DroneDrone
Drone
 
C programming
C programmingC programming
C programming
 
Os
OsOs
Os
 
Physics ii
Physics iiPhysics ii
Physics ii
 
Block chain
Block chainBlock chain
Block chain
 
Image processing
Image processingImage processing
Image processing
 
Data mining(1)
Data mining(1)Data mining(1)
Data mining(1)
 
Lcd bresenham
Lcd bresenhamLcd bresenham
Lcd bresenham
 
Simulation pst
Simulation pstSimulation pst
Simulation pst
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Technology in education
Technology in educationTechnology in education
Technology in education
 
Zah architecture 123
Zah architecture 123Zah architecture 123
Zah architecture 123
 

Recently uploaded

Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 

Recently uploaded (20)

Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfCOLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 

Infinity

  • 2. PRESENTATION TOPIC :Write a program to construct a Heap and perform deletion, insertion, search, update. Also find the Smallest and Largest Elements in the Heap and Find the Common Ancestor and Print the Path. Presented to: Dr. Sheak Rashed Haider Noori Assistant Professor Department Of CSE Daffodil Internal University • Presented by: • Anirudha Dhar Parash (152-15-5742) • S.M. Zahidul Islam (152-15-5925) • Samyamay Howlader (152-15-5913) • Muzahidul Islam (152-15-5585) • Sharuk Ahmed (152-15-5796)
  • 4. INSERT FUNCTION void insert(int num, int location) { int parentnode; while (location > 0) { parentnode =(location - 1)/2; if (num <= array[parentnode]) { array[location] = num; return; } array[location] = array[parentnode]; location = parentnode; } array[0] = num; }
  • 5. (Delete & Display Function) S.M. Zahidul Islam ID: 152-15-5925
  • 6. DELETE FUNCTION void delete(int array[],int size ) { int i=size-1; array[0]=array[i]; i--; heap_sort(array,i); } void heap_sort(int array[],int size) { int i,c,root,temp;
  • 7. for (i = 1; i <=size; i++) { c = i; do { root = (c - 1) / 2; if (array[root] < array[c]) { temp = array[root]; array[root] = array[c]; array[c] = temp; } c = root; } while (c != 0); } }
  • 8. DISPLAY FUNCTION void display(int array[],int n) { int i; if (n == 0) { printf("Heap is empty n"); return; } for (i = 0; i < n; i++) printf("%d ", array[i]); printf("n"); }
  • 9. (Search Function) Samyamay Howlader Niloy ID: 152-15-5913
  • 10. SEARCH FUNCTION void search(int array[],int n) { int i,key; printf("Enter the number that you search:"); scanf("%d",&key); if (n == 0) { printf("Heap is empty n"); return; } for (i = 0; i < n; i++) { if(array[i]==key) { printf("The number is found"); } } }
  • 11. (Max & Min Num Function) Muzahidul Islam ID: 152-15-5585
  • 12. MAX NUM FUNCTION void max_num(int array[],int n) { int i,max; max=array[0]; for (i = 0; i < n; i++) { if(array[i]>max) { max=array[i]; } } printf("The maximum number in heap: %d",max); }
  • 13. MIN NUM FUNCTION void min_num(int array[],int n) { int i,min; min=array[0]; for (i = 0; i < n; i++) { if(array[i]<min) { min=array[i]; } } printf("The minimum number in heap: %d",min); }
  • 14. (COMMON ANCESTOR & Update Function) Sharuk Ahmed ID: 152-15-5796
  • 15. COMMON ANCESTOR FUNCTION void ancestor(int array[],int n,int num) { int i,a[100]; if (n == 0) { printf("Heap is empty n"); return; } for (i = 0; i < n; i++) { a[i]=array[i]; if(array[i]==num) { break; } }
  • 16. printf("Common Ancestors : "); do { a[i]=a[(i-1)/2]; printf("%d,",a[i]); i=(i-1)/2; } while(i>=1); printf("n"); }
  • 17. UPDATE FUNCTION void update(int array[],int n ) { int i,key,num; printf("enter the number that is to be delete : "); scanf("%d",&key); printf("enter the number that you update : "); scanf("%d",&num); for(i=0; i<n; i++) { if(array[i]==key) { array[i]=num; } } heap_sort(array,n); printf("the number is updated : "); }
  • 18. MAIN FUNCTION int main() { int choice, num; n = 0; while(1) { printf("1.Insert the element n"); printf("2.Delete the element n"); printf("3.Display all elements n"); printf("4.Search element: n"); printf("5.Search max number: n"); printf("6.Search min number: n"); printf("7.Find the Common Ancestor: n"); printf("8.Update an element: n"); printf("9.Quit n"); printf("Enter your choice : ");
  • 19. scanf("%d", &choice); switch(choice) { case 1: printf("Enter the element to be inserted to the list : "); scanf("%d", &num); insert(num, n); n = n + 1; break; case 2: delete(array,n); n=n-1; break;
  • 20. case 3: display(array,n); break; case 4: search(array,n); break; case 5: max_num(array,n); break; case 6: min_num(array,n); break; case 7: printf("Enter the element : "); scanf("%d", &num); ancestor(array,n,num); break;
  • 22. LAIBRARY FUNCTION & GLOBAL VARIABLES #include <stdio.h> int array[100], n;