## Where Should You Use Data Structures

Your answer will demonstrate your understanding of what the interviewing company does. Show you will be able to appropriately structure their data by referencing elements specific to the company.

Example:Data structures can effectively be applied anywhere data exists. However, it is most useful in database management, analyzing numbers, graphics and compiler design.

Related: 9 Common Data Structures Every Programmer Should Know

## What Is A Queue Data Structure What Are The Applications Of Queue

A queue is a linear data structure that allows users to store items in a list in a systematic manner. The items are added to the queue at the rear end until they are full, at which point they are removed from the queue from the front. Queues are commonly used in situations where the users want to hold items for a long period of time, such as during a checkout process. A good example of a queue is any queue of customers for a resource where the first consumer is served first.

Following are some applications of queue data structure:

- Breadth-first search algorithm in graphs
- Operating system: job scheduling operations, Disk scheduling, CPU scheduling etc.

## Explain What Is Data Structure

The data structure is nothing but an entity where the data is perfectly aligned and can be manipulated as per the requirement. When we deal with data structure it is not just about one table of data but it is about different data sets and how well they are aligned with each other. Overall, it helps the data to be organized.

**You May Like: What Questions To Ask As The Interviewer **

## What Is The Process Behind Storing Variables In Memory

The simplest way to store anything in the computers memory is using a variable. A variable represents one piece of data, such as a character or a number. Variables make it easier to write programmes because you can refer to values by their names and write generic programs or functions that work with any value.

The way variables are stored depends on the programming language being used. Some programming languages require declaring variables and others dont. There are certain programming languages in which variables can only be of a certain type while others are more flexible.

## Question : Edit Distance Problem In Java

Given two strings string1 and string2, String1 is to be converted into String2 with the given operations available in the minimum number of steps. Using any one of the given operations contributes to the increment of steps by one.

Allowed Operations are : **Remove** : This operation allows the Removal any one character from String. **Insert** : This operation allows the Insertion of one character at any spot in the String. **Replace** : This operation allows the replacement of any one character in the string withany other character.

Solution: Edit distance problem in java.

**Don’t Miss: Big Data Analytics Interview Questions **

## Tips For Cracking The Google Software Engineer Interview

Before going in, ensure that you keep the following in mind and put your best efforts into clearing the Google software engineer interview:

These tips will always come in handy â whether youâre appearing for the Google software engineer intern interview or youâre an experienced professional. You can learn more here.

If you want some more help, check out these articles:

## What Is A Stack Data Structure What Are The Applications Of Stack

A stack is a data structure that is used to represent the state of an application at a particular point in time. The stack consists of a series of items that are added to the top of the stack and then removed from the top. It is a linear data structure that follows a particular order in which operations are performed. LIFO or FILO are two possible orders. A stack consists of a sequence of items. The element that’s added last will come out first, a real-life example might be a stack of clothes on top of each other. When we remove the cloth that was previously on top, we can say that the cloth that was added last comes out first.

Following are some applications for stack data structure:

- It acts as temporary storage during recursive operations
- Redo and Undo operations in doc editors
- Reversing a string

**Read Also: What To Expect In A Teaching Interview **

## What Is The Result Of 10+20+30 In Javascript

This interview question tests your knowledge of JavaScript data primitives, the data types that can be composed into different data structures in Python. In this case, its a mix between string and numbers data types. Knowing that the result will be 102030 rather than 60 means that you understand that when a string type is invoked with the + operator in JavaScript, the automatic behavior is to turn it into a concatenation operator.

Only by ensuring that everything that interacts with the + operator is a number or BigInt data type can you ensure that a desired behavior of addition happens.

## What Is The Difference Between A Stack And An Array

**STACK**:

i) Stack is a collection of articles arranged.

ii) Stack is a dynamic object whose size changes steadily when things are pressed and popped.

Stack may have many sorts of data.

iv) Stack is specified as a structure with an array that holds the stack element, and an integer that specifies the stack top in the array.

**ARRAY:**

i) Array is a group of articles ordered.

ii) Array is an object static, i.e. no item is fixed, and the array statement assigns it.

iii) It includes the same kinds of data.

iv) A pile array, i.e. a pile array can be declared large enough to have the maximum stack size.

**Don’t Miss: How To Prepare Online Interview **

## What Do You Mean By Queue Can You Explain Its Applications

A queue is a data structure which follows the First In First Out logic for operations, which means that the first element input into the queue is operated on first.

