Add office photos
Engaged Employer

Amazon

4.1
based on 25k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by

30+ Tetra Pak Interview Questions and Answers

Updated 17 Oct 2024
Popular Designations

Q1. pid ={3,5,0,1} ppid ={5,4,2,2} process id(pid) ppid=parent process id let us say the process that we killed is 2 now we have to print 2,0,1 as 0,1 are child of 2 and suppose that if we have children for this 0,...

read more
Ans.

Given a list of process IDs and their corresponding parent process IDs, print the IDs of all processes that are children of a specific process ID, and recursively kill all their children.

  • Iterate through the list of process IDs and parent process IDs

  • Check if the current process ID is the one to be killed

  • If yes, recursively find and print all its children

  • If a child has further children, recursively kill them as well

View 1 answer

Q2. N queen problem with problem statement and dry running of code with 4 queens and then writing the code

Ans.

N queen problem is to place N queens on an NxN chessboard without any two queens threatening each other.

  • The problem can be solved using backtracking algorithm

  • Start with placing a queen in the first row and move to the next row

  • If no safe position is found, backtrack to the previous row and try a different position

  • Repeat until all queens are placed or no safe position is found

  • Code can be written in any programming language

  • Example: https://www.geeksforgeeks.org/n-queen-problem-b...read more

Add your answer

Q3. Sub set problem(Check if there exists any sub array with given sum in the array ) . But the thing here is that we have to do it with space complexity of only O( 1 K ) . K is the sum given .

Ans.

Check if there exists any sub array with given sum in the array with O(1K) space complexity.

  • Use two pointers to traverse the array and maintain a current sum.

  • If the current sum is greater than the given sum, move the left pointer.

  • If the current sum is less than the given sum, move the right pointer.

  • If the current sum is equal to the given sum, return true.

View 1 answer

Q4. What is the difference between references and pointers

Ans.

References and pointers are both used to access memory locations, but references cannot be null and cannot be reassigned.

  • Pointers can be null and can be reassigned to point to different memory locations.

  • References are automatically dereferenced, while pointers need to be explicitly dereferenced.

  • Pointers can perform arithmetic operations, while references cannot.

  • Example: int x = 5; int *ptr = &x; int &ref = x;

  • Example: int *ptr = nullptr; int &ref = x; // not allowed

View 1 answer
Discover Tetra Pak interview dos and don'ts from real experiences

Q5. what is difference between reference variable and actual reference

Ans.

A reference variable is a variable that holds the memory address of an object, while an actual reference is the object itself.

  • A reference variable is declared with a specific type and can only refer to objects of that type.

  • An actual reference is the object itself, which can be accessed and manipulated using the reference variable.

  • Changing the value of a reference variable does not affect the original object, but changing the value of an actual reference does.

  • Reference variabl...read more

Add your answer

Q6. What happens when we type an URL

Ans.

When we type an URL, the browser sends a request to the server hosting the website and retrieves the corresponding webpage.

  • The browser parses the URL to extract the protocol, domain, and path.

  • It resolves the domain name to an IP address using DNS.

  • The browser establishes a TCP connection with the server.

  • It sends an HTTP request to the server.

  • The server processes the request and sends back an HTTP response.

  • The browser receives the response and renders the webpage.

View 2 more answers
Are these interview questions helpful?

Q7. What is indexing in DBMS How do we maintain it

Ans.

Indexing in DBMS is a technique to improve query performance by creating a data structure that allows faster data retrieval.

  • Indexing is used to speed up data retrieval operations in a database.

  • It involves creating a separate data structure that maps the values of a specific column to their corresponding records.

  • This data structure is called an index.

  • Indexes are typically created on columns that are frequently used in search conditions or join operations.

  • Maintaining an index i...read more

Add your answer

Q8. find the height of the tree when the leaf nodes are connected with each other

Ans.

The height of the tree can be found by counting the number of edges from the root to the farthest leaf node.

  • Count the number of edges from the root to the farthest leaf node

  • This will give the height of the tree

  • Example: If the farthest leaf node is 4 edges away from the root, the height of the tree is 4

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. What is caching? explain in detail.

