Data Structures (unit 7) (Finished) Flashcards
(7.1)What is an array?
An array is a set number of elements of the same type. (A list can have different data types in it)
(7.1)What is a 2d array?
a grid (or table) with rows and columns version of an array
(7.2) What is a queue?
A queue is a first in first out data structure, where elements can only be added to the end of the queue
(7.2)What are the 4 operations that can be performed on a queue?
Add item to the rear of the queue (enQueue(item))
Remove item from the front of the queue (deQueue())
Check if the queue is empty (isEmpty())
Check if the queue is full (isFull())
(7.2) What are pointers and how do they work?
Pointers are used to identify which is the next value in a queue that should be visited
(7.2) What is the difference between a circular queue and a normal queue
in a circular queue, the front and rear depend on which one was put in last or first entirely, not the place value it holds. an example of this is that the value in [0] could be the rear, while the value in [4] could be the front
(7.2)write functions to check if a queue is empty, or a queue is full
function isEmpty if size == 0: return True else return False
function isFull if size == maxSize: return True else: return False
(7.2)Write a function to enqueue an item
function enqueue(newItem): if size == maxSize: print ("Queue full") else: rear = (rear + 1): queue[rear] = newItem size = size + 1
(7.2)Write a function to enqueue an item
function enqueue(newItem): if size == maxSize: print ("Queue full") else: rear = (rear + 1): queue[rear] = newItem size = size + 1
(7.2)Write a function to dequeue an item
function dequeue(): if size == 0: print ("Queue empty") else: front = (front + 1): size = size - 1
(7.2)What is a priority queue?
a priority queue allows some elements of the list to skip forward depending on the attributes they hold
(7.2) What are the differences between a dynamic and static data structure?
Static data structures are fixed in size:
cannot grow, shrink, or be freed up during execution,
an array is a static data structure
Dynamic data structures can grow and shrink:
allocates and deallocates memory from the heap (an area of memory especially used for this purpose)
excessive allocation of memory, without deallocation, may cause overflow (exceeding maximum memory limit)
(7.3) what is abstraction?
abstraction is the process of filtering out the unneeded parts to concentrate on what is needed
(7.3)What are some examples of Abstract Data Types? (adt)
Queues
Lists
(7.3)What is an abstract data type?
A data type that isnt built into the programming language but is still used
(7.3) What are some examples of languages with dynamic list support?
Python
Java
vb.net
delphi
(7.3) what is a linked list?
a linked list is a dynamic data structure which is implemented as a normal list/array (with pointers)
(7.3) What are some applications of lists?
List of students in a class and their marks,
Component parts of a product,
Songs in a music library,
Friends on a social media platform, etc.
(7.3) How are nodes deleted in linked lists?
Node is deleted, pointers are adjusted to skip the value that the deleted node once occupied
(7.4) What is a stack?
LIFO (last in first out) data structure
(7.4) What are some examples of stacks being used?
Towers of Hanoi game
websites visited (so that you can go back to the previous page)
Contents of the CPU
(7.4) What functions can be used in a stack?
Push
Pop
Check size of the stack
peek (check the size of the stack if empty/full)
(7.4) What operations can be performed on a stack?
Push(item)
pop()
isfull()
isempty()
(7.4) How can a list be reversed using a stack?
put the list into a stack, then take it out, will come out reversed as stacks are FILO
(7.4) What is the main disadvantage of a stack?
the main disadvantage of a stack is that the first job may never get popped/done
(7.4) What is overflow?
attempting to push onto a stack that is full
(7.4) What is underflow?
attempting to pop from a stack that is empty