SlideShare a Scribd company logo
1 of 16
Download to read offline
THE
CELEBRITY
PROBLEM
Presented By: Group 1
Ipsita Raha – Dibyendu Banik – Arnab Chatterjee – Arijit Dhali
11500120054 – 11500320062 – 11500320076 – 11500320078
SOLVING BY GRAPHICAL METHOD
TABLE OF CONTENTS
Disscussing Problem
& Strategy
01
Graphical
Approach
02
Pseudocode &
Algorithm
03
Complexity Analysis
& Result analysis
04
Program Code &
Other Approaches
05
Conclusion &
References
06
CELEBRITY
PROBLEM
A celebrity among a group of n people is a
person who knows nobody but is known
by everybody else. The task is to identify a
celebrity by only asking questions to
people of the following form: “Do you
know this person?
STRATEGY
0 0 1 0 0
0 0 1 0 0
0 0 0 0 0
0 0 1 0 0
0 0 1 0 0
0
1
2
3
4
0 1 2 3 4
Person
Let us understand the solution using two sample cases where we consider a matrix of person [ i , j ]
(for person i knows j or not)
Hence, 2 is the Celebrity here
Case 1: 0 0 1 0 0
0 0 1 0 0
0 1 0 0 0
0 0 1 0 0
0 0 1 0 0
0
1
2
3
4
0 1 2 3 4
Person
Case 2:
Hence, there is no celebrity here
From these examples,
We can conclude the conditions :
• Condition 1:
Every other person knows the celebrity
• Condition 2:
Celebrity doesn’t knows no other person
01
GRAPHICAL
APPROACH
● Model the solution using graphs
● Initialize indegree and outdegree of every vertex as 0.
● If A knows B, draw a directed edge from A to B, increase
indegree of B and outdegree of A by 1.
● Construct all possible edges of the graph for every possible
pair [ i , j ].
● Now there are nC2 pairs.
● For atleast 1 celebrity present in the party, there will be one
sink node in the graph with outdegree of zero and indegree
of N-1
PSEUDOCODE
1. Create two arrays indegree and outdegree, to store the indegree and outdegree
2. Run a nested loop, the outer loop from 0 to n and inner loop from 0 to n.
3. For every pair i, j check if i knows j then increase the outdegree of i and indegree of j
4. For every pair i, j check if j knows i then increase the outdegree of j and indegree of i
5. Run a loop from 0 to n and find the id where the indegree is n-1 and outdegree is 0
ALGORITHM WITH TIME COMPLEXITY
findCelebrity (n):
indegree -> [0 for x from 0 to n]
outdegree -> [0 for x from 0 to n]
for i <- 0 to n -1
for j <- 0 to n -1
x = knows( i , j )
outdegree[ i ] + = x
indegree[ j ] + = x
for i <- 0 to n -1
if indegree[ i ] = n - 1 and outdegree[ i ] = 0
return i
return -1
Cost Times
C1
n
C2
C3
C4
෍
𝑗=0
𝑛−1
𝑡𝑗
C5
C6
C7
C8
n
C9
C10
C11 1
CONTINUATION
knows(a, b):
return MATRIX[ a ][ b ]
Main:
id <- findCelebrity(n)
if id = -1:
No celebrity
else
Celebrity Present, print id
Cost Times
C12 1
Here, tj is the number of times the while loop is executed.
Also, MATRIX = [ [ 0, 0, 1, 0 ], and N = 4 ( Person in party )
[ 0, 0, 1, 0 ],
[ 0, 0, 0, 0 ],
[ 0, 0, 1, 0 ] ]
Cost Times
C13 1
C14
1
C15
C16
1
C17
COMPLEXITY ANALYSIS
● Time Complexity : O(n2)
A nested loop is run traversing the array, SO the
time complexity is O(n2)
= (C1+C2+C3+C8+C9+C10 )(n) + (C4+C5+C6+C7)(n2) +
C11 + C12 + C13 + C14 + C15 + C16 + C17
= O(n2)
● Space Complexity: O(n)
Since extra space of size n is required.
RESULT ANALYSIS 1
Let us consider the previous case 1, and create tables for
indegree and outdegree
0 0 1 0 0
0 0 1 0 0
0 0 0 0 0
0 0 1 0 0
0 0 1 0 0
0
1
2
3
4
0 1 2 3 4
Person
Indegree Outdegree
0 0 0
1 0 0
2 0 0
3 0 0
4 0 0
1
1
2
1
1
3
1
4
In this table we can see, person 2 has
Indegree = 4 = (5 – 1) or (n – 1)
Outdegree = 0
∴ Person 2 is the celebrity
RESULT ANALYSIS 2
Let us consider the previous case 2, and create tables for
indegree and outdegree
Indegree Outdegree
0 0 0
1 0 0
2 0 0
3 0 0
4 0 0
1
1
2
1
1
3
1
4
In this table we can see, person 2 has
Indegree = 5 ≠ (5 – 1) or (n – 1)
Outdegree = 1
∴ Returns -1 which means no celebrity
0 0 1 0 0
0 0 1 0 0
0 1 0 0 0
0 0 1 0 0
0 0 1 0 0
0
1
2
3
4
0 1 2 3 4
Person 1
1
PROGRAM
CODE
OTHER APPROACHES
02
RECURSIVE
APPROACH
03
STACKING
APPROACH
CONCLUSION
In this term paper we solved the given problem using
graphical method.
For graphs to be computationally useful, they have to be
conveniently represented in programs.
However it is simple to implement, easy and fast to tell if
a pair ( i , j ) is an edge: simply check if A[ i ][ j ] is 1 or 0.
No matter how few edges the graph has, the matrix takes
O(n2) in memory
References
● https://www.geeksforgeeks.org/the-celebrity-problem/
● https://tutorialspoint.dev/data-structure/stack-data-structure/the-celebrity-problem
● https://www.youtube.com/watch?v=aENYremq77I&list=LL
CREDITS: This presentation template was created by Slidesgo,
including icons by Flaticon, infographics & images by Freepik
THANK
YOU
For your kind attention towards our
presentation
Group 1

