ServiceNow
20+ Tau's Cafe And Lassi Bar Interview Questions and Answers
Q1. Given a container and 3 shapes of balls small , medium , large using each type of ball at least once how do you fit these balls so that the space wasted is minimized he was looking for a programmatic way of sol...
read moreProgrammatically fit small, medium, and large balls in a container to minimize wasted space.
Start by calculating the volume of the container.
Calculate the volume of each type of ball.
Use a loop to try all possible combinations of balls.
Calculate the total volume of each combination and keep track of the one with the least wasted space.
Return the combination with the least wasted space.
Q2. If a variable is protected in parent class and another variable with same name with public is declared in child class is this allowed is the reverse also allowed and how would you access parents variable in chi...
read moreYes, it is allowed. Access parent's variable using 'super' keyword.
Child class can have a variable with the same name as parent's protected variable.
Access parent's variable in child class using 'super' keyword.
Reverse is not allowed i.e. parent cannot have a public variable with the same name as child's protected variable.
Q3. There are 9 balls one ball is lighter out of them and we have a balance how would you find lighter ball in 2 weightings? (I told i knew this question so he moved on)
Find the lighter ball among 9 balls in 2 weightings using a balance.
Divide the balls into 3 groups of 3 each.
Weigh any 2 groups against each other.
If they balance, the lighter ball is in the third group.
If they don't balance, the lighter ball is in the lighter group.
Take 2 balls from the lighter group and weigh them against each other.
If they balance, the lighter ball is the remaining one.
If they don't balance, the lighter ball is the lighter one.
Q4. what is the difference between microprocessor and microcontroler ? give an example for each and what is intel i7 ?
Q5. How do we find count of numbers between (a,b) both inclusive with no consecutive ones in the binary representation? They asked me 3 different approaches for this problem
Count numbers between (a,b) with no consecutive ones in binary representation.
Use dynamic programming to count numbers with no consecutive ones.
Calculate count of numbers with no consecutive ones up to b and a-1.
Subtract the counts to get the final answer.
Q6. Difference between abstract class and interface what is the problem if I use abstract class when there are no implemented methods?
Abstract class can have implemented methods, interface cannot. Using abstract class without implemented methods is unnecessary.
Abstract class can have constructors, fields, and implemented methods, while interface cannot.
Abstract class can be used to provide default implementations for methods that subclasses can override.
Interface is used to define a contract that implementing classes must follow.
Using abstract class without implemented methods is unnecessary and can be repl...read more
Q7. In a circularly linked list how would you ensure at least one node is left always even if you remove all the nodes ?
To ensure at least one node is left in a circularly linked list, we can use a sentinel node.
Create a sentinel node and point it to the last node in the list.
When removing a node, check if it is the last node. If it is, remove it and point the sentinel node to the new last node.
If all nodes are removed, the sentinel node will still be present.
Example: If we have a circularly linked list with nodes A, B, and C, we can create a sentinel node S and point it to C. If we remove nod...read more
Q8. How to reduce the time of booting of the processor where we have no control on hardware devices but can only modify software (he was looking for more points here)?
To reduce booting time of processor with no control on hardware, modify software by disabling unnecessary services and programs.
Disable unnecessary services and programs
Optimize startup programs
Remove malware and viruses
Update drivers and software
Defragment hard drive
Q9. Detecting a loop in a singly linked list what are the stopping condition if there is no loop?
Stopping conditions for detecting a loop in a singly linked list if there is no loop.
If the current node or the next node is null, then there is no loop.
If the current node is the last node in the list, then there is no loop.
If the list has only one node, then there is no loop.
Q10. difference between functional and oo approach of problem solving . why oops is best
Q11. Difference between object oriented programming, functional programming, logic programming ?
Object-oriented programming focuses on objects and their interactions, functional programming emphasizes on functions and their composition, and logic programming uses logical rules to solve problems.
Object-oriented programming uses classes and objects to encapsulate data and behavior.
Functional programming uses pure functions and immutable data to avoid side effects.
Logic programming uses logical rules and constraints to solve problems.
Examples of object-oriented programming...read more
Q12. Executable Code to Detect a Loop in a Singly Linked List without any mistake in first time with all boundry cases if any
Use Floyd's Cycle Detection Algorithm to detect a loop in a singly linked list.
Use two pointers, one moving at twice the speed of the other.
If there is a loop, the two pointers will eventually meet.
Handle boundary cases like an empty list or a list with only one node.
Q13. Space and time complexity to “Detecting a Loop in a Singly Linked List ”
Space complexity O(1), time complexity O(n)
Traverse the linked list using two pointers, one moving one step at a time and the other moving two steps at a time
If there is a loop, the two pointers will eventually meet at the same node
Space complexity is O(1) as only two pointers are used, time complexity is O(n) as worst case is traversing the entire list
Q14. Design a system for putting newspapers using classes and functions taking different aspects into account
Q15. Find product of each element of an array except that element in O(N) time complexity without using / operation
Q16. Median of 2 sorted arrays in O(log N) time complexity and O(1) space complexity
Use binary search to find the median of two sorted arrays in O(log N) time complexity and O(1) space complexity.
Use binary search to partition both arrays into two halves
Ensure that elements on the left side of the partition are smaller than elements on the right side
Calculate the median based on the partitioned arrays
Q17. Shortest path between 2 points in 2-D space in O(log N) time
Using Dijkstra's algorithm, the shortest path between 2 points in 2-D space can be found in O(log N) time.
Dijkstra's algorithm is a popular algorithm for finding the shortest path between nodes in a graph.
In a 2-D space, the points can be represented as nodes in a graph with edges connecting them.
By applying Dijkstra's algorithm to this graph, the shortest path between the 2 points can be determined efficiently.
Example: Given points A(0,0) and B(3,4), the shortest path betwee...read more
Q18. Reverse level order traversal of a tree using Queue
Reverse level order traversal of a tree using Queue
Start by pushing the root node into a queue
While the queue is not empty, dequeue a node, push its children into the queue, and add the node to a stack
Once the queue is empty, pop elements from the stack to get the reverse level order traversal
Q19. Level order traversal of a tree using Queue
Level order traversal of a tree using Queue
Create an empty queue and enqueue the root node
While the queue is not empty, dequeue a node and print its value
Enqueue the left and right child nodes of the dequeued node
Continue this process until the queue is empty
Q20. Program to convert a given number into words
A program to convert a given number into words.
Use a switch statement or if-else conditions to handle different cases for each digit
Break down the number into individual digits and convert each digit into its corresponding word
Handle special cases like numbers between 10 and 19 separately
Consider adding support for negative numbers and decimal places if required
Q21. Recursively deleting linked list from end
To recursively delete a linked list from the end, traverse to the end of the list and delete nodes one by one.
Start by recursively moving to the end of the linked list
Delete the last node and update the previous node's next pointer to null
Repeat the process until the entire linked list is deleted
Q22. Difference between Floyd Warshall and Djikstra
Q23. what is microcontroller ?
A microcontroller is a small computer on a single integrated circuit that contains a processor core, memory, and programmable input/output peripherals.
Microcontrollers are used in various applications such as embedded systems, robotics, and automation.
They are designed to execute specific tasks and are often used in devices that require real-time control.
Examples of microcontrollers include Arduino boards, PIC microcontrollers, and STM32 microcontrollers.
Q24. what is microprocessor ?
Q25. Strings Anagram in O(1) space complexity
Check if two strings are anagrams by sorting and comparing them
Sort both strings and compare if they are equal
Use a hashmap to count characters in each string and compare the counts
Q26. Recursively deleting linked list
Recursively delete a linked list by freeing memory of each node
Create a recursive function to delete nodes one by one
Update the next pointer of each node to NULL after freeing memory
Base case should be when the current node is NULL
Q27. BFS and DFS Difference
BFS and DFS are two popular graph traversal algorithms with different approaches.
BFS explores nodes level by level, while DFS explores nodes depth by depth.
BFS uses a queue data structure, while DFS uses a stack or recursion.
BFS is optimal for finding shortest paths, while DFS is more memory efficient.
Example: BFS is used in finding the shortest path in a maze, while DFS is used in topological sorting.
Q28. Recursively deleting from end
Recursively delete elements from the end of an array
Start by checking if the array is empty, if so return the array as is
If the array is not empty, recursively call the function with a smaller array each time
Base case: when the array is empty, return an empty array
Q29. Recursively deleting tree
Recursively deleting a tree involves deleting all nodes starting from the leaves up to the root.
Start by deleting all child nodes of a parent node before deleting the parent node itself.
Use a recursive function to traverse the tree and delete nodes in a bottom-up manner.
Ensure to properly handle memory deallocation to avoid memory leaks.
Top HR Questions asked in Tau's Cafe And Lassi Bar
Interview Process at Tau's Cafe And Lassi Bar
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month