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.
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.
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.
4
Q
What is a character data type?
A
- A single letter, number, or symbol enclosed in single quotes.
- Represents text in programming.
5
Q
What are composite data types?
A
- Data types that can store multiple values or a collection of items.
- Examples: Arrays, Lists, Tuples.
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.
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.
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.
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.
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).
11
Q
What are the applications of a stack?
A
- Used in expression evaluation, function call management, undo operations in software.
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).
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.
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.
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.