flashcards_simple_data_structures

1
Q

What are data structures?

A

Sets of associations or relationships (structure) involving combined elements.

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

What does the stackTop operation do in a stack ADT?

A

It returns the topmost element.

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

When is a stack considered empty?

A

When the isEmpty() method returns true.

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

What does the POP operation do?

A

It removes the element currently at the top.

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

What does the PUSH operation do?

A

It inserts an element on top of the most recently inserted data.

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

What happens when PUSH is called on a full stack?

A

Stack overflow occurs.

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

What is data encapsulation?

A

Packaging together data values with the operations on those values.

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

When is the water tank considered empty?

A

When the water level is zero, and isEmpty() returns true.

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

What kind of operation is addWater() in a water tank ADT?

A

It is a transformer.

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

What is the purpose of the ~waterTank() operation?

A

It serves as a destructor.

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

What happens when PUSH is called on a non-empty, non-full stack?

A

The new item is inserted and becomes the last element.

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

What happens after a POP operation?

A

The next oldest item becomes the topmost item.

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

What aspect does ADT emphasize?

A

The ‘what’ rather than the ‘how’.

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

What technique does a stack follow?

A

Last-In, First-Out (LIFO).

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

What happens if POP is called on a full stack?

A

The topmost element is deleted.

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

What happens if POP is called on an empty stack?

A

Stack underflow occurs.

17
Q

What are the operations involved in an ADT?

A

Creators, transformers, observers, and input/output.

18
Q

Which data structures are hierarchical?

A

General trees and binary trees.

19
Q

What is a general tree?

A

A tree with at least three child nodes.

20
Q

What type of relationship do hierarchical data structures have?

A

One-to-many.

21
Q

Which data structures are linear, and which are hierarchical?

A

Stacks and queues are linear; trees are hierarchical.

22
Q

What type of elements does an array contain?

A

Elements of the same type only.

23
Q

How do you declare a one-dimensional array in Java?

A

int arr[] = new int[3];

24
Q

How do you declare a multidimensional array in Java?

A

int[][] arr; or int arr[][];

25
How are elements in an array accessed compared to linked lists?
Arrays allow random access; linked lists require sequential access.
26
Which sort is faster for small arrays, insertion or quick sort?
Insertion sort is faster for small arrays.
27
What is an advantage of selection sort?
It is an in-place sorting algorithm, needing no extra storage.
28
How does merge sort work?
It divides the array, sorts each half, and then merges them.
29
How is bottom-up merge sort implemented?
Using an iterative method, merging adjacent arrays progressively.
30
How does quick sort sort an array?
By partitioning the array around a pivot.
31
What is another name for shell sort?
Diminishing decrement sort.
32
Give an example of an internal sorting algorithm.
Shell sort.
33
What is a cipher in cryptography?
A method to implement encryption and decryption of messages.
34
Who keeps the private key in asymmetric key cryptography?
The receiver only.
35
What do transpositional ciphers do?
They rearrange the order of letters in a message.
36
What is the purpose of cryptanalysis?
To find insecurities in a cryptographic scheme.
37
What is the purpose of the TLS protocol?
To secure HTTP connections.
38
What are the principles of data security?
Data Confidentiality, Data Integrity, and Authentication.