SlideShare a Scribd company logo
1 of 2
Download to read offline
Need help with the FbUnfriend function. I am able to delete properly from the head of the list,
but i am struggling to figure out how to delete from the middle or the end.
In lectures, we learned that a graph is a collection of vertices and edges between them. This very
abstract definition allows for many real-world scenarios and systems to be modelled by graphs -
for example, maps, social networks, and the web. In this lab, we will explore an application of
graphs in a simple social network app called Friendbook Friendbook Friendbook is a very simple
social network app with the following features: - People can sign up with their name. For
simplicity, people are identified by their names, so two people cannot have the same name. -
People can friend other people (i,e., add them as friends). Friending goes both ways, so if you
add someone as a friend, you become their friend as well. - People can unfriend their friends (i.e,
remove them from their friends list). This also goes both ways. - People can see a count of how
many friends they have. - People can see a list of their friends. - People can see a list of the
mutual friends that they share with someone else. - People can receive friend recommendations.
Friendbook has two different methods of generating recommendations: 1. The first method only
recommends friends of friends, and ranks friend recommendations in order of the number of
mutual friends, so people who you share more mutual friends with will be recommended first. 2.
The second method recommends friends of friends first, and then friends of friends of friends
next, and then friends of friends of friends of friends, and so on. Anyone who can be reached by
following friendship links can be recommended.
Names as Vertices All of the graph implementations we have seen so far have used integer
vertices numbered from 0 to n1, where n is the number of vertices. This is convenient, as vertex
numbers can double as indices into the adjacency matrix or adjacency list. But in Friendbook, the
vertices are people (names), so how do we represent this internally? It tums out we don't need to
do that much more work. If we give each person an integer ID between 0 and n1 and store a
mapping between names and IDs, then we can continue to use the graph representations that we
are familiar with. A simple way to implement this mapping would be to store all the names in an
array, and let the ID of each person be the index containing their name in the array. The first
person in the array would have an ID of 0 , the second person in the array would have an ID of 1
, and so on. If we wanted to answer a question involving one or more people, we can scan this
array to determine their ID, and then use this ID to query the matrix/list. For example, suppose
this is our internal representation: Now suppose we wanted to find out if Harry and Draco are
friends. First, we need to find the vertex numbers associated with Harry and Draco, so we
perform a linear scan of the array of names (called labels), and find that Harry is associated with
a vertex number of 0 , and Draco is associated with a vertex number of 3 . The adjacency list for
vertex 0 does not. contain vertex 3 , so we can conclude that Harry and Draco are not friends.
Unfortunately, this translation between names and vertex numbers adds quite a bit of overhead to
our graph operations. Converting from vertex numbers to names is easy, as we can go straight to
the relevant index in the array (O(1)), but. converting from names to vertex numbers requires a
linear scan of the array, which is O(n). So what was once an O(1) operation (checking if an edge
exists) is now an O(n) operation. We can improve the efficiency of the name to vertex number
conversion by using a data structure that allows for efficient searching, such as a binary search
tree.
File Walkthrough runfb.c runfb. c provides a command-line interface to the Friendbook ADT. It
creates a Friendoook instance, and then accepts commands to interact with it. Here is an example
session with the program: $/runFb Friendbook v1. 0 Enter? to see the list of commands. ?
Connands: >+ Harry Harry was successfully added to Friendbook! >+Ron Ron was successfully
added to Friendbook! >+ Hermione Hernione was successfully added to Friendbook! > f Harry
Ron Successfully friended Harry and Ron! >f Ron Hermione Successfully friended Ron and
Hermione! > s Harry Ron Harry and Ron are friends. > u Harry Ron Could not unfriend Harry
and Ron - they are not friends. > s Harry Ron Harry and Ron are friends. > s Harry Hermione
Harry and Hermione are not friends. > it Harry Hermione Harry and Hermione's mutual friends:
> r Harry Harry's friend reconmendations R Harry q
Implement the Fbunfriend () function in Fb.c, which takes the names of two people, and
unfriends them if they are friends. The function should return true if the people were friends and
were successfully unfriended, and false if the two people were not friends (and so they could not
be unfriended). When you think you are done, use the make command to recompile the runfb
program and then run it to test your code.
}

More Related Content

Similar to Need help with the FbUnfriend function. I am able to delete properly.pdf

Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Philip Schwarz
 