Ans.

Caching is the process of storing frequently accessed data in a temporary storage to improve performance.

  • Caching improves performance by reducing the need to fetch data from the original source.

  • It involves storing data in a temporary storage, such as memory or disk, closer to the user or application.

  • Caching can be done at various levels, including browser caching, server-side caching, and database caching.

  • Examples of caching include caching web pages, caching database query r...read more

View 1 answer

Q10. AVL trees with examples and their balancing

Ans.

AVL trees are self-balancing binary search trees. They maintain a balance factor to ensure height balance.

  • AVL trees are named after their inventors, Adelson-Velsky and Landis.

  • They are height-balanced, meaning the difference in height between left and right subtrees is at most 1.

  • Insertion and deletion operations may cause imbalance, which is corrected by rotations.

  • AVL trees have a worst-case time complexity of O(log n) for search, insertion, and deletion.

  • Example: Inserting 5, ...read more

View 1 answer

Q11. Implementation of LRU (WIth Production level code)

Ans.

Implementation of LRU cache using a doubly linked list and a hash map.

  • LRU (Least Recently Used) cache is a data structure that stores a fixed number of items and evicts the least recently used item when the cache is full.

  • To implement LRU cache, we can use a doubly linked list to maintain the order of items based on their usage frequency.

  • We can also use a hash map to store the key-value pairs for quick access and retrieval.

  • When a new item is accessed, it is moved to the front ...read more

Add your answer

Q12. what is NP hardness .

Ans.

NP hardness refers to the difficulty of solving a problem in non-deterministic polynomial time.

  • NP-hard problems are some of the most difficult problems in computer science.

  • They cannot be solved in polynomial time by any known algorithm.

  • Examples include the traveling salesman problem and the knapsack problem.

View 1 answer

Q13. B trees , B+ trees with examples

Ans.

B trees and B+ trees are data structures used for efficient storage and retrieval of data in databases.

  • B trees are balanced trees with a variable number of child nodes per parent node. They are commonly used in databases to store large amounts of data.

  • B+ trees are a variant of B trees where all data is stored in the leaf nodes, and the internal nodes only contain keys. They are commonly used in databases for indexing.

  • B+ trees are more efficient than B trees for range queries ...read more

Add your answer

Q14. 1. Find the contiguous sub array with max sum 2. Find the median of an array sorting is involved

Ans.

Interview question on finding max sum contiguous subarray and median of array with sorting involved.

  • For finding max sum contiguous subarray, use Kadane's algorithm which has O(n) time complexity.

  • For finding median of array, sort the array and then find the middle element or average of middle two elements.

  • If the array is too large to sort, use quickselect algorithm to find the kth smallest element in O(n) time.

Add your answer

Q15. connect n ropes with minimum cost(priority queue question)

Ans.

Connect n ropes with minimum cost using priority queue

  • Create a priority queue and insert all the ropes into it

  • Pop the two smallest ropes from the queue and connect them

  • Insert the new rope into the queue and repeat until only one rope remains

  • The cost of connecting two ropes is the sum of their lengths

  • Time complexity: O(nlogn)

  • Example: Ropes of lengths 4, 3, 2, and 6 can be connected with a cost of 29

Add your answer

Q16. First non repeating character in continuous character stream

Ans.

Find the first non-repeating character in a continuous character stream.

  • Use a hash table to keep track of character frequency.

  • Iterate through the stream and check if the current character has a frequency of 1.

  • If yes, return the character as the first non-repeating character.

  • If no non-repeating character is found, return null or a default value.

View 1 answer

Q17. Leet code medium of array and dp

Ans.

Dynamic programming problem involving arrays of strings.

  • Use dynamic programming to efficiently solve problems by breaking them down into smaller subproblems.

  • Consider using a 2D array to store intermediate results for optimal substructure.

  • Examples: Longest Common Subsequence, Word Break, Minimum Path Sum.

Add your answer

Q18. You are given a family tree, and a node, you have to print all the nodes on the same level as it.

Ans.

