Explain the similarities and differences between a record and a class
Record is a datastructure
A class is a template for makingdatastructures
Class also has methods which describes functionality
Bothstoredata of differenttypes
Bothcanhavemultipleinstances
Class can include visibility of properties / private
Define the term 'queue'
A data structure
FIFO (first in first out)
Explain how a private attribute improves the integrity of the data
Properties are encapsulated and canonly be accessedthrough their methods
Cannot be changed/accessed accidentally
What does it mean for a list to be dynamic?
items can be added and deleted, inserted at any place
Difference between breadth first and depth first
Depth-first goes to left child nodealways, if there is noleft child it goes to the right child. When there are no child nodes the algorithm ‘visits’ it’ and backtracks to the parentnode.
Breadth-firstvisitsallnodesconnecteddirectlytostartnode Then visits all nodes directly connected to each of those nodes and so on
Depth-first uses a stack
Breadth-first uses a queue
Difference in storage structure between breadth and depth first traversal?
Queue for breadth-first traversal, stack for depth-first traversal
Similarities graph and tree
Both consists of nodes
Both are connected by edges
Both are non-linear data structures
Both are dynamic data structures
Explain how a data item is removed from a linked list
Traverse the list to the itemimmediatelyprior to the item to be removed
Find the value of the nextpointerof the item to be removed
Set the nextpointer of the itempriorto the item to beremovedto the nextpointervalue
Update the next pointer
Explain how backtracking is used in depth-first
Depth first starts at the root and goes all the way downonebranch to the bottom
It stores which nodes it has visited onto a stack
When it cannotgoanyfurther it backtracks to the previousnode and continues to backtrackuntil a node is reached with unvisitedchildren and checks down that branch
Explain how 1D array can be set up and used to push and pop items as a stack
Array size defined
A stack pointer is used to point to the top of the stack
When an item is pushed the stack pointer is incremented
When an item is popped the stack pointer is decremented
Describe how an array can be used to implement a queue data structure
Queue has headpointer and tailpointer
When an item is enqueued the tailpointerincrements
When an item is dequeued the headpointerincrements