Chapter 11. Programming Flashcards

1
Q

What are primitive data types?

A
  • Basic data types provided by a programming language.
  • Examples: Integer, Float, Boolean, Character.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the difference between an integer and a float?

A
  • Integer: A whole number without a decimal point.
  • Float: A number with a fractional part, represented with a decimal point.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a Boolean data type?

A
  • A data type that can hold one of two values: True or False.
  • Used in logical operations and control structures.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a character data type?

A
  • A single letter, number, or symbol enclosed in single quotes.
  • Represents text in programming.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are composite data types?

A
  • Data types that can store multiple values or a collection of items.
  • Examples: Arrays, Lists, Tuples.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an array?

A
  • A collection of elements, all of the same data type, stored in contiguous memory locations.
  • Accessed using an index.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the advantages of using arrays?

A
  • Fast access to elements using indices.
  • Efficient in terms of memory usage for fixed-size collections.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a linked list?

A
  • A linear data structure where each element (node) points to the next.
  • Allows for dynamic memory allocation and efficient insertions/deletions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the difference between a singly linked list and a doubly linked list?

A
  • Singly linked list: Each node points to the next node only.
  • Doubly linked list: Each node points to both the next and previous nodes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a stack?

A
  • A linear data structure that follows the Last In, First Out (LIFO) principle.
  • Common operations: Push (add), Pop (remove).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the applications of a stack?

A
  • Used in expression evaluation, function call management, undo operations in software.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a queue?

A
  • A linear data structure that follows the First In, First Out (FIFO) principle.
  • Common operations: Enqueue (add), Dequeue (remove).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the differences between a queue and a stack?

A
  • Queue: FIFO structure, elements are added at one end and removed from the other.
  • Stack: LIFO structure, elements are added and removed from the same end.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a priority queue?

A
  • A data structure where each element has a priority.
  • Elements with higher priority are dequeued before elements with lower priority.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a hash table?

A
  • A data structure that maps keys to values using a hash function.
  • Provides fast access to elements based on key.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the common uses of hash tables?

A
  • Implementing associative arrays, caches, and sets.
  • Used for fast data retrieval.
17
Q

What is a binary tree?

A
  • A hierarchical data structure where each node has at most two children (left and right).
  • Used in searching, sorting, and hierarchical data representation.
18
Q

What is the difference between a binary search tree and a balanced binary tree?

A
  • Binary search tree: Left child is less than the parent, right child is greater.
  • Balanced binary tree: Maintains a balanced height to ensure efficient operations.
19
Q

What is a graph?

A
  • A collection of nodes (vertices) connected by edges.
  • Can be directed or undirected, weighted or unweighted.
20
Q

What are the types of graphs in data structures?

A
  • Directed graph: Edges have a direction.
  • Undirected graph: Edges have no direction.
  • Weighted graph: Edges have weights/costs associated with them.
21
Q

What is a tuple in programming?

A
  • An ordered collection of elements that can be of different data types.
  • Immutable, meaning its elements cannot be changed after creation.
22
Q

What is a set in data structures?

A
  • An unordered collection of unique elements.
  • Supports operations like union, intersection, and difference.
23
Q

What are the differences between a list and a tuple?

A
  • List: Mutable, can be modified after creation.
  • Tuple: Immutable, cannot be modified after creation.
24
Q

What is a dictionary in programming?

A
  • A collection of key-value pairs where each key is unique.
  • Allows fast lookup, addition, and deletion of key-value pairs.
25
Q

What are the advantages of using a dictionary over a list?

A
  • Provides faster lookup times for key-value pairs.
  • Suitable for associative data where fast access is required.