Topic: [Revision] Data Structures and Algorithms
ALGORITHM 5
DATA STRUCTURES AND ALGORITHM
Student’s Name
Course
Professor’s Name
University
City (State)
Date
Sequential Data Structures and Algorithm
A graph is a non-linear data structure which models and represents a variety of system. Also, a graph is a collection of objects or entities called vertices and nodes where edges possibly connect nodes. Thus, in mathematics, a graph (G) is an ordered pair of a set (V) of vertices and a set E of edges G= (V, E) (Goodrich et al., 2014). In the undirected graph, the set of vertices has to come first, followed by the set of edges. In this undirected graph, there are eight vertices and ten edges. The eight vertices City=(City A, City B, City C, City D, City E, City F, City E, and City H). Its two endpoints uniquely identify an edge. In this graph, the edges are undirected to have a two-way connection. For instance, between city F and City H, there is a path from both sides. Edges= {(City H, City), (City F, City E), (City E, City A), (City A, City B), (City B, City C), (City C, City G), (City G, City D), (City D, City H), (City D, City F), (City D, City E)}.
In this case, the connection of the city is the undirected graph based on the fact that the roads can link the cities in two mutual ways. Since a person can travel from one place to another. The undirected graph, therefore, is implemented as an adjacency matrix.
Justification of Choice
From this undirected graph, a city is a node in the graph. Thus, if two cities can be linked together, there shall be an edge connecting them. In a country, there can be so many nodes to cities. Cities can be visited to and fro, meaning they can be accessed in two ways. For instance, City E is linked to City F, City A, and City D through an edge. If there was need to suggest cities connection to City E. One way to do so, if cities are suggested to the cities linked to City E. For instance, City F is edged with City H, and City D is edged with City G and City H, and City A is linked to City B. Therefore, cities such as H, G, and B can be suggested to City E. Thus, it can help in determining the shortest (Mehlhorn, 2013).
In determining all nodes that give the shortest path from city E that is equal to 2, insertion, deleting, merging, and sorting can be applied. In this context, if it was suggested that City H, G, B can be edged to City E. Thus, if H was to be connected to E, then the edge of City F can be deleted and connect E directly to H, which often leads to various interruption. Also, If E was to be connected to City B, the path of City B can be merged with the edge of City A. Insertion means that city G an edge can be inserted to link it to City E (Goodrich et al., 2014). However, the edges can be rearranged and sorted. For instance, if there is a need to connect City E and G, the graph can be sorted to connect City G to City E. The operation sort occurs in linear order such that for any edge (G, D) in E, G precedes D in the ordering.
Reference List
Mehlhorn, K., 2013. Data structures and algorithms 1: Sorting and searching (Vol. 1). Springer Science & Business Media.
Goodrich, M.T., Tamassia, R. and Goldwasser, M.H., 2014. Data structures and algorithms in Java. John Wiley & Sons.