linear structures Flashcards
what us an adt
is an abstract data type (ADT) is a mathematical model of a data structure that specifies
- the type of data stored
- the operations supported on them and the types of parameters of the operations
- realized by a concrete data structure
what are some linear structures
- stack, queues, lists, and their variants such as double ended queues, priority queues
- maps and sets, there variants, and hash tables ( a data structure to implement them)
what are some non linear structures
trees, search trees binary trees, binary search trees, balanced trees and heaps, graphs, important graph problems and algorithms
how does a stack work ( like adding and taking off elements)
last in first out scheme ( like plates stacked)
what are the main stack operations
- push(object)
- object pop() // removes and returns the last inserted element
- object top() returns the last inserted element( do not remove it tho)
- int size() // returns the number of elements
- boolean isEmpty- is there elements
what is the spaced used on a array based stack
O(N)
what is the run time of a array based stack
each operation is O(1)
what are the limitations of a array based stack
- the maximum size of the stack must be defined and cannot be changed
- trying to push a new element into a full stack caused an error
stack implemented with a singly linked list running time is
constant time
how does a queue work ( like adding and taking off elements)
first in first out ( like lining up for food)
what are the main queue opperations
- enqueue(object)
- object dequeue() // removes and returns the last inserted element
- object first() returns the last inserted element( do not remove it tho)
- int size() // returns the number of elements
- boolean isEmpty- is there elements
what is the run time of a array based queue
each operation runs at O(1)
what is the spaced used on a array based queue
O(N) //N is the size of the array
queue implemented with a singly linked list running time is
delete and add in constant time
what are the main deque opperations
- addFirst(object) // adds to front of list
- addLast(object) // adds to end of list
- object removeFirst() // removes and returns the first inserted element
- object removeLast() // removes and returns the last element
- object first() returns the first element( do not remove it tho)
- object last() returns the last element( do not remove it tho)
- int size() // returns the number of elements
- boolean isEmpty- is there elements