more paper 1 stuff Flashcards

1
Q

How does a hash function contribute to the performance of a hash table

A

A hash function maps keys to indices in the hash table, ensuring even distribution of elements and efficient retrieval

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

Explain how a priority queue can be implemented using an array

A

A priority queue can be implemented using arrays where elements are sorted based on their priority levels, allowing efficient insertion and removal

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

Discuss the impact of hash collisions on the performance of a hash table

A

Hash collisions can degrade performance by increasing lookup time and necessitating collision resolution techniques like chaining or open addressing

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

Explain how dynamic arrays handle resizing when they run out of space.

A

Dynamic arrays resize by allocating a larger block of memory, copying existing elements, and deallocating the old memory block, ensuring efficient resizing.

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

Discuss the advantages and disadvantages of using a dictionary for key-value storage

A

ADV:
- Fast Lookup Time: Dictionaries offer constant-time (O(1)) average-case lookup time for retrieving values based on their keys.
- Flexible Key Types: Dictionaries allow keys to be of various types, including strings, integers, tuples
- Dynamic Resizing: Many dictionary implementations automatically resize themselves as more elements are added,

DISADV:
- Memory Overhead: Dictionaries can consume more memory compared to other data structures
- Hash collisions
-

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

What is representational abstraction?

A

Removing (unnecessary) details;

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

What is abstraction by generalisation?

A

Grouping by common characteristics /

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

Explain what is meant by procedural decomposition

A

Breaking a problem into smaller sub-problems;
- Each of which solves an identifiable task;
Each of which might be further subdivided;

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

explain how a single stack can be used to reverse the order of the items in a queue

A

repeatedly remove the front item from the queue and push it into the stack
repeatedly pop items from the stack and add them to the rear of the queue

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

state two characteristics that make a tree a binary tree

A
  • has a root node
  • each node has a maximum of 2 children
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

advantages of using subroutines

A

Easier to test/debug as each subroutine can be tested separately;

Easier to understand the code if sensible identifiers are used for subroutine names;

Code can be easily reused as each subroutine is independent of rest of program;

Makes it easier to work as a team of programmers as each subroutine can be worked on independently;

Can be used as often as needed without having to write the code each time;

Makes program easier to maintain/update (in future) as fewer changes will need to
be made to make an update;

Allows the use of recursive techniques because subroutines can call themselves;
Easier to understand the code as each subroutine can be considered in isolation;

Less likely to be errors in the code due to reuse of code;
Reduces/eliminates side effects (eg unexpected change to value in global variable)
through use of local variables;

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

what is the cardinality of a set

A
  • refers to the number of elements in a set. - Cardinality is usually expressed using double vertical bars:|A| is the number of elements of A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Explain why, when implemented using a fixed-length array, a circular queue is usually considered to be a better choice of data structure than a linear queue.

A

When an item is removed from a linear queue, all other items need to be shuffled up one, and this can result in unusable space in the array

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

Describe the steps that must be completed to remove (dequeue) an item from a circular queue that has been implemented using a fixed-length array

A
  1. Check that the queue is not already empty
    R. reference to array instead of queue
  2. if it is then deal with (underflow) error // (If it is not then) process/dequeue the
    front item in the queue;3. Reduce the value of the variable used to store the current size by 1;
  3. Check if the front is in the last position of the array and if it is set it to the first
    position in the array
  4. (Else) add 1 to the value of the front pointer;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is the dot product rule

A

A⋅B=AxBx+AyBy

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

advantages of dynamic structures

A

No wasted memory;
Can grow as more data is added to the data structure // no limit on number of
items that can be added (except due to hardware limitations);
Resources only allocated as they are needed (with static data structures they are
allocated at creation even if not needed until later);

17
Q

advantages of static structures

A

predictable memory allocation, faster access times, and simpler implementation

18
Q

properties of a graph that make it a tree

A

unweighted and undirected