Given a node in a family tree, print all nodes on the same level.

  • Traverse the tree level by level using BFS

  • Keep track of the level of each node while traversing

  • Print all nodes with the same level as the given node

  • Example: If the given node is 'John', print all his siblings and cousins

Add your answer

Q19. Find missing number in array without extra space

Ans.

Find missing number in array without extra space

  • Iterate through the array and XOR all the elements with their indices and the actual numbers

  • The missing number will be the XOR result

  • Example: ['1', '2', '4', '5'] -> XOR(0, 1) ^ XOR(1, 2) ^ XOR(2, 4) ^ XOR(3, 5) = 3

Add your answer

Q20. Explain one machine learning algorithm.

Ans.

Random Forest is a machine learning algorithm that builds multiple decision trees and combines their outputs.

  • Random Forest is an ensemble learning method.

  • It builds multiple decision trees and combines their outputs to make a final prediction.

  • It is used for both classification and regression tasks.

  • It is less prone to overfitting compared to a single decision tree.

  • It can handle missing values and outliers.

  • Example: predicting whether a customer will buy a product based on their ...read more

Add your answer

Q21. Algorithm for string attachment

Ans.

String attachment algorithm joins two strings together.

  • Create a new string variable to hold the result

  • Loop through the first string and add each character to the new string

  • Loop through the second string and add each character to the new string

  • Return the new string

Add your answer

Q22. How to use set in javascript

Ans.

Sets in JavaScript are used to store unique values of any type.

  • Create a new set using the Set constructor

  • Add values to the set using the add() method

  • Check if a value exists in the set using the has() method

  • Remove a value from the set using the delete() method

  • Iterate over the set using the forEach() method

Add your answer

Q23. What are POST requests?

Ans.

POST requests are a type of HTTP request method used to submit data to a server.

  • POST requests are used to create or update resources on a server.

  • They are commonly used in web forms to submit user input data.

  • POST requests have a request body that contains the data being submitted.

  • They are different from GET requests, which are used to retrieve data from a server.

  • POST requests are more secure than GET requests because the data is not visible in the URL.

Add your answer

Q24. 2 variable variation of LIS

Ans.

2 variable variation of LIS

  • The problem involves finding the longest increasing subsequence in two arrays

  • Dynamic programming can be used to solve the problem

  • The time complexity of the solution is O(n^2)

  • Example: Given two arrays [1, 3, 5, 4] and [2, 4, 3, 5], the longest increasing subsequence is [3, 5]

  • Example: Given two arrays [10, 22, 9, 33, 21, 50, 41, 60] and [5, 24, 39, 60, 15, 28, 27, 40], the longest increasing subsequence is [10, 22, 33, 50, 60]

View 1 answer

Q25. Search in rotated sorted array

Ans.

Search for an element in a rotated sorted array.

  • Use binary search to find the pivot point where the array is rotated.

  • Compare the target element with the first element of the array to determine which half to search.

  • Perform binary search on the selected half to find the target element.

  • Time complexity: O(log n), Space complexity: O(1).

View 1 answer

Q26. intrsection point in linked list

Ans.

Finding the intersection point of two linked lists.

  • Traverse both lists and find their lengths

  • Move the head of the longer list by the difference in lengths

  • Traverse both lists simultaneously until they meet at the intersection point

Add your answer

Q27. Multiply one matrix with another

Ans.

Matrix multiplication involves multiplying the elements of one matrix with another matrix.

  • Create two matrices with compatible dimensions

  • Multiply corresponding elements of each row in the first matrix with each column in the second matrix

  • Sum the products to get the resulting matrix

Add your answer

Q28. find middle of linkedlist add 2 numbers

Ans.

To find the middle of a linked list, use two pointers - one moving twice as fast as the other. To add two numbers, traverse both lists simultaneously and add corresponding digits.

  • Use two pointers to find the middle of the linked list - one moving twice as fast as the other

  • To add two numbers represented by linked lists, traverse both lists simultaneously and add corresponding digits

  • If the sum of two digits is greater than 9, carry over the 1 to the next digit

Add your answer

Q29. path sum between two tree node

Ans.

