# COURSE – CODING INTERVIEW PREPARATION QUIZ ANSWERS

## Complete Coursera Answers & Study Guide

Click to Enroll in Coursera Meta Front-End Professional Certificate

## Introduction to Data Structures INTRODUCTION

This module introduces students to the concept of data structures and their implementation in various programming languages. It is part of the Meta Front-End Developer Professional Certificate program offered by Coursera. Through this module, students will gain an understanding of basic data structures, such as strings, integers, arrays and objects. This will be followed by a deeper examination into more complex collection data structures including lists, stacks and trees.

Finally, advanced topics related to hash tables, heaps and graphs will be covered too. Students who successfully complete this course should feel confident in their ability to apply appropriate data structures for various programming tasks and activities.

## Learning Objectives

• Review data structures in context with coding interviews
• Introduce new data structures that are commonly found in coding interviews

## KNOWLEDGE CHECK: BASIC DATA STRUCTURES

### 1. What does it mean to say a Data Structure is a first-class object?

• It is very quick at retrieving and storing data.
• This means that a data structure can be passed to a function, returned as a result and generally treated like any other variable. (CORRECT)
• They are not memory intensive.

Correct: That’s correct. It relates to the capabilities available to it.

### 2. What does it mean to parse a string?

• To pass it to the compiler to execute instructions.
• To remove symbols and uppercases from a string of text.
• To remove items from a string not based on a given format. (CORRECT)

Correct: That’s correct. This format can be anything such as the shape of the date, or a repeating pattern such as name, date of birth, address, etc.

### 3. How many bytes does it normally take to represent a standard int?

• 16
• 4 (CORRECT)

Correct: That’s correct. A standard int takes 4 bytes.

### 4. A Boolean answer is one that will be either true or false?

• True (CORRECT)
• False

Correct: That’s correct. Depending on the language it might be 0 or 1, this is just a different representation of true or false.

### 5. Is it possible to copy an array?

• No.
• Yes, but only through making a shallow-copy.
• Yes, but only through making a deep-copy. (CORRECT)

Correct: Correct. While one can make a shallow copy of an array, the actual array itself is not copied. Making a deep copy creates a new instance of an array with the same values but that exists in its own space in memory.

## KNOWLEDGE CHECK: COLLECTION DATA STRUCTURES

### 1. You wish to store a list of grades for a class. Given the choice between a set and a list, which is the more appropriate data structure?

• Either would do
• Set
• List (CORRECT)

Correct: Correct. A list will allow you to store repeating instances of data.

### 2. In relation to data structures what does mutability mean?

• It relates to dynamic programming languages, and it can be passed as a variable to a function.
• It means that once an object is created it cannot be changed.
• It means that it can be changed after it has been created. (CORRECT)

Correct: That’s correct. It relates to the ability to be able to change a value after it has been instantiated.

### 3. LIFO and FILO mean the same thing?

• True (CORRECT)
• False

Correct: That’s correct. FILO (First In Last Out) is another way of saying LIFO (Last in First Out).

### 4. Creating a class through the use of a capital T as below:

• Stack<T>, is an example of what?
• Generics (CORRECT)
• Encapsulation
• Immutability

Correct: That’s correct. In this way, the object created from the class need not be confined to one specific type until compile time.

### 5. On what type of data structure would one do a depth first search?

• Lists
• Stacks
• Trees (CORRECT)

Correct: That’s correct. A tree is a series of interconnected nodes that build under one root node. Doing a depth first search, is to follow one branch of nodes to the very deepest one.

## KNOWLEDGE CHECK: ADVANCED DATA STRUCTURES

### 1. Given an array of 12 numbers ->  1,45,5,34,23,5,82,12,35,21,8,9And a hashing function modulus 6. How many collisions would you expect to have in your table?

• 5
• 6 (CORRECT)

Correct: That’s correct. Applying the hashing function led to generating 6 collisions.

### 2. What data structure would be most suitable for mimicking the actions of a hashtable?

• Stack
• Queue
• Dictionaries (CORRECT)

Correct: That’s correct. Some languages that do not have built-in hashtable types use dictionaries to emulate the behavior.

### 3. What value is stored at the root of a min_heap?

• The highest value
• The lowest value (CORRECT)
• The last inserted value

Correct: That’s correct. A min heap stores in order of lowest to highest

### 4. Why is the travelling salesman used in graphs?

• Because graphs store information in a fixed way so that every node is the exact same distance apart. Allowing us apply travel times to it.
• Because the analogy of travelling can be related to the number of connected nodes. (CORRECT)
• Because the distance between two nodes reflects distance in real life.

Correct: That’s correct. When one talks about the travelling sales man, it need not be routed in actual distance. Instead, this is an analogy to the connectedness between elements. From this principle, many algorithms can be applied to extract information from data.

### 5. In relation to computer science what is a clique?

• It is a subset of a graph that has found to have strong internal connections and weak external ones. (CORRECT)
• It is a social group that one actively engages with.
• It is a memory feature that allows for quick lookup of one’s social circle.

Correct: That’s correct. It can be determined by analyzing the interconnectedness of nodes and comparing them to external nodes.

## Coursera Meta Front-End Developer Professional Certificate Answers and Study Guide

Liking our content? Then don’t forget to ad us to your bookmarks so you can find us easily!

## MODULE QUIZ: INTRODUCTION TO DATA STRUCTURES

### 1. What do TSV files use to separate their data?

• Tabs (CORRECT)
• Types
• Topic

Correct: That’s correct. The TSV are Tab Separated Values.

