Chapter 23 Computational Thinking and Problem-Solving Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an ADT?

A

Abstract Data Types are a collection of data with associated operations. Data organised according to a certain rule.

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

Types of ADTs (studied in the book)?

A
Stack
Queue
Circular queue
Linked list
Binary tree
Hash table
Dictionary
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which are the pointers in a stack?

A

Base of stack pointer

Top of stack pointer

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

Which item is accessable in a stack?

A

The top item

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

The main difference between the stack and queue when an item is removed?

A

In a stack the top of stack pointer is decreased.

In a queue we need to move all the items one slot forward.

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

Which are the pointers in a queue?

A

Front of queue pointer

End of queue pointer

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

What is a node in a linked list?

A

An element of the list

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

What can a node consist of?

A

Several data items and a pointer

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

What is a pointer in a list?

A

A variable that stores the address of the node

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

What is a null pointer and a start pointer in a list?

A

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.

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

What is the difference between linear and linked lists?

A
  1. Reordering:
    • linked lists, only the pointer needs to be changed
    • linear lists, all data needs to be moved
  2. Linked lists save time, on the other hand linked lists also take up more storage
  3. Linked lists can be stored in an array of records. One record consists of the data and a pointer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Best practice in a linked list regarding the unused nodes.

A

Unused nodes are usually linked into another linked list (the free list).

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

What is the pseudocode for initiating a linked list?

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

How are values entered in a binary tree?

A

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

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

What is the idea behind hash tables?

A

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

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

What does hashing mean?

A

Calculating an address from a key

17
Q

What does collision mean?

A

If two different key values hash to the same address this is called a ‘collision’

18
Q

How does Chaining work?

A

Create a linked list for collisions with start pointer at the hashed address

19
Q

How does Using overflow areas work?

A

All collisions are stored in a separate overflow area, known as ‘closed hashing’

20
Q

How does Using neighbouring slots do?

A

perform a linear search from the hashed address to find an empty slot, known as ‘open hashing’

21
Q

Which are the ways of handling collisions in a hash table?

A
Chaining 
Closed Hashing (uses overflow areas)
Open Hashing (uses the same list but adjacent slots)
22
Q

How are dictionaries setup?

A

Dictionaries are setup as Hash tables.