More Related Content

What's hot

Wavelet transform in image compression
Wavelet transform in image compressionWavelet transform in image compression
Wavelet transform in image compressionjeevithaelangovan
 
PhD Oral Defense of Md Kafiul Islam on "ARTIFACT CHARACTERIZATION, DETECTION ...
PhD Oral Defense of Md Kafiul Islam on "ARTIFACT CHARACTERIZATION, DETECTION ...PhD Oral Defense of Md Kafiul Islam on "ARTIFACT CHARACTERIZATION, DETECTION ...
PhD Oral Defense of Md Kafiul Islam on "ARTIFACT CHARACTERIZATION, DETECTION ...Md Kafiul Islam
 
Attention in Deep Learning
Attention in Deep LearningAttention in Deep Learning
Attention in Deep Learning健程 杨
 
Discrete fourier transform
Discrete fourier transformDiscrete fourier transform
Discrete fourier transformMOHAMMAD AKRAM
 
Discrete Time Fourier Transform
Discrete Time Fourier TransformDiscrete Time Fourier Transform
Discrete Time Fourier TransformWaqas Afzal
 
Speech recognition project report
Speech recognition project reportSpeech recognition project report
Speech recognition project reportSarang Afle
 
Basics of pixel neighbor.
Basics of pixel neighbor.Basics of pixel neighbor.
Basics of pixel neighbor.raheel rajput
 
Image compression in digital image processing
Image compression in digital image processingImage compression in digital image processing
Image compression in digital image processingDHIVYADEVAKI
 
Computer Vision: Correlation, Convolution, and Gradient
Computer Vision: Correlation, Convolution, and GradientComputer Vision: Correlation, Convolution, and Gradient
Computer Vision: Correlation, Convolution, and GradientAhmed Gad
 
New error-detection
New error-detectionNew error-detection
New error-detectionNitesh Singh
 
Histogram Processing
Histogram ProcessingHistogram Processing
Histogram ProcessingAmnaakhaan
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domainAshish Kumar
 
Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2DigiGurukul
 

What's hot (20)

Wavelet transform in image compression
Wavelet transform in image compressionWavelet transform in image compression
Wavelet transform in image compression
 
PhD Oral Defense of Md Kafiul Islam on "ARTIFACT CHARACTERIZATION, DETECTION ...
PhD Oral Defense of Md Kafiul Islam on "ARTIFACT CHARACTERIZATION, DETECTION ...PhD Oral Defense of Md Kafiul Islam on "ARTIFACT CHARACTERIZATION, DETECTION ...
PhD Oral Defense of Md Kafiul Islam on "ARTIFACT CHARACTERIZATION, DETECTION ...
 
Attention in Deep Learning
Attention in Deep LearningAttention in Deep Learning
Attention in Deep Learning
 
Kernel (OS)
Kernel (OS)Kernel (OS)
Kernel (OS)
 
Image compression models
Image compression modelsImage compression models
Image compression models
 
Discrete fourier transform
Discrete fourier transformDiscrete fourier transform
Discrete fourier transform
 
Discrete Time Fourier Transform
Discrete Time Fourier TransformDiscrete Time Fourier Transform
Discrete Time Fourier Transform
 
Loops in flow
Loops in flowLoops in flow
Loops in flow
 
Speech recognition project report
Speech recognition project reportSpeech recognition project report
Speech recognition project report
 
Matched filter
Matched filterMatched filter
Matched filter
 
Basics of pixel neighbor.
Basics of pixel neighbor.Basics of pixel neighbor.
Basics of pixel neighbor.
 
Np cooks theorem
Np cooks theoremNp cooks theorem
Np cooks theorem
 
Image compression in digital image processing
Image compression in digital image processingImage compression in digital image processing
Image compression in digital image processing
 
Computer Vision: Correlation, Convolution, and Gradient
Computer Vision: Correlation, Convolution, and GradientComputer Vision: Correlation, Convolution, and Gradient
Computer Vision: Correlation, Convolution, and Gradient
 
New error-detection
New error-detectionNew error-detection
New error-detection
 
Histogram Processing
Histogram ProcessingHistogram Processing
Histogram Processing
 
Speech Signal Analysis
Speech Signal AnalysisSpeech Signal Analysis
Speech Signal Analysis
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Enhancement in frequency domain
Enhancement in frequency domainEnhancement in frequency domain
Enhancement in frequency domain
 
Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2Artificial Intelligence Notes Unit 2
Artificial Intelligence Notes Unit 2
 

Similar to The Celebrity Problem Graph

ix-number system-ppt(2).pptx
ix-number system-ppt(2).pptxix-number system-ppt(2).pptx
ix-number system-ppt(2).pptxRajkumarknms
 
1 complex numbers part 1 of 3
1 complex numbers part 1 of 31 complex numbers part 1 of 3
1 complex numbers part 1 of 3naveenkumar9211
 
Number System2.pptx
Number System2.pptxNumber System2.pptx
Number System2.pptxAnshRattan
 
Normal distribution slide share
Normal distribution slide shareNormal distribution slide share
Normal distribution slide shareKate FLR
 
Section 4.1 And 4.2 Plus Warm Ups
Section 4.1 And 4.2 Plus Warm UpsSection 4.1 And 4.2 Plus Warm Ups
Section 4.1 And 4.2 Plus Warm UpsJessca Lundin
 
Perspectives and application of fuzzy initial value problems
Perspectives and application of fuzzy initial value problemsPerspectives and application of fuzzy initial value problems
Perspectives and application of fuzzy initial value problemsRAJKRISHNA MONDAL
 
Perspectives and application of fuzzy initial value problems
Perspectives and application of fuzzy initial value problemsPerspectives and application of fuzzy initial value problems
Perspectives and application of fuzzy initial value problemsRAJKRISHNA MONDAL
 
Integers And Order of Operations
Integers And Order of OperationsIntegers And Order of Operations
Integers And Order of Operationsnickromero76
 
Statistics for CEGEP Biology
Statistics for CEGEP BiologyStatistics for CEGEP Biology
Statistics for CEGEP BiologyCorey Chivers
 
cie-as-maths-9709-statistics1-v2-znotes.pdf
cie-as-maths-9709-statistics1-v2-znotes.pdfcie-as-maths-9709-statistics1-v2-znotes.pdf
cie-as-maths-9709-statistics1-v2-znotes.pdfYiranMa4
 
cie-as-maths-9709-statistics1-v2-znotes 2.pdf
cie-as-maths-9709-statistics1-v2-znotes 2.pdfcie-as-maths-9709-statistics1-v2-znotes 2.pdf
cie-as-maths-9709-statistics1-v2-znotes 2.pdfYiranMa4
 
W1-L1 Negative-numbers-ppt..pptx
W1-L1 Negative-numbers-ppt..pptxW1-L1 Negative-numbers-ppt..pptx
W1-L1 Negative-numbers-ppt..pptxGhassan44
 
Day 7 distributive property
Day 7 distributive propertyDay 7 distributive property
Day 7 distributive propertyErik Tjersland
 
Lec10-CS110 Computational Engineering
Lec10-CS110 Computational EngineeringLec10-CS110 Computational Engineering
Lec10-CS110 Computational EngineeringSri Harsha Pamu
 
Interpolation and Extrapolation
Interpolation and ExtrapolationInterpolation and Extrapolation
Interpolation and ExtrapolationVNRacademy
 
Game theory for neural networks
Game theory for neural networksGame theory for neural networks
Game theory for neural networksDavid Balduzzi
 
3.2 insertion sort
3.2 insertion sort3.2 insertion sort
3.2 insertion sortKrish_ver2
 

Similar to The Celebrity Problem Graph (20)

ix-number system-ppt(2).pptx
ix-number system-ppt(2).pptxix-number system-ppt(2).pptx
ix-number system-ppt(2).pptx
 
RSA without Integrity Checks
RSA without Integrity ChecksRSA without Integrity Checks
RSA without Integrity Checks
 
1 complex numbers part 1 of 3
1 complex numbers part 1 of 31 complex numbers part 1 of 3
1 complex numbers part 1 of 3
 
Chinese remainder theorem
Chinese remainder theoremChinese remainder theorem
Chinese remainder theorem
 
Number System2.pptx
Number System2.pptxNumber System2.pptx
Number System2.pptx
 
Normal distribution slide share
Normal distribution slide shareNormal distribution slide share
Normal distribution slide share
 
Section 4.1 And 4.2 Plus Warm Ups
Section 4.1 And 4.2 Plus Warm UpsSection 4.1 And 4.2 Plus Warm Ups
Section 4.1 And 4.2 Plus Warm Ups
 
Perspectives and application of fuzzy initial value problems
Perspectives and application of fuzzy initial value problemsPerspectives and application of fuzzy initial value problems
Perspectives and application of fuzzy initial value problems
 
Perspectives and application of fuzzy initial value problems
Perspectives and application of fuzzy initial value problemsPerspectives and application of fuzzy initial value problems
Perspectives and application of fuzzy initial value problems
 
Integers And Order of Operations
Integers And Order of OperationsIntegers And Order of Operations
Integers And Order of Operations
 
Statistics for CEGEP Biology
Statistics for CEGEP BiologyStatistics for CEGEP Biology
Statistics for CEGEP Biology
 
cie-as-maths-9709-statistics1-v2-znotes.pdf
cie-as-maths-9709-statistics1-v2-znotes.pdfcie-as-maths-9709-statistics1-v2-znotes.pdf
cie-as-maths-9709-statistics1-v2-znotes.pdf
 
cie-as-maths-9709-statistics1-v2-znotes 2.pdf
cie-as-maths-9709-statistics1-v2-znotes 2.pdfcie-as-maths-9709-statistics1-v2-znotes 2.pdf
cie-as-maths-9709-statistics1-v2-znotes 2.pdf
 
W1-L1 Negative-numbers-ppt..pptx
W1-L1 Negative-numbers-ppt..pptxW1-L1 Negative-numbers-ppt..pptx
W1-L1 Negative-numbers-ppt..pptx
 
Day 7 distributive property
Day 7 distributive propertyDay 7 distributive property
Day 7 distributive property
 
Lec10-CS110 Computational Engineering
Lec10-CS110 Computational EngineeringLec10-CS110 Computational Engineering
Lec10-CS110 Computational Engineering
 
Sequences
SequencesSequences
Sequences
 
Interpolation and Extrapolation
Interpolation and ExtrapolationInterpolation and Extrapolation
Interpolation and Extrapolation
 
Game theory for neural networks
Game theory for neural networksGame theory for neural networks
Game theory for neural networks
 
3.2 insertion sort
3.2 insertion sort3.2 insertion sort
3.2 insertion sort
 

More from ArijitDhali

Signal Constellation, Geometric Interpretation of Signals
Signal Constellation,  Geometric Interpretation of  SignalsSignal Constellation,  Geometric Interpretation of  Signals
Signal Constellation, Geometric Interpretation of SignalsArijitDhali
 
Stack Queue SubRoutine
Stack Queue SubRoutineStack Queue SubRoutine
Stack Queue SubRoutineArijitDhali
 
Overviewing the techniques of Numerical Integration.pdf
Overviewing the techniques of Numerical Integration.pdfOverviewing the techniques of Numerical Integration.pdf
Overviewing the techniques of Numerical Integration.pdfArijitDhali
 
Motorola 68020.pdf
Motorola 68020.pdfMotorola 68020.pdf
Motorola 68020.pdfArijitDhali
 
Stereotactic Radiosurgery in Brain Metastases.pdf
Stereotactic Radiosurgery in Brain Metastases.pdfStereotactic Radiosurgery in Brain Metastases.pdf
Stereotactic Radiosurgery in Brain Metastases.pdfArijitDhali
 
Active Filters.pdf
Active Filters.pdfActive Filters.pdf
Active Filters.pdfArijitDhali
 
Wideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfWideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfArijitDhali
 
SSBSC Single Side Band - Suppressed Carrier Compressed
SSBSC Single Side Band - Suppressed Carrier CompressedSSBSC Single Side Band - Suppressed Carrier Compressed
SSBSC Single Side Band - Suppressed Carrier CompressedArijitDhali
 
Biodiversity Hotspots in India
Biodiversity Hotspots in IndiaBiodiversity Hotspots in India
Biodiversity Hotspots in IndiaArijitDhali
 
LTI Systems - With/Without Memory
LTI Systems - With/Without MemoryLTI Systems - With/Without Memory
LTI Systems - With/Without MemoryArijitDhali
 
RLC Series Resonance
RLC Series ResonanceRLC Series Resonance
RLC Series ResonanceArijitDhali
 
Bivariate Discrete Distribution
Bivariate Discrete DistributionBivariate Discrete Distribution
Bivariate Discrete DistributionArijitDhali
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's AlgorithmArijitDhali
 
Conditional Probability
Conditional ProbabilityConditional Probability
Conditional ProbabilityArijitDhali
 
Isomerism of Transition Metal Complex
Isomerism of Transition Metal ComplexIsomerism of Transition Metal Complex
Isomerism of Transition Metal ComplexArijitDhali
 
Space Solar Power
Space Solar PowerSpace Solar Power
Space Solar PowerArijitDhali
 
Types of function call
Types of function callTypes of function call
Types of function callArijitDhali
 
Power Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationPower Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationArijitDhali
 

