Data Structures: 25 flashcards
All 25 flashcards from this kit, free and with no sign-up.
1. What is an array?
Show the answer
A collection of elements of the same data type stored in contiguous memory locations.
2. How is an array element accessed?
Show the answer
Using an index (or subscript) that starts from 0 in most programming languages.
3. What is the time complexity to access an array element by index?
Show the answer
$O(1)$
4. What is a stack?
Show the answer
A linear data structure that follows the Last In First Out (LIFO) principle.
5. What are the primary operations on a stack?
Show the answer
**Push** (insert) and **Pop** (remove), both at the top.
6. What is a queue?
Show the answer
A linear data structure that follows the First In First Out (FIFO) principle.
7. What are the primary operations on a queue?
Show the answer
**Enqueue** (insert at rear) and **Dequeue** (remove from front).
8. What is a linked list?
Show the answer
A linear data structure where each element (node) contains a data part and a pointer to the next node.
9. What is a node in a linked list?
Show the answer
A structure that holds data and a reference (pointer) to the next node.
10. What is dynamic memory allocation?
Show the answer
The process of allocating memory at runtime (as opposed to compile time) using functions like `malloc()` or `new`.
11. Which function is used to allocate memory dynamically in C?
Show the answer
`malloc()`
12. What does `malloc()` return on failure?
Show the answer
`NULL` pointer.
13. What is the difference between `malloc()` and `calloc()`?
Show the answer
`malloc()` allocates a single block of uninitialized memory; `calloc()` allocates multiple blocks and initializes them to zero.
14. What is the purpose of `free()` in C?
Show the answer
It deallocates memory previously allocated by `malloc()`, `calloc()`, or `realloc()`.
15. What is a memory leak?
Show the answer
A situation where allocated memory is not freed, leading to wasted memory resources.
16. How is an array stored in memory?
Show the answer
In contiguous memory locations, allowing constant-time access via index.
17. What is the time complexity to insert an element at the beginning of an array?
Show the answer
$O(n)$ because all existing elements must be shifted.
18. What is the time complexity to insert an element at the beginning of a linked list?
Show the answer
$O(1)$ if you have a pointer to the head.
19. What is a circular queue?
Show the answer
A queue where the rear wraps around to the front when the end is reached, efficiently using space.
20. What is a stack overflow?
Show the answer
An error that occurs when trying to push onto a full stack.
21. What is a stack underflow?
Show the answer
An error that occurs when trying to pop from an empty stack.
22. What is a doubly linked list?
Show the answer
A linked list where each node has two pointers: one to the next node and one to the previous node.
23. What is the advantage of a linked list over an array?
Show the answer
Dynamic size and efficient insertion/deletion at any position (given a pointer).
24. What is the disadvantage of a linked list compared to an array?
Show the answer
No direct access by index; extra memory for pointers; not cache-friendly.
25. What does `realloc()` do?
Show the answer
Resizes a previously allocated memory block, preserving existing data.
Your notes can be a kit like these
Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.
- Chapter notes
- Flashcards
- Practice MCQs
- Scored tests
- Exam prep
Get Veda free See what students get
Free to start · No ads · Works in 42 languages