Interactive visualization and exploration of network data with Gephi
Interactive visualization and exploration of network data with GephiInteractive visualization and exploration of network data with Gephi
Interactive visualization and exploration of network data with GephiDigital Methods Initiative
 
Graph Databases: Trends in the Web of Data
Graph Databases: Trends in the Web of DataGraph Databases: Trends in the Web of Data
Graph Databases: Trends in the Web of DataMarko Rodriguez
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 3
Folding Unfolded -Polyglot FP for Fun and Profit -Haskell and Scala - Part 3Folding Unfolded -Polyglot FP for Fun and Profit -Haskell and Scala - Part 3
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 3Philip Schwarz
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Bryan O'Sullivan
 

Similar to Need help with the FbUnfriend function. I am able to delete properly.pdf (7)

R Programming
R ProgrammingR Programming
R Programming
 
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
Function Applicative for Great Good of Palindrome Checker Function - Polyglot...
 
Interactive visualization and exploration of network data with Gephi
Interactive visualization and exploration of network data with GephiInteractive visualization and exploration of network data with Gephi
Interactive visualization and exploration of network data with Gephi
 
Graph Databases: Trends in the Web of Data
Graph Databases: Trends in the Web of DataGraph Databases: Trends in the Web of Data
Graph Databases: Trends in the Web of Data
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 3
Folding Unfolded -Polyglot FP for Fun and Profit -Haskell and Scala - Part 3Folding Unfolded -Polyglot FP for Fun and Profit -Haskell and Scala - Part 3
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 3
 
Real World Haskell: Lecture 2
Real World Haskell: Lecture 2Real World Haskell: Lecture 2
Real World Haskell: Lecture 2
 

More from aliracreations

One unit of A is made of three units of B, one unit of C, and two un.pdf
One unit of A is made of three units of B, one unit of C, and two un.pdfOne unit of A is made of three units of B, one unit of C, and two un.pdf
One unit of A is made of three units of B, one unit of C, and two un.pdfaliracreations
 
One of the methods that astronomer use to detect the presence of pla.pdf
One of the methods that astronomer use to detect the presence of pla.pdfOne of the methods that astronomer use to detect the presence of pla.pdf
One of the methods that astronomer use to detect the presence of pla.pdfaliracreations
 
One of the important uses of portfolio management tools isa. to .pdf
One of the important uses of portfolio management tools isa. to .pdfOne of the important uses of portfolio management tools isa. to .pdf
One of the important uses of portfolio management tools isa. to .pdfaliracreations
 
One common result of phospholipid signaling pathways downstream of G.pdf
One common result of phospholipid signaling pathways downstream of G.pdfOne common result of phospholipid signaling pathways downstream of G.pdf
One common result of phospholipid signaling pathways downstream of G.pdfaliracreations
 
Once you have completed your Exploratory research you have decided t.pdf
Once you have completed your Exploratory research you have decided t.pdfOnce you have completed your Exploratory research you have decided t.pdf
Once you have completed your Exploratory research you have decided t.pdfaliracreations
 
Once you have your list, respond to the followingList the current.pdf
Once you have your list, respond to the followingList the current.pdfOnce you have your list, respond to the followingList the current.pdf
Once you have your list, respond to the followingList the current.pdfaliracreations
 
One day, Alex got tired of climbing in a gym and decided to take a v.pdf
One day, Alex got tired of climbing in a gym and decided to take a v.pdfOne day, Alex got tired of climbing in a gym and decided to take a v.pdf
One day, Alex got tired of climbing in a gym and decided to take a v.pdfaliracreations
 
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdfOn November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdfaliracreations
 
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdfOn January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdfaliracreations
 
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdfOn January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdfaliracreations
 
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdfOn December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdfaliracreations
 
No plagiarism. At least 250 wordsWhat is the relationship be.pdf
No plagiarism. At least 250 wordsWhat is the relationship be.pdfNo plagiarism. At least 250 wordsWhat is the relationship be.pdf
No plagiarism. At least 250 wordsWhat is the relationship be.pdfaliracreations
 
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdfOn August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdfaliracreations
 
On April 1, Mathis purchased merchandise on account from Reece with .pdf
On April 1, Mathis purchased merchandise on account from Reece with .pdfOn April 1, Mathis purchased merchandise on account from Reece with .pdf
On April 1, Mathis purchased merchandise on account from Reece with .pdfaliracreations
 
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdfOn 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdfaliracreations
 
New York State, county, city, school district, and other government .pdf
New York State, county, city, school district, and other government .pdfNew York State, county, city, school district, and other government .pdf
New York State, county, city, school district, and other government .pdfaliracreations
 
Objective The purpose of this exercise is to create a Linked List d.pdf
Objective The purpose of this exercise is to create a Linked List d.pdfObjective The purpose of this exercise is to create a Linked List d.pdf
Objective The purpose of this exercise is to create a Linked List d.pdfaliracreations
 
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdfnsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdfaliracreations
 
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdfnsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdfaliracreations
 
Nurse is performing a vaginal exan on a patient who is in labor .pdf
Nurse is performing a vaginal exan on a patient who is in labor .pdfNurse is performing a vaginal exan on a patient who is in labor .pdf
Nurse is performing a vaginal exan on a patient who is in labor .pdfaliracreations
 

More from aliracreations (20)

One unit of A is made of three units of B, one unit of C, and two un.pdf
One unit of A is made of three units of B, one unit of C, and two un.pdfOne unit of A is made of three units of B, one unit of C, and two un.pdf
One unit of A is made of three units of B, one unit of C, and two un.pdf
 
One of the methods that astronomer use to detect the presence of pla.pdf
One of the methods that astronomer use to detect the presence of pla.pdfOne of the methods that astronomer use to detect the presence of pla.pdf
One of the methods that astronomer use to detect the presence of pla.pdf
 
One of the important uses of portfolio management tools isa. to .pdf
One of the important uses of portfolio management tools isa. to .pdfOne of the important uses of portfolio management tools isa. to .pdf
One of the important uses of portfolio management tools isa. to .pdf
 
One common result of phospholipid signaling pathways downstream of G.pdf
One common result of phospholipid signaling pathways downstream of G.pdfOne common result of phospholipid signaling pathways downstream of G.pdf
One common result of phospholipid signaling pathways downstream of G.pdf
 
Once you have completed your Exploratory research you have decided t.pdf
Once you have completed your Exploratory research you have decided t.pdfOnce you have completed your Exploratory research you have decided t.pdf
Once you have completed your Exploratory research you have decided t.pdf
 
Once you have your list, respond to the followingList the current.pdf
Once you have your list, respond to the followingList the current.pdfOnce you have your list, respond to the followingList the current.pdf
Once you have your list, respond to the followingList the current.pdf
 
One day, Alex got tired of climbing in a gym and decided to take a v.pdf
One day, Alex got tired of climbing in a gym and decided to take a v.pdfOne day, Alex got tired of climbing in a gym and decided to take a v.pdf
One day, Alex got tired of climbing in a gym and decided to take a v.pdf
 
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdfOn November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
On November 1, 2021 a company sign a $200,000.12 percent six-month n.pdf
 
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdfOn January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
On January 1, Year 2, Kincaid Companys Accounts Receivable and the .pdf
 
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdfOn January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
On January 1, 2021, Daniel Corp. acquired 80 of the voting common s.pdf
 
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdfOn December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
On December 31, Year 3, Mueller Corp. acquired 80 of the outstandin.pdf
 
No plagiarism. At least 250 wordsWhat is the relationship be.pdf
No plagiarism. At least 250 wordsWhat is the relationship be.pdfNo plagiarism. At least 250 wordsWhat is the relationship be.pdf
No plagiarism. At least 250 wordsWhat is the relationship be.pdf
 
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdfOn August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
On August 1, 2024, Trico Technologies, an aeronautic electronics com.pdf
 
On April 1, Mathis purchased merchandise on account from Reece with .pdf
On April 1, Mathis purchased merchandise on account from Reece with .pdfOn April 1, Mathis purchased merchandise on account from Reece with .pdf
On April 1, Mathis purchased merchandise on account from Reece with .pdf
 
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdfOn 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
On 1 January 2021, Alpha Ltd sold inventory to Beta Ltd for $90 000..pdf
 
New York State, county, city, school district, and other government .pdf
New York State, county, city, school district, and other government .pdfNew York State, county, city, school district, and other government .pdf
New York State, county, city, school district, and other government .pdf
 
Objective The purpose of this exercise is to create a Linked List d.pdf
Objective The purpose of this exercise is to create a Linked List d.pdfObjective The purpose of this exercise is to create a Linked List d.pdf
Objective The purpose of this exercise is to create a Linked List d.pdf
 
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdfnsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
nsan davranlar �almasnda, �rg�tsel liderler insanlarn deerleri, tutu.pdf
 
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdfnsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
nsan adaptasyonu genetik, geliimsel, iklimlendirme ve k�lt�rel olmak.pdf
 
Nurse is performing a vaginal exan on a patient who is in labor .pdf
Nurse is performing a vaginal exan on a patient who is in labor .pdfNurse is performing a vaginal exan on a patient who is in labor .pdf
Nurse is performing a vaginal exan on a patient who is in labor .pdf
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 

Need help with the FbUnfriend function. I am able to delete properly.pdf

  • 1. Need help with the FbUnfriend function. I am able to delete properly from the head of the list, but i am struggling to figure out how to delete from the middle or the end. In lectures, we learned that a graph is a collection of vertices and edges between them. This very abstract definition allows for many real-world scenarios and systems to be modelled by graphs - for example, maps, social networks, and the web. In this lab, we will explore an application of graphs in a simple social network app called Friendbook Friendbook Friendbook is a very simple social network app with the following features: - People can sign up with their name. For simplicity, people are identified by their names, so two people cannot have the same name. - People can friend other people (i,e., add them as friends). Friending goes both ways, so if you add someone as a friend, you become their friend as well. - People can unfriend their friends (i.e, remove them from their friends list). This also goes both ways. - People can see a count of how many friends they have. - People can see a list of their friends. - People can see a list of the mutual friends that they share with someone else. - People can receive friend recommendations. Friendbook has two different methods of generating recommendations: 1. The first method only recommends friends of friends, and ranks friend recommendations in order of the number of mutual friends, so people who you share more mutual friends with will be recommended first. 2. The second method recommends friends of friends first, and then friends of friends of friends next, and then friends of friends of friends of friends, and so on. Anyone who can be reached by following friendship links can be recommended. Names as Vertices All of the graph implementations we have seen so far have used integer vertices numbered from 0 to n1, where n is the number of vertices. This is convenient, as vertex numbers can double as indices into the adjacency matrix or adjacency list. But in Friendbook, the vertices are people (names), so how do we represent this internally? It tums out we don't need to do that much more work. If we give each person an integer ID between 0 and n1 and store a mapping between names and IDs, then we can continue to use the graph representations that we are familiar with. A simple way to implement this mapping would be to store all the names in an array, and let the ID of each person be the index containing their name in the array. The first person in the array would have an ID of 0 , the second person in the array would have an ID of 1 , and so on. If we wanted to answer a question involving one or more people, we can scan this array to determine their ID, and then use this ID to query the matrix/list. For example, suppose this is our internal representation: Now suppose we wanted to find out if Harry and Draco are friends. First, we need to find the vertex numbers associated with Harry and Draco, so we perform a linear scan of the array of names (called labels), and find that Harry is associated with a vertex number of 0 , and Draco is associated with a vertex number of 3 . The adjacency list for
  • 2. vertex 0 does not. contain vertex 3 , so we can conclude that Harry and Draco are not friends. Unfortunately, this translation between names and vertex numbers adds quite a bit of overhead to our graph operations. Converting from vertex numbers to names is easy, as we can go straight to the relevant index in the array (O(1)), but. converting from names to vertex numbers requires a linear scan of the array, which is O(n). So what was once an O(1) operation (checking if an edge exists) is now an O(n) operation. We can improve the efficiency of the name to vertex number conversion by using a data structure that allows for efficient searching, such as a binary search tree. File Walkthrough runfb.c runfb. c provides a command-line interface to the Friendbook ADT. It creates a Friendoook instance, and then accepts commands to interact with it. Here is an example session with the program: $/runFb Friendbook v1. 0 Enter? to see the list of commands. ? Connands: >+ Harry Harry was successfully added to Friendbook! >+Ron Ron was successfully added to Friendbook! >+ Hermione Hernione was successfully added to Friendbook! > f Harry Ron Successfully friended Harry and Ron! >f Ron Hermione Successfully friended Ron and Hermione! > s Harry Ron Harry and Ron are friends. > u Harry Ron Could not unfriend Harry and Ron - they are not friends. > s Harry Ron Harry and Ron are friends. > s Harry Hermione Harry and Hermione are not friends. > it Harry Hermione Harry and Hermione's mutual friends: > r Harry Harry's friend reconmendations R Harry q Implement the Fbunfriend () function in Fb.c, which takes the names of two people, and unfriends them if they are friends. The function should return true if the people were friends and were successfully unfriended, and false if the two people were not friends (and so they could not be unfriended). When you think you are done, use the make command to recompile the runfb program and then run it to test your code. }