Graphs and Trees

¡Supera tus tareas y exámenes ahora con Quizwiz!

Tree definition

A connected, undirected, non-cyclical graph with a root node.

Graph definition

A set of nodes (vertices) that can be connected using edges

Binary tree definition

A tree in which a node has at most two child nodes

Graph uses

All tree uses Storing maps

Breadth First Search uses

Best for shortest path situations

Djikstra's Algorithm

Every node has a 'previous', 'visited' and 'distance' attribute This distance is set to infinity for all nodes except the starting node at 0 The current node is the unvisited node with the shortest 'distance' The unvisited nodes connected to the current node have their tentative distance compared with their 'distance' If it is smaller, their 'distance' is set to the tentative distance and their 'previous' is set to the current node This is done as long as there are unvisited nodes

Tree uses

Expression (e.g. arithmetic) Binary search tree (must be a binary tree) Decision tree (like a probability tree)

Graph features

Graphs may be: directed weighted cyclical connected

Depth First Search uses

Maze solving

Dijkstra's Algorithm uses

Minimising a factor when considering steps e.g. minimising distance or cost

Adjacency List Advantages

More memory efficient for sparser and larger graphs

Adjacency Matrix Advantages

O(1) access Memory efficient for many connections between nodes

Breadth First Search

Searches all nodes one further than the current 'border' nodes, with the border node being the start node on the first pass and repeat until the whole graph has been traversed

Depth First Search

Searches as far down a path as possible, backtracks to nearest branch, searches as far down that path as possible and repeats

Pre order, in order, post order traversal methods

trace around the outside of the tree, listing the values as you pass the appropriate side (left - pre, under - in, right - post)


Conjuntos de estudio relacionados

Chapter 13: Appraisal of Property/ Property Valuation

View Set

HIST 2010 MindTap Chapter 14 Test: From Compromise to Secession, 1850-1861

View Set

Intermediate Accounting - Chpt 15

View Set

Tx 30 Hr Law of Contracts Practice Exam

View Set

Chapter 2 - Information Systems and Strategy

View Set

Chapter 12: Family Violence and Abuse

View Set