linear structures Flashcards

1
Q

what us an adt

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what are some linear structures

A
  • 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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what are some non linear structures

A

trees, search trees binary trees, binary search trees, balanced trees and heaps, graphs, important graph problems and algorithms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

how does a stack work ( like adding and taking off elements)

A

last in first out scheme ( like plates stacked)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what are the main stack operations

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the spaced used on a array based stack

A

O(N)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the run time of a array based stack

A

each operation is O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what are the limitations of a array based stack

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

stack implemented with a singly linked list running time is

A

constant time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how does a queue work ( like adding and taking off elements)

A

first in first out ( like lining up for food)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what are the main queue opperations

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is the run time of a array based queue

A

each operation runs at O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is the spaced used on a array based queue

A

O(N) //N is the size of the array

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

queue implemented with a singly linked list running time is

A

delete and add in constant time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what are the main deque opperations

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what is the run time of a array based deque

A

constant time O(1) even with doubly linked list

17
Q

what is the spaced used on a array based deque

A

O(N)

18
Q

what is a list

A

list is an ADT in a linear squenece of elements and support of operations for adding or removifn elements at arbatrary positions

19
Q

what are the main list opperations

A
  • get (i) // returns the elements of the list having index i.
  • set(i,e) - replaces the element at index i with e and returns the old element that was replaced
    add(i,e) - inserts a new element e into the list so that it has index i
    remove (i) removes and returns the element at index i
  • int size() // returns the number of elements
  • boolean isEmpty- is there elements
20
Q

what is the run time of a array based list

A

O(n)

21
Q

what is the run time of a array based list

A

O(1)