Unformatted text preview:

Data Types and Data StructuresData Structures - AtomicData Structures - ArrayData Structures - Linked ListData Structures - StackData Structures - QueueData Structures - Stacks & QueuesData Structures - GraphData Structures - TreeData Structures - HeapSlide 11Slide 12Graph ProblemsGraph Problems - Traveling SalesmanGraph Problems - Graph ColoringGraph Problems - Maximum FlowCost of Graph ProblemsCost of Typical ProblemsArtificial IntelligenceArtificial Intelligence ChallengesProposed AI SystemsSlide 22Data Types and Data Structures•When specifying data in a program we need to describe its type and its structure.•Data's type impose meaning onto data (semantics) and data's structure impose organization (syntax)onto data.•Data Type (definition): A label applied to data that tells the computer how to interpret and manipulate data.–Type tells the computer how much space to reserve for variables and how to interpret operations on them. •Data Structure (definition): The way data is organized logically.–Describes how different pieces of data are organized.Data Structures - AtomicName AtomicDefinition A data structure containing a single value, or data item, of any type.Std Functions Assign – places a value in the atomic structure.Retrieve – returns the value currently stored in the structure.Non-Std FunctionsNoneNotesThis is the most basic data structure, from which all others are built. Contains only one data itemCan be placed anywhere in memory.Data Structures - ArrayName ArrayDefinition A group of data elements stored in contiguous memory.Std Functions Assign(n) – store a value in the nth element.Retrieve(n) – retrieves the value stored in the nth element.Non-Std FunctionsLength – returns number of elements in the array. Sort – sorts the elements of the array.Matrix operations, like determinant, transpose, etc.NotesTypically, all elements of an array are of the same type.Typically, each element in an array can be of any type.Advantage: Instant access to any element in the array (ie it is just as easy to retrieve the value of the first element as any other).Disadvantages: Hard to change the size of the array. Hard to insert new elements in the middle of the array.Data Structures - Linked ListName Linked ListDefinition A group of data elements composed of two parts: a value part and a link part. The link points to the next data element in the list.Std Functions Insert(value) – inserts a new element into the list.Remove(value) – removes an element from the list.Non-Std FunctionsNoneNotesThe variable representing the linked list points to the head of the list.The last element in the list has a value of “NULL” for its link.Advantages: The linked list can change size easily.Elements can be inserted and deleted easily into linked lists.Disadvantage: You do not have quick access to members 1 23 4Data Structures - StackName StackDefinition A structure in which only the top element is visible.Std Functions Push(value) – pushes the value on the top of the stack.Pop() – Removes the top value in a stack.Peek() – Returns the value of the top element on the stack.Non-Std FunctionsPush(value1, value2, value3..) - pushes multiple values on the stack.Pop(n) – Pops n elements off the stack.Peek(n) - Returns the value of the nth element.NotesCan be though of as a stack of plates or trays. Exhibits LIFO (Last in First Out) behavior.Useful in task scheduling in which one task must be completed before others can begin.Data Structures - QueueName QueueDefinition A list of elements in which elements are added to one end and removed from the other. Std Functions Enqueue(value) – adds the value to one end of the queue.Dequeue() – removes a value from the queue.Non-Std FunctionsNoneNotesCan be thought of as a line of customers, such as at the bank or grocers.Exhibits FIFO (First in First Out) behavior.Useful in task scheduling in which FIFO is important (Example: printer queues)Data Structures - Stacks & QueuesENTEREXITENTER EXITSTACKQUEUENOTE: STACKS AND QUEUES ARE TYPICALLY DEPICTED LIKE ARRAYS BUT THE INDIVIDUAL ELEMENTS CAN RESIDE ANYWHERE IN MEMORY.Data Structures - GraphName GraphDefinition A set of nodes (data elements) connected by edges in an arbitrary manner.Std Functions NoneNon-Std FunctionsNoneNotesThe most versatile data structure (linked lists, trees and heaps are special instances of graphs).Standard Problems:Graph Coloring: Coloring the nodes of a graph such that adjacent nodes do not have the same color.Traveling Salesman: Visiting each node in the graph exactly once for the least cost (start and stop at the same node).Maximum Flow: Determine the amount of flow through a network.Data Structures - TreeName TreeDefinition A graph with directed edges connecting parent to child such that there is exactly one node with no parents and all other nodes have exactly one parent.Std Functions NoneNon-Std FunctionsNoneNotesThe first element in the tree is the “root” node, which has no parents, and from which all others can be reached.Nodes with no children are "leaf" nodes.If nodes “a” and “b” are connected by an edge, then: “a” is a child of “b” if “b” is closer to the root than “a”. “a” is a parent of “b” if “a” is closer to the root than “b”Useful in making decisions and categorizing data.Data Structures - HeapName HeapDefinition A tree in which a parent node has a value larger than all its children.Std Functions Heap(a, H) – Add new node a to heap H.Unheap(H) – Remove the root element from heap H and re-establish the heap.Non-Std FunctionsNoneNotesFlexible data structure useful for sorting elements “as they arrive.” This allows sorting on lists whoses size change constantly.Used in “priority queues” or other situations where maintaining and accessing a maximum element is important.Data Structures - GraphTHESE ARE ALL GRAPHS.Data Structures - GraphTHESE ARE TREES (ABOVE). ARE THEY HEAPS?THESE ARE NOT TREES (ABOVE). ARE THEY HEAPS?Graph Problems•There are literally thousands of graph problems, but we will focus on three that are occur very commonly and show the diversity of the graph structure:–The Traveling Salesman Problem.–Graph Coloring Problem.–Maximum Flow Problem.•Each problem has a decision form and an optimization form. The decision form asks "Can we do it?" and the optimization form asks "How well can we do it?"•At least one of these problems is solved by you every


View Full Document

UCF COP 2500C - Data Types and Data Structures

Download Data Types and Data Structures
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Data Types and Data Structures and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Data Types and Data Structures 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?