### 2. Arrays are always stored on the stack?

•  Yes, but only through making a deep-copy. (CORRECT)
• Yes, but only through making a shallow-copy.
• No

Correct: Correct. While one can make a shallow copy of an array, the actual array itself is not copied. Making a deep copy creates a new instance of an array with the same values but that exists in its own space in memory.

### 3. What happens when you try to retrieve a value using a number greater than the index size?

• Nothing. There would be nothing to retrieve so it would return null.
•  It would throw an error. (CORRECT)
• It would return a warning and a message indicating the issue.

Correct: That’s correct. Accessing the array outside of the index range throws an out-of-bounds error.

### 4. In relation to computer science, what is a class?

• An object that has functionality.
• It is the thing from which arrays are build.
• It is a blueprint for an object. (CORRECT)

Correct: That’s correct. How the class is coded is what characteristics the object will embody.

### 5. In relation to objects, what are instance variables?

• Characteristics of the class. (CORRECT)
• Attributes that can take on many forms.
• An attribute that has an immediate impact when compiled.

Correct: That’s correct. Variables are the characteristics or attributes associated with a class.

### 6. How many children can a node in a binary tree have?

• 2 (CORRECT)
• 1

Correct: That’s correct. As the name suggests it can have two children nodes, one larger and one smaller.

### 7. Which of the following uses a FIFO approach.

• Stacks
• Queues (CORRECT)
• Lists

Correct: That’s correct! A queue works much like its namesake. The first one to arrive is the first one to be served.

### 8. In relation to data structures what does synchronization mean?

• Making a class thread safe. (CORRECT)
• It is something to do with swimming.
• Relates to a measured way of increasing the size of an object.

Correct: That’s correct. Synchronizing an object means that only one thing can access it at a time.

### 9. Why do you need to implement a comparator when storing objects on a tree?

• As a means of comparing objects so the tree knows which node to store an object on. (CORRECT)
• To ensure that values don’t clash when being added to a tree.
• So that the compiler can know to keep the tree balanced by comparing a number of nodes.

Correct: That’s correct. The implementation of some trees requires that objects are stored relative to one another. Enabling a comparator allows you store objects of different types in relation to one another.

### 10. Why are heaps called heaps?

• The order of importance is determined by where in the data structure the information is found. (CORRECT)
• The organization of their data is done in a very loose way, so it is said that the elements are heaped together.
• Because they store a selection of different data types.

Correct: Correct. A heap will place the most important element at the top. This can be the highest or lowest depending on implementation. The design of this approach is that one would only take the top value and not try and retrieve one in the middle.

### 11. What type of data structure would you implement if you require the ability to perform updates and queries directly on the contents without affecting the data structure?

•  Mutable (CORRECT)
•  Immutable
•  Array

Correct: That’s correct. A mutable data structure facilitates operations to be performed on its contents.

### 12. Which type of data structure would you use if you needed to store some data that would grow dynamically, using nodes to reference an element’s position in the data structure?

• A set
•  An array-based list  (CORRECT)

Correct: Not quite. An array-based list is an ordered collection that generally requires that you initially determine how big a structure will be.

### 13. Which data structure would you choose if you wanted to create a collection of elements where you needed to access the last element entered into the collection first?

• Stack (CORRECT)
• Queue

Correct: That’s correct. A stack works with a strict First-In-Last-Out or FILO basis, which means that items can only be retrieved from the top of the stack, or the most recently added element.

### 14. Which of the below names can be used to describe a tree node:

• Branch
• Sibling (CORRECT)
• Child (CORRECT)
• Parent (CORRECT)
• Leaf (CORRECT)
• Root (CORRECT)

Correct: That’s correct. Nodes that have the same parent are referred to as siblings.

Correct: That’s correct. Each subsequent node that is connected down the tree from a parent or root node is referred to as a child node.

Correct: That’s correct. A parent node can have a connected set of children nodes.

Correct: That’s correct. Nodes with no children are referred to as leaf nodes.

Correct: That’s correct. The top level node of a tree is referred to as the root.

### How many collisions would you expect to have in your table?

• 4
• 5 (CORRECT)
• 3
• 6

Correct: That’s correct. Given this array of numbers [1, 4, 2, 6, 2, 3, 3, 5, 2, 2, 6, 0] this would equal to 5 collisions.

### This memory relates to external memory that can be plugged in externally and used to increase the storage capacity of your system. Accessing this type of memory is slower and requires transferring all required information and instructions into RAM.

• Secondary Memory (CORRECT)
• Cache memory
• Main memory

Correct: Well done.  Secondary memory relates to external memory that can be plugged in externally and used to increase the storage capacity of your system.   Accessing this type of memory is slower and requires transferring all required information and instructions into RAM.

### 17. An undirected graph has an order of precedence.

• True
• False (CORRECT)

Correct: Well done. In contrast to a directed graph, an undirected graph doesn’t have an order of precedence.

## INTRODUCTION TO DATA STRUCTURES CONCLUSION

In this module, you learned about data structures and their implementation in different programming languages. You also discovered the similarities between the patterns of data structures in various programming languages. This knowledge will help you choose the right data structure for your program based on its capabilities.

Now that you have completed this module, why not put your new skills to the test by enrolling in Coursera’s Data Structures and Algorithms course? With Coursera, you can learn at your own pace and earn a certification to show future employers what you’re capable of. Don’t wait – sign up today!

#### Subscribe to our site

Get new content delivered directly to your inbox.

## Quiztudy Top Courses

Liking our content? Then, don’t forget to ad us to your BOOKMARKS so you can find us easily!