# Coding Interview Preparation Coursera Quiz Answers

In this article i am gone to share Coding Interview Preparation by Meta | Coding Interview Preparation Coursera Quiz Answers with you..

**Enrol Link:** Coding Interview Preparation

## Coding Interview Preparation Coursera Quiz Answers

**Week 1 Quiz Answers**

### Knowledge check: The coding interview

Question 1)

What are softskills?

- Skills that you would not feel very competent at.
**They relate to the way you conduct yourself social.**- Coding skills that improve presentation of code.

Question 2)

When are you most likely to be asked about your Softskills?

- During a technical interview.
**During a screening call.**- During a quiz.

Question 3)

What is the purpose of the online coding assignment?

- It is to get you to solve some company problem
- To help you get into the mindset of working for this company before you start
**It is designed to give you an opportunity to show what you can produce in an unpressurized environment that mimics potential job activities you will be asked to undertake**

Question 4)

Pseudocode is a structured way to engage with code.

- True
**False**

Question 5)

When should you test your code?

- Whenever the application crashes to identify what the issue is.
- At the end.
**Continuously as the project progress.**

### Knowledge check: Time complexity

Question 1)

Which has the largest time to compute?

- O(1)
- O(log n)
**O(N)**

Question 2)

Given the following lines of code pseudocode;

N = 7 FOR i = 1 TO N: output(i)

- O(1)
**O(N)**- O(n^2)

Question 3)

Given the following lines of code pseudocode;

N = 7 FOR i = 1 TO N: FOR j = 1 TO N: output(N)

**O(n^2)**- O(N)
- O(1)

Question 4)

Given the following lines of code pseudocode:

N = 37 FOR i = 1 TO N: WHILE i < 10: output(i*N)

- O(1)
**O(N)**- O(n^2)

Question 5)

Given the following lines of code pseudocode;

N = 37 FOR i = 1 TO N: WHILE i < 10: output(i*N)

- O(n^2)
**O(N)**- O(1)

Question 6)

Given the following lines of code pseudocode:

N = 10 FOR i = 1 TO 5: FOR j = 1 TO i: output(i*j)

- O(n^2)
- O(Log N)
**O(1)**

Question 7)

Given the following lines of code pseudocode:

output(N) N = 7 FOR i = 1 TO N: FOR j = 1 TO N: output(N)

- O(N)
- O(1)
**O(n^2)**

### Knowledge check: Space complexity

Question 1)

Given an array that holds 12 integers at 4bytes per integer, contains an additional 12 bytes for the header and 4 bytes for padding. What is the total space complexity for this data structure?

**64**- 16
- 48

Question 2)

A program requires two arrays to compute a function. First array has a header of 12 bytes, and padding of another 4 bytes. It contains 8 integers of 4 bytes each. The second array also has a header of 12 bytes and 4 bytes padding. The second array contains 24 integers of 4 bytes each. What is the input space of this function?

- 32
- 160
**128**

Question 3)

Changing the values in an array leads to greater space complexity over creating a new array and copying in the values?

- True
**False**

Question 4)

Does reducing the space complexity of a function increase the time complexity?

- Yes
**No**

Question 5)

What does auxiliary space refer to?

- Virtual memory
- The space used to store data that the CPU is processing
**It is the space required to hold any additional variables used in the computations of an application.**

**Visit this link:** Module quiz: Introduction to the coding interview Quiz Answers

**Week 2 Quiz Answers**

### Knowledge check: Basic data structures

Question 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.**- They are not memory intensive.

Question 2)

What does it mean to parse a string?

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

Question 3)

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

- 16
- 8
**4**

Question 4)

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

**True**- False

Question 5)

Is it possible to copy an array?

- Yes, but only through making a shallow-copy.
**Yes, but only through making a deep-copy.**- No.

### Knowledge check: Collection data structures

Question 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?

**List**- Set
- Either would do

Question 2)

In relation to data structures what does mutability mean?

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

Question 3)

LIFO and FILO mean the same thing?

**True**- False

Question 4)

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

Stack<T>, is an example of what?

**Generics**- Immutability
- Encapsulation

Question 5)

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

- Lists
**Trees**- Stacks

### Knowledge check: Advanced data structures

Question 1)

Given an array of 12 numbers -> 1,45,5,34,23,5,82,12,35,21,8,9

And a hashing function modulus 6. How many collisions would you expect to have in your table?

- 7
- 5
- 4
**6**

Question 2)

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

- Stack
**Dictionaries**- Queue

Question 3)

What value is stored at the root of a min_heap?

- The last inserted value
- The highest value
**The lowest value**

Question 4)

Why is the travelling salesman used in graphs?

**Because the analogy of travelling can be related to the number of connected nodes.**- 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 distance between two nodes reflects distance in real life.

Question 5)

In relation to computer science what is a clique?

- 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.
**It is a subset of a graph that has found to have strong internal connections and weak external ones.**

**Visit this link:** Module quiz: Introduction to data structures Quiz Answers

**Week 3 Quiz Answers**

### Knowledge check: Sorting and searching

Question 1)

Given an array of 6 numbers -> 6, 8, 19, 48, 9, 90 and applying a selection sort. How many swaps must occur before the array is sorted?

- 4
- 6
**2**

Question 2)

Given an array of numbers and a target value, using a loop, what is the worst-case time complexity to check if the number is present in the array?

- O(1)
- O(log n)
**O(n)**

Question 3)

A binary search can only be performed on a sorted dataset.

**True**- False

Question 4)

Given the following snippet of pseudocode:

array = []

n = 4

FOR i = 0 TO n:

FOR j = 0 TO n:

array.add(i*j)

What is the space complexity of this problem?

- O(n)
**O(n^2)**- O(log n)

Question 5)

What advantage is there to changing element location using an in-place swap?

**It reduces the amount of space taken by removing the need to create another variable in memory.**- It reduces the time taken to complete an algorithm through lowering the time complexity.
- It is a memory feature that allows many variables to reference the same memory location.

### Knowledge check: Working with algorithms

Question 1)

What is memoization?

**It is a process of retaining the results from a computation so that they can be reused rather than recalculating a result.**- It is a practice of only computing what is in the cache in place of expensive memory calls.
- It is an example of divide and conquer.

Question 2)

The practice of breaking a problem into a set of overlapping subproblems is referred to as:

- Memoization
- Divide and conquer
**Dynamic programming**

Question 3)

Quicksort is an example of divide and conquer?

**True**- False

Question 4)

Examine the following problem:

A bank robber has entered a bank vault and sees 3 stacks of precious bars: Gold, silver and platinum. The gold weighs 6kg and is valued at 60 dollars. The silver weighs 1 kg and is valued at 5 dollars. And the platinum weighs 10kg and is valued at 110 dollars. The robber can only carry 38kg. What is the optimal combination of items to take? Your solution is to fill the bag with as many platinum bars as possible before moving to the gold and then the silver. What type of approach best describes this solution?

**Greedy approach**- Graph approach
- Dynamic programming

Question 5)

Why is a base case crucial when designing recursive solutions?

**Without it the function would go on forever.**- It is used to ensure that the input diminishes at each call.
- The algorithm needs to know the shape of the minimum case so it can model the solution from it.

**Visit this link:** Module quiz: Introduction to algorithms Quiz Answers

**Week 4 Quiz Answers**

**Visit this link:** Coding Interview Preparation Final graded assessment Quiz Answers