Calculate the sum of all paths between two nodes in a binary tree.

  • Traverse the tree and keep track of the path and its sum from the root to the current node.

  • When the target nodes are found, calculate the sum of all paths between them by adding the path sums of their common ancestor.

  • Recursively traverse the left and right subtrees to find the target nodes.

  • Use a hash table to store the path sums of each node for efficient lookup.

  • Time complexity: O(n), Space complexity: O(n).

Add your answer

Q30. What is linked list?

Ans.

A linked list is a linear data structure where elements are stored in nodes with each node pointing to the next node in the sequence.

  • Consists of nodes connected by pointers

  • Does not have a fixed size like arrays

  • Can easily insert or delete elements without shifting other elements

  • Examples: Singly linked list, Doubly linked list, Circular linked list

Add your answer

Q31. final element in rotated array

Ans.

Find the final element in a rotated array.

  • Identify the pivot point where the array was rotated.

  • Determine if the target element is in the first or second half of the array.

  • Use binary search to find the target element.

Add your answer

Q32. Implement Heap in C++

Ans.

Implementing Heap data structure in C++

  • Use an array to represent the binary tree structure of the heap

  • Implement functions for inserting elements, deleting elements, and heapifying the array

  • Ensure that the heap property is maintained (parent node is always greater than or equal to its children)

Add your answer

Q33. Largest common ancestor

Ans.

Largest common ancestor is the most recent node that is a common ancestor of two or more nodes in a tree.

  • It is commonly used in computer science and genealogy.

  • In genealogy, it refers to the most recent common ancestor of two or more individuals.

  • In computer science, it is used in algorithms for finding the lowest common ancestor of two nodes in a tree.

  • It can be found using various algorithms such as Tarjan's off-line least common ancestors algorithm and the binary lifting algo...read more

Add your answer

Q34. Rain water trapping Problem

Ans.

Rain water trapping problem refers to the accumulation of rainwater in low-lying areas or on flat roofs.

  • The problem can be solved by installing rainwater harvesting systems.

  • Proper drainage systems can also prevent rainwater trapping.

  • Green roofs and permeable pavements can help absorb rainwater.

  • Rain gardens can be created to collect and filter rainwater.

  • Regular maintenance of gutters and downspouts can prevent clogging and overflow.

  • The problem can lead to water damage, mold gr...read more

Add your answer

Q35. Mountain array in a array.

Ans.

A mountain array in an array refers to an array where the elements form a peak and then descend.

  • The array should have a peak element and then the elements should descend on both sides.

  • For example, [1, 3, 5, 4, 2] is a mountain array in an array.

  • However, [1, 2, 3, 4, 5] is not a mountain array in an array.

Add your answer

Q36. Median in a running stream.

Ans.

Finding the median in a running stream of data.

  • The median is the middle value in a sorted list of numbers.

  • In a running stream, we cannot sort the data beforehand.

  • We can use a min-heap and a max-heap to keep track of the median.

  • As new data comes in, we add it to the appropriate heap and balance the heaps.

  • The median is then the top element of the larger heap or the average of the top elements of both heaps.

Add your answer

Q37. reorder Linked list

Ans.

Reorder a linked list in place.

  • Use two pointers to find the middle of the list

  • Reverse the second half of the list

  • Merge the two halves of the list

Add your answer

Q38. Implement LRU Cache

Ans.

LRU Cache is a data structure that stores a fixed number of items and removes the least recently used item when the cache is full.

  • Use a combination of a doubly linked list and a hashmap to efficiently implement LRU Cache.

  • Keep track of the least recently used item at the tail of the linked list.

  • When an item is accessed, move it to the head of the linked list to mark it as the most recently used item.

  • When adding a new item, check if the cache is full. If so, remove the tail ite...read more

Add your answer

More about working at Amazon

Top Rated Mega Company - 2024
Top Rated Company for Women - 2024
Top Rated Internet/Product Company - 2024
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Tetra Pak

based on 14 interviews
4 Interview rounds
Resume Shortlist Round
Coding Test Round
Technical Round - 1
Technical Round - 2
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Sde1 Interview Questions from Similar Companies

3.5
 • 18 Interview Questions
4.1
 • 11 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter