Chapter 23 Computational Thinking and Problem-Solving Flashcards
What is an ADT?
Abstract Data Types are a collection of data with associated operations. Data organised according to a certain rule.
Types of ADTs (studied in the book)?
Stack Queue Circular queue Linked list Binary tree Hash table Dictionary
Which are the pointers in a stack?
Base of stack pointer
Top of stack pointer
Which item is accessable in a stack?
The top item
The main difference between the stack and queue when an item is removed?
In a stack the top of stack pointer is decreased.
In a queue we need to move all the items one slot forward.
Which are the pointers in a queue?
Front of queue pointer
End of queue pointer
What is a node in a linked list?
An element of the list
What can a node consist of?
Several data items and a pointer
What is a pointer in a list?
A variable that stores the address of the node
What is a null pointer and a start pointer in a list?
A null pointer is a pointer that doesn’t point to any node and it is represented by ‘Ø’ symbol.
A start pointer is a pointer that points to the first node in the list.
What is the difference between linear and linked lists?
- Reordering:
- linked lists, only the pointer needs to be changed
- linear lists, all data needs to be moved
- Linked lists save time, on the other hand linked lists also take up more storage
- Linked lists can be stored in an array of records. One record consists of the data and a pointer
Best practice in a linked list regarding the unused nodes.
Unused nodes are usually linked into another linked list (the free list).
What is the pseudocode for initiating a linked list?
Declare the type, the declare an array or list of the new type. For example: TYPE ListNode DECLARE Data : STRING DECLARE Pointer : INTEGER ENDTYPE
DECLARE List[1 : 7] OF ListNode
How are values entered in a binary tree?
If the value that needs to be under a node is greater than the upper node it goes to the right
If the value that needs to be under a node is smaller than the upper node it goes to the left
What is the idea behind hash tables?
The idea behind hash tables is to calculate and address (the array index) from the key value of the record and store the record at that address