Data Structures Fundamentals
- 35Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary purpose of data structures in computer science?
What is the primary purpose of data structures in computer science?
35 questions
- 1
What is the primary purpose of data structures in computer science?
- A
They help in creating disorganized data storage in memory.
- B
They prevent any data from being stored in computer memory.
- C
They allow data to be structured for easy retrieval and reading.
- D
They convert all data into a single, uniform variable type.
Correct answer
CThey allow data to be structured for easy retrieval and reading.
Explanation
Data structures are used to organize data in computer memory, making it easy to retrieve and read. The text contrasts this with disorganized storage, emphasizing the need for structured data.
- A
- 2
Which of the following terms is NOT used interchangeably with 'Arrays' in some programming languages?
- A
Sets represent distinct elements, unlike arrays.
- B
Lists are often considered to be similar to arrays.
- C
Arrays are fundamental ordered data collections.
- D
Vectors are sometimes synonymous with arrays.
Correct answer
ASets represent distinct elements, unlike arrays.
Explanation
The text states that Arrays are also called lists or Vectors in some languages. Sets are a different type of data structure with unique properties.
- A
- 3
How do programming languages typically denote array access and indexing?
- A
They always start arrays at index 0 and use angle brackets.
- B
They commonly begin arrays at index -1 and use curly braces.
- C
They generally begin arrays at index 1 and use parentheses.
- D
They usually start arrays at index 0 and use square brackets.
Correct answer
DThey usually start arrays at index 0 and use square brackets.
Explanation
The content explicitly mentions that 'Almost all programing languages start arrays at index 0, and use a square bracket syntax to denote array access.'
- A
- 4
If an array is stored at memory location 1000, where would 'j index of 5' retrieve its value?
- A
The program would go to memory location 1000 plus an offset of 5.
- B
The computer would access memory location 1000 with an offset of 0.
- C
The value would be found at memory location 1000 minus an offset of 5.
- D
The system would look for the value at memory location 1005 plus 0.
Correct answer
AThe program would go to memory location 1000 plus an offset of 5.
Explanation
The text explains, 'If we wanted to retrieve 'j index of 5', our program goes to memory location 1000, plus an offset of 5.' This demonstrates how indexing translates to memory offsets.
- A
- 5
What distinguishes the 'fifth number in the array' from the 'number at index 5'?
- A
They are always the same value in any given array.
- B
The number at index 5 is always found before the fifth number.
- C
The fifth number is at index 4, while index 5 is the sixth number.
- D
The fifth number is always larger than the number at index 5.
Correct answer
CThe fifth number is at index 4, while index 5 is the sixth number.
Explanation
The content clarifies, 'It’s easy to confuse the fifth number in the array with the number at index 5. They are not the same. Remember, the number at index 5 is the 6th number in the array because the first number is at index 0.'
- A
- 6
Which statement accurately describes the utility of built-in sort functions for arrays?
- A
They must be configured to work with every unique data type.
- B
They only work for arrays containing a specific range of numbers.
- C
They require programmers to implement the sorting algorithm manually.
- D
They allow passing an array to get it sorted without writing code.
Correct answer
DThey allow passing an array to get it sorted without writing code.
Explanation
The text states, 'For example, pretty much every programming language comes with a built-in sort function, where you just pass in your array, and it comes back sorted. So there’s no need to write that algorithm from scratch.'
- A
- 7
How are Strings fundamentally represented in computer memory?
- A
Strings are exclusively stored as binary values without characters.
- B
Strings are always treated as single, indivisible data units.
- C
Strings are essentially arrays of characters, like letters and symbols.
- D
Strings are stored as standalone individual character variables.
Correct answer
CStrings are essentially arrays of characters, like letters and symbols.
Explanation
The content defines strings as 'just arrays of characters, like letters, numbers, punctuation and other written symbols.'
- A
- 8
What is the significance of the null character (binary value 0) at the end of a string in memory?
- A
It represents a placeholder for an additional character to be added.
- B
It denotes the end of the string, telling functions when to stop.
- C
It acts as a separator between individual characters in a string.
- D
It indicates the string should continue indefinitely in memory.
Correct answer
BIt denotes the end of the string, telling functions when to stop.
Explanation
The text explains, 'This is called the null character, and denotes the end of the string in memory. This is important because if I call a function like 'print quote', it needs to know when to stop!'
- A
- 9
Which function is described for combining two strings into a single, longer string?
- A
A string parsing function separates text into smaller parts.
- B
A string comparison function checks if two strings are identical.
- C
A string length function determines the total character count.
- D
A string concatenation function joins two strings together.
Correct answer
DA string concatenation function joins two strings together.
Explanation
The content describes, 'many programming languages have a string concatenation function, or 'strcat', which takes in two strings, and copies the second one to the end of the first.'
- A
- 10
What concept best describes a 'Matrix' in the context of data structures?
- A
It can be conceptualized as an array where each element is another array.
- B
It functions as a simple array of individual numbers.
- C
It serves primarily as a container for unrelated variables.
- D
It is a single, isolated value with no internal structure.
Correct answer
AIt can be conceptualized as an array where each element is another array.
Explanation
The text clearly states, 'You can think of a Matrix as an array of arrays!' This highlights its nested array structure.
- A
- 11
To access a specific value in a two-dimensional matrix, how many indices are required?
- A
Two indices are necessary to locate a specific element.
- B
Only one index is needed to pinpoint a matrix value.
- C
No indices are needed, as values are accessed sequentially.
- D
Three indices are always required for matrix access.
Correct answer
ATwo indices are necessary to locate a specific element.
Explanation
The content explains, 'To access a value, you need to specify two indexes, like 'J index of 2, then index of 1' - this tells the computer you’re looking for the item in subarray 2 at position 1.'
- A
- 12
What is a key characteristic regarding the dimensionality of matrices?
- A
Matrices cannot exceed three dimensions under any circumstances.
- B
Matrices can be created with any desired number of dimensions.
- C
Matrices are strictly limited to two dimensions for data storage.
- D
Matrices are always one-dimensional arrays in their structure.
Correct answer
BMatrices can be created with any desired number of dimensions.
Explanation
The text indicates, 'The cool thing about matrices is we’re not limited to 3 by 3 -- we can make them any size we want -- and we can also make them any number of dimensions we want.'
- A
- 13
What is the primary purpose of a 'Struct' data structure?
- A
To create an array that can endlessly grow in size.
- B
To store only single, unrelated numbers or characters.
- C
To bundle together a block of related variables into one unit.
- D
To limit variables to storing only one type of data at a time.
Correct answer
CTo bundle together a block of related variables into one unit.
Explanation
The content states, 'But often it’s useful to store a block of related variables together. Like, you might want to store a bank account number along with its balance. Groups of variables like these can be bundled together into a Struct.'
- A
- 14
How does accessing 'J index of 0' in an array of structs differ from a simple array?
- A
It provides only the memory address of the first variable.
- B
It retrieves the entire bundled struct stored at that index.
- C
It causes an error because structs cannot be in arrays.
- D
It returns only a single number from the array location.
Correct answer
BIt retrieves the entire bundled struct stored at that index.
Explanation
The text clarifies, 'If we access, for example, J index of 0, we get back the whole struct stored there, and we can pull the specific account number and balance data we want.'
- A
- 15
What limitation do arrays of structs share with regular arrays regarding size?
- A
They can be dynamically enlarged to add an unlimited number of items.
- B
They automatically adjust their size based on data input.
- C
They are created at a fixed size and cannot be easily enlarged.
- D
They can only store a single struct, regardless of its content.
Correct answer
CThey are created at a fixed size and cannot be easily enlarged.
Explanation
The content notes, 'This array of structs, like any other array, gets created at a fixed size that can’t be enlarged to add more items.'
- A
- 16
What does a 'pointer' variable represent in the context of data structures?
- A
A variable that stores a fixed numerical value.
- B
A variable that can only store Boolean true/false states.
- C
A variable that directly holds another variable's entire content.
- D
A special variable that indicates a location in computer memory.
Correct answer
DA special variable that indicates a location in computer memory.
Explanation
The content defines a pointer as 'a special variable that points, hence the name, to a location in memory.'
- A
- 17
How does a 'linked list' achieve its flexibility in storing many nodes?
- A
Each node points to the next node in the sequence of the list.
- B
Each node explicitly stores all the data of subsequent nodes.
- C
Linked lists require fixed, pre-defined sizes like arrays.
- D
All nodes are stored contiguously in a single memory block.
Correct answer
AEach node points to the next node in the sequence of the list.
Explanation
The text states, 'Using this struct, we can create a linked list, which is a flexible data structure that can store many nodes. It does this by having each node point to the next node in the list.'
- A
- 18
What allows nodes in a linked list to be spaced apart in memory?
- A
They must always be stored sequentially, without any gaps.
- B
Linked lists consolidate all nodes into one contiguous block.
- C
Pointers within nodes explicitly store the memory location of the next node.
- D
Each node's value implicitly indicates the next node's location.
Correct answer
CPointers within nodes explicitly store the memory location of the next node.
Explanation
The content explains, 'They might be spaced apart, because they were created at different times, and other data can sit between them. So, you see that the first node contains the value 7, and the location 1008 in its 'next' pointer.' This shows pointers manage non-contiguous storage.
- A
- 19
How can a linked list be terminated to indicate its end?
- A
By ensuring the last node contains a specific non-zero value.
- B
By having the last node point back to the very first node.
- C
By adding a special character at the end of the last node.
- D
By using a 'next' pointer value of 0, the null value.
Correct answer
DBy using a 'next' pointer value of 0, the null value.
Explanation
The text states, 'it could also have been terminated by using a next pointer value of 0 -- the null value -- which would indicate we’ve reached the end of the list.'
- A
- 20
What is a significant advantage of linked lists over arrays regarding size?
- A
Linked lists maintain a constant size, regardless of additions.
- B
Linked lists can be dynamically extended or shortened.
- C
Linked lists always require a pre-defined fixed size.
- D
Linked lists cannot be easily expanded or contracted.
Correct answer
BLinked lists can be dynamically extended or shortened.
Explanation
The content highlights, 'Unlike an array, whose size has to be pre-defined, linked lists can be dynamically extended or shortened.'
- A
- 21
How can a new node be inserted into an existing linked list?
- A
By converting the linked list into a fixed-size array first.
- B
By allocating new memory for all subsequent nodes.
- C
By completely rebuilding the entire linked list from scratch.
- D
By changing only the 'next' pointers of relevant nodes.
Correct answer
DBy changing only the 'next' pointers of relevant nodes.
Explanation
The text mentions, 'For example, we can allocate a new node in memory, and insert it into this list, just by changing the next pointers.'
- A
- 22
What describes the behavior of a 'queue' data structure?
- A
Elements are processed in a First-In, First-Out (FIFO) order.
- B
It allows random access to any element within the structure.
- C
Elements are added and removed only from the top.
- D
It follows a Last-In, First-Out (LIFO) principle.
Correct answer
AElements are processed in a First-In, First-Out (FIFO) order.
Explanation
The text explains a queue 'goes in order of arrival. The person who has been waiting the longest, gets served first. This behavior is called First-In First-Out, or FIFO.'
- A
- 23
In a queue, what term describes adding a new person to the end of the line?
- A
The action of retrieving an element is called dequeuing.
- B
The operation of adding an element is called enqueueing.
- C
The process of removing an element is called popping.
- D
The method of placing an element is called pushing.
Correct answer
BThe operation of adding an element is called enqueueing.
Explanation
The content describes, 'If we want to enqueue someone, that is, add them to the line, we have to traverse down the linked list until we hit the end, and then change that next pointer to point to the new person.'
- A
- 24
What term is used for removing an element from the front of a queue?
- A
Removing an item is always termed stacking.
- B
Removing an item is commonly known as pushing.
- C
Removing an item is generally called enqueueing.
- D
Removing an item is referred to as dequeuing.
Correct answer
DRemoving an item is referred to as dequeuing.
Explanation
The text states, 'Once we’re done serving Hank, we can read Hank’s next pointer, and update our 'post office queue' pointer to the next person in the line. We’ve successfully dequeued Hank.'
- A
- 25
What principle governs the behavior of a 'stack' data structure?
- A
Elements are retrieved randomly from any position.
- B
Elements are processed in a Last-In, First-Out (LIFO) manner.
- C
Elements are processed in a First-In, First-Out (FIFO) manner.
- D
Elements are always accessed from the very bottom.
Correct answer
BElements are processed in a Last-In, First-Out (LIFO) manner.
Explanation
The content explains, 'With just a small change, we can use linked lists as stacks, which are LIFO… Last-In First-Out.'
- A
- 26
Which terms are the official operations for adding and removing data from a stack?
- A
Adding data is 'placing,' and removing data is 'extracting.'
- B
Adding data is 'inserting,' and removing data is 'deleting.'
- C
Adding data is 'enqueueing,' and removing data is 'dequeuing.'
- D
Adding data is 'pushing,' and removing data is 'popping.'
Correct answer
DAdding data is 'pushing,' and removing data is 'popping.'
Explanation
The text explicitly states, 'Instead of enqueueing and dequeuing, data is pushed onto the stack and popped from the stacks. Yep, those are the official terms!'
- A
- 27
How can 'trees' be constructed using a modified node struct?
- A
By having the node contain only a single data variable.
- B
By ensuring all nodes point exclusively to the root node.
- C
By updating the node struct to include two or more pointers.
- D
By eliminating all pointers from the node structure entirely.
Correct answer
CBy updating the node struct to include two or more pointers.
Explanation
The content explains, 'If we update our node struct to contain not just one, but two pointers, we can build trees, another data structure that’s used in many algorithms.'
- A
- 28
In a tree data structure, what is the topmost node called?
- A
The topmost node in a tree is always a parent node.
- B
The topmost node in a tree is known as a leaf node.
- C
The topmost node in a tree is designated as the child.
- D
The topmost node in a tree is referred to as the root.
Correct answer
DThe topmost node in a tree is referred to as the root.
Explanation
The text clearly defines, 'The top most node is called the root.'
- A
- 29
What is the term for nodes in a tree that have no children?
- A
These nodes are commonly called parent nodes.
- B
These nodes are known as leaf nodes.
- C
These nodes are exclusively referred to as root nodes.
- D
These nodes are identified as branching nodes.
Correct answer
BThese nodes are known as leaf nodes.
Explanation
The content states, 'And finally, any nodes that have no children -- where the tree ends -- are called Leaf Nodes.'
- A
- 30
What type of tree is it when nodes can have up to two children?
- A
This specific structure is called a binary tree.
- B
This specific structure is known as a general tree.
- C
This specific structure is designated as a leaf tree.
- D
This specific structure is named a multi-way tree.
Correct answer
AThis specific structure is called a binary tree.
Explanation
The content specifies, 'In our example, nodes can have up to two children, and for that reason, this particular data structure is called a binary tree.'
- A
- 31
What is a fundamental property of trees, both in real life and as data structures?
- A
There are always multiple-way paths from roots to leaves.
- B
There are arbitrary connections forming loops within trees.
- C
There is a one-way path from roots to leaves.
- D
There are no distinct roots or leaves in tree structures.
Correct answer
CThere is a one-way path from roots to leaves.
Explanation
The text states, 'An important property of trees – both in real life and in data structures – is that there’s a one-way path from roots to leaves.'
- A
- 32
When is a 'graph' data structure preferred over a tree?
- A
When data must always follow a strict one-way path from root to leaf.
- B
When the data links arbitrarily and includes complex loops.
- C
When there is a clear hierarchy of parent and child nodes.
- D
When the primary goal is to maintain a simple, linear data sequence.
Correct answer
BWhen the data links arbitrarily and includes complex loops.
Explanation
The content explains, 'For data that links arbitrarily, that include things like loops, we can use a graph data structure instead.' It also contrasts this with trees by noting 'there is no notion of roots and leaves, and children and parents… Anything can point to anything!'
- A
- 33
What distinguishes a graph data structure from a tree, even though both use nodes and pointers?
- A
Graphs have no concept of roots, leaves, parents, or children.
- B
Graphs are limited to a fixed number of connections per node.
- C
Graphs allow only one-way paths between connected nodes.
- D
Graphs strictly enforce a single root node and distinct leaf nodes.
Correct answer
AGraphs have no concept of roots, leaves, parents, or children.
Explanation
The text explains, 'This can be stored as nodes with many pointers, very much like a tree, but there is no notion of roots and leaves, and children and parents… Anything can point to anything!'
- A
- 34
Why is the choice of data structure important for programmers?
- A
The right data structure can make a programmer's job easier.
- B
Different data structures are merely aesthetic choices for code.
- C
The choice of data structure has no impact on computations.
- D
Programmers must always implement data structures from scratch.
Correct answer
AThe right data structure can make a programmer's job easier.
Explanation
The content advises, 'The right choice of data structure can make your job a lot easier, so it pays off to think about how you want to structure your data before you jump in.'
- A
- 35
What resource do most programming languages offer for data structures?
- A
They require manual creation of every data structure type for efficiency.
- B
They come with libraries packed full of ready-made data structures.
- C
They provide only the most basic components, requiring full custom implementation.
- D
They offer no specific support for data structures, relying on user code.
Correct answer
BThey come with libraries packed full of ready-made data structures.
Explanation
The text states, 'Fortunately, most programming languages come with libraries packed full of ready-made data structures. For example, C++ has its Standard Template Library, and Java has the Java Class Library.'
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.