More from ArijitDhali (20)

Signal Constellation, Geometric Interpretation of Signals
Signal Constellation,  Geometric Interpretation of  SignalsSignal Constellation,  Geometric Interpretation of  Signals
Signal Constellation, Geometric Interpretation of Signals
 
Stack Queue SubRoutine
Stack Queue SubRoutineStack Queue SubRoutine
Stack Queue SubRoutine
 
Overviewing the techniques of Numerical Integration.pdf
Overviewing the techniques of Numerical Integration.pdfOverviewing the techniques of Numerical Integration.pdf
Overviewing the techniques of Numerical Integration.pdf
 
Motorola 68020.pdf
Motorola 68020.pdfMotorola 68020.pdf
Motorola 68020.pdf
 
Stereotactic Radiosurgery in Brain Metastases.pdf
Stereotactic Radiosurgery in Brain Metastases.pdfStereotactic Radiosurgery in Brain Metastases.pdf
Stereotactic Radiosurgery in Brain Metastases.pdf
 
Active Filters.pdf
Active Filters.pdfActive Filters.pdf
Active Filters.pdf
 
Wideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdfWideband Frequency Modulation.pdf
Wideband Frequency Modulation.pdf
 
SSBSC Single Side Band - Suppressed Carrier Compressed
SSBSC Single Side Band - Suppressed Carrier CompressedSSBSC Single Side Band - Suppressed Carrier Compressed
SSBSC Single Side Band - Suppressed Carrier Compressed
 
Biodiversity Hotspots in India
Biodiversity Hotspots in IndiaBiodiversity Hotspots in India
Biodiversity Hotspots in India
 
LTI Systems - With/Without Memory
LTI Systems - With/Without MemoryLTI Systems - With/Without Memory
LTI Systems - With/Without Memory
 
RLC Series Resonance
RLC Series ResonanceRLC Series Resonance
RLC Series Resonance
 
Bivariate Discrete Distribution
Bivariate Discrete DistributionBivariate Discrete Distribution
Bivariate Discrete Distribution
 
Solar Cell
Solar CellSolar Cell
Solar Cell
 
Barcode Decoder
Barcode DecoderBarcode Decoder
Barcode Decoder
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
Conditional Probability
Conditional ProbabilityConditional Probability
Conditional Probability
 
Isomerism of Transition Metal Complex
Isomerism of Transition Metal ComplexIsomerism of Transition Metal Complex
Isomerism of Transition Metal Complex
 
Space Solar Power
Space Solar PowerSpace Solar Power
Space Solar Power
 
Types of function call
Types of function callTypes of function call
Types of function call
 
Power Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's EquationPower Series - Legendre Polynomial - Bessel's Equation
Power Series - Legendre Polynomial - Bessel's Equation
 

Recently uploaded

Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 

Recently uploaded (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 

The Celebrity Problem Graph

  • 1. THE CELEBRITY PROBLEM Presented By: Group 1 Ipsita Raha – Dibyendu Banik – Arnab Chatterjee – Arijit Dhali 11500120054 – 11500320062 – 11500320076 – 11500320078 SOLVING BY GRAPHICAL METHOD
  • 2. TABLE OF CONTENTS Disscussing Problem & Strategy 01 Graphical Approach 02 Pseudocode & Algorithm 03 Complexity Analysis & Result analysis 04 Program Code & Other Approaches 05 Conclusion & References 06
  • 3. CELEBRITY PROBLEM A celebrity among a group of n people is a person who knows nobody but is known by everybody else. The task is to identify a celebrity by only asking questions to people of the following form: “Do you know this person?
  • 4. STRATEGY 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 2 3 4 0 1 2 3 4 Person Let us understand the solution using two sample cases where we consider a matrix of person [ i , j ] (for person i knows j or not) Hence, 2 is the Celebrity here Case 1: 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 2 3 4 0 1 2 3 4 Person Case 2: Hence, there is no celebrity here From these examples, We can conclude the conditions : • Condition 1: Every other person knows the celebrity • Condition 2: Celebrity doesn’t knows no other person
  • 5. 01 GRAPHICAL APPROACH ● Model the solution using graphs ● Initialize indegree and outdegree of every vertex as 0. ● If A knows B, draw a directed edge from A to B, increase indegree of B and outdegree of A by 1. ● Construct all possible edges of the graph for every possible pair [ i , j ]. ● Now there are nC2 pairs. ● For atleast 1 celebrity present in the party, there will be one sink node in the graph with outdegree of zero and indegree of N-1
  • 6. PSEUDOCODE 1. Create two arrays indegree and outdegree, to store the indegree and outdegree 2. Run a nested loop, the outer loop from 0 to n and inner loop from 0 to n. 3. For every pair i, j check if i knows j then increase the outdegree of i and indegree of j 4. For every pair i, j check if j knows i then increase the outdegree of j and indegree of i 5. Run a loop from 0 to n and find the id where the indegree is n-1 and outdegree is 0
  • 7. ALGORITHM WITH TIME COMPLEXITY findCelebrity (n): indegree -> [0 for x from 0 to n] outdegree -> [0 for x from 0 to n] for i <- 0 to n -1 for j <- 0 to n -1 x = knows( i , j ) outdegree[ i ] + = x indegree[ j ] + = x for i <- 0 to n -1 if indegree[ i ] = n - 1 and outdegree[ i ] = 0 return i return -1 Cost Times C1 n C2 C3 C4 ෍ 𝑗=0 𝑛−1 𝑡𝑗 C5 C6 C7 C8 n C9 C10 C11 1
  • 8. CONTINUATION knows(a, b): return MATRIX[ a ][ b ] Main: id <- findCelebrity(n) if id = -1: No celebrity else Celebrity Present, print id Cost Times C12 1 Here, tj is the number of times the while loop is executed. Also, MATRIX = [ [ 0, 0, 1, 0 ], and N = 4 ( Person in party ) [ 0, 0, 1, 0 ], [ 0, 0, 0, 0 ], [ 0, 0, 1, 0 ] ] Cost Times C13 1 C14 1 C15 C16 1 C17
  • 9. COMPLEXITY ANALYSIS ● Time Complexity : O(n2) A nested loop is run traversing the array, SO the time complexity is O(n2) = (C1+C2+C3+C8+C9+C10 )(n) + (C4+C5+C6+C7)(n2) + C11 + C12 + C13 + C14 + C15 + C16 + C17 = O(n2) ● Space Complexity: O(n) Since extra space of size n is required.
  • 10. RESULT ANALYSIS 1 Let us consider the previous case 1, and create tables for indegree and outdegree 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 2 3 4 0 1 2 3 4 Person Indegree Outdegree 0 0 0 1 0 0 2 0 0 3 0 0 4 0 0 1 1 2 1 1 3 1 4 In this table we can see, person 2 has Indegree = 4 = (5 – 1) or (n – 1) Outdegree = 0 ∴ Person 2 is the celebrity
  • 11. RESULT ANALYSIS 2 Let us consider the previous case 2, and create tables for indegree and outdegree Indegree Outdegree 0 0 0 1 0 0 2 0 0 3 0 0 4 0 0 1 1 2 1 1 3 1 4 In this table we can see, person 2 has Indegree = 5 ≠ (5 – 1) or (n – 1) Outdegree = 1 ∴ Returns -1 which means no celebrity 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 1 2 3 4 0 1 2 3 4 Person 1 1
  • 14. CONCLUSION In this term paper we solved the given problem using graphical method. For graphs to be computationally useful, they have to be conveniently represented in programs. However it is simple to implement, easy and fast to tell if a pair ( i , j ) is an edge: simply check if A[ i ][ j ] is 1 or 0. No matter how few edges the graph has, the matrix takes O(n2) in memory
  • 16. CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, infographics & images by Freepik THANK YOU For your kind attention towards our presentation Group 1