A scheduling system is a good example of an application of a queue. Imagine a computing environment where CPU resources are being shared by multiple people. In that case, the work that they want to do can be placed in a queue, with the commands that came first being executed by the queue first.

## How Can You Implement A Stack Using Queues

You can implement a stack using queues either by making the push or pop operations costly. Here are the algorithms for both methods.

#### Making the Push Operation Costly

We use two queues to implement a stack by making the push operation costly.

- We start by moving all the elements from q1 to q2
- Next, enqueue the new element into q1
- Transfer all the elements in q2 back into q1

#### Making the Pop Operation Costly

- Move all elements except the last element from q1 to q2
- Remove the last element that remains in q1
- Move all the elements from q2 back into q1

**You May Like: How To Prepare For A Project Coordinator Interview **

## Write A Function For Zigzag Traversal In A Binary Tree

**Explanation:**Zigzag Traversal first iterates the given level of the tree from left to right and then the next level as the right to the level.

// Tree Nodestruct Node //Function to store the zigzag order traversal of a tree in a list. vector < int> zigZagTraversal //Iterate until the second stack is not empty while) } return result }

**Time Complexity**: O

## Do Linked Lists Have Any Advantages Over Arrays

Yes, linked lists have a few advantages in comparison with arrays.

- Linked lists offer dynamic storage capacity and can easily accommodate newer values. Arrays are initialized with a particular size and cant adapt to memory requirements as a result.
- It is easier to insert or delete elements in a linked list since the elements are not stored in contiguous memory locations.

**Recommended Reading: Open-ended Interview Questions For Managers **

## What Is Array Data Structure What Are The Applications Of Arrays

An array data structure is a data structure that is used to store data in a way that is efficient and easy to access. It is similar to a list in that it stores data in a sequence. However, an array data structure differs from a list in that it can hold much more data than a list can. An array data structure is created by combining several arrays together. Each array is then given a unique identifier, and each arrays data is stored in the order in which they are created.

Array data structures are commonly used in databases and other computer systems to store large amounts of data efficiently. They are also useful for storing information that is frequently accessed, such as large amounts of text or images.

## Linear Data Structures Vs Non

A linear data structure stores data in a linear sequence. You can only traverse the data structure in that linear sequence. Arrays and stacks are examples of linear data structures.

Non-linear data structures arrange data in ways that are not linear. A graph, for example, has nodes which are connected to each other through edges. The relationships between the data values are defined by which nodes are connected through edges, and not by a sequential arrangement. Trees are also non-linear data structures.

**You May Like: Email Rejecting Candidate After Interview **

## Are Data Structures Always Static

No, Data Structures can be both dynamic and static, depending on the way memory allocation works for them. For example, Arrays are static data structures since an entire lot of contiguous memory is allocated to them when they are defined. On the other hand, Linked Lists are dynamic Data Structures as they dont have any fixed size and the number of nodes can increase depending on the programmers requirements.

## What Is Infix Prefix And Postfix In Data Structure

The way to write arithmetic expressions is known as notation. There are three types of notations used in an arithmetic expression, i.e., without changing the essence or output of expression. These notations are:

**Prefix Notation**– In this, the operator is prefixed to operands, i.e. ahead of operands.**Infix Notation**– In this, operators are used in between operands.**Postfix Notation**– In this, the operator is postfixed to the operands, i.e., after the operands.

The following table briefly tries to show the difference in all three notations

Infix Notation |

**Read Also: How Do I Answer Interview Questions **

## How Would You Detect And Remove A Loop In A Linked List

A linked list is a data structure that, like an array, is linear. However, whereas an array stores its elements in contiguous locations, linked lists store elements randomly and link them through pointers.

Generally, a linked list is a data structure constructed from nodes, each consisting of a data field and a link that points to the next node in the list. Loops in a linked list could cause errors in the program. To answer this question well, you should have a solid knowledge of recursion as it is a recursive data structure.

Example:To detect and remove a loop in a linked list, you should write a detectAndRemoveLoop function, which checks for loop in a linked list and then removes it if present and then returns true. If no loop is detected, the function returns false.

Related:How To Prepare for 5 Common jQuery Interview Questions

## How Can You Use Linked Lists And Arrays Give Examples

A linked list is a linear data structure where data values are not stored in contiguous memory locations. Image viewer applications can use linked lists to let users go from one image to the next in chronological order. These images dont need to be stored in contiguous locations, but each one needs to point to the next so that users can scroll through the album.

Arrays are simple data structures which store the same types of data values in contiguous locations. Imagine you want to run every day and store your daily distance in a data structure. In that case, you could use an array to store the distance for each day and access previous entries easily.

**Read Also: How To Land A Job Interview **

## Google Software Engineer Interview Questions On Binary Tree

- Explain how a binary search tree is implemented.
- How do you traverse a given binary tree in preorder without recursion?
- How do the leaves of a binary search tree get printed?
- How will you perform a binary search in a given array?
- How are the leaf nodes in a given binary tree counted?

As all data canât just be represented in the linear data structure, this is where the tree data structure comes into play. When solving binary tree questions while preparing for a Google software engineer interview, having a good grasp of the theoretical concepts is vital.

## How Does A Selection Sort Work For An Array

The selection sort is a fairly intuitive sorting algorithm, though not necessarily efficient. In this process, the smallest element is first located and switched with the element at subscript zero, thereby placing the smallest element in the first position.

The smallest element remaining in the subarray is then located next to subscripts 1 through n-1 and switched with the element at subscript 1, thereby placing the second smallest element in the second position. The steps are repeated in the same manner till the last element.

**You May Like: What Questions To Ask During A Phone Interview **

## What Are The Applications Of Graph Data Structure

- Transport grids where stations are represented as vertices and routes as the edges of the graph
- Utility graphs of power or water, where vertices are connection points and edge the wires or pipes connecting them
- Social network graphs to determine the flow of information and hotspots
- Neural networks where vertices represent neurons and edge the synapses between them

## Write A Function To Convert An Infix Expression To Postfix Expression

**Output:**abcd^*+

int prec public: // Function to convert an infix expression to a postfix expression. string infixToPostfix st.pop } // If an operator is scanned else } st.push } } // Pop all the remaining elements from the stack while ) return result }

**Time Complexity:**O**Space Complexity:**O

**You May Like: Best Platform To Prepare For Coding Interview **

## What Is An Asymptotic Analysis Of An Algorithm

Asymptotic analysis is the technique of determining an algorithm’s running time in mathematical units to determine the program’s limits, also known as “run-time performance.” The purpose is to identify the best case, worst case, and average-case times for completing a particular activity. While not a deep learning training technique, Asymptotic analysis is an essential diagnostic tool for programmers to analyze an algorithm’s efficiency rather than its correctness.

#### Free Course: Programming Fundamentals

## What Are Binary Trees

A binary tree is a tree data structure made up of nodes, each of which has two offspring, known as the left and right nodes. The tree begins with a single node called the root.

Each node in the tree carries the following information:

Data

A pointing device indicates the left kid.

An arrow pointing to the correct child

**Don’t Miss: What Questions To Ask An Employer At Interview **

## Q10 Explain Slicing In Python

Slicing is the mechanism to choose a range of items from sequence types such as lists, tuples, and strings. For example, slicing a list refers to selecting a specific portion or a subset of the list for some function, and the rest of the list remains unaffected. So, you remove a piece without altering the rest of the contents.

The syntax for slicing a list is: List_name

## What Are Asymptotic Notations

Asymptotic Notation represents an algorithm’s running time – how long an algorithm takes with a given input, n. Big O, large Theta , and big Omega are the three distinct notations. When the running time is the same in all circumstances, big- is used, big-O for the worst-case running time, and big- for the best case running time.

**Also Check: How To Interview A Babysitter Or Nanny **

## Write A Function To Find The Maximum For Each And Every Contiguous Subarray Of Size K

**Input:**N = 9, K = 3 arr =**Explanation**: In the first subarray of size 3: , the value 3 is maximum, similarly for all such subarrays for size 3.

//function to find maximum in each subarray using sliding window approachvector< int> max_of_subarrays vector< int> ans while j++ while& & arr< =arr) dq.pop_back dq.push_back } ans.push_back return ans }

**Time Complexity:**O

## What Is The Difference Between The Breadth First Search And Depth First Search

Breadth First Search | |
---|---|

DFS necessitates less memory. | |

Nodes that have been traversed multiple times are removed from the queue. | When there are no more nodes to visit, the visited nodes are added to the stack and then removed. |

Backtracking is not an option in BFS. | The DFS algorithm is a recursive algorithm that employs the concept of backtracking. |

It is based on the FIFO principle . | It is based on the LIFO principle . |

**Also Check: Where Can I Watch Prince Harry Interview With Oprah **