SAP
10+ Sreevari Enterprises Interview Questions and Answers
Q1. Multilevel Inheritance Implementation
Create a series of classes to demonstrate multilevel inheritance.
Explanation:
Create three classes to illustrate multilevel inheritance.
GrandFather
: This class should ha...read more
Demonstrate multilevel inheritance with classes GrandFather, Father, and Son with specific attributes and methods.
Create a class GrandFather with a parameterized constructor and attribute grandFatherName.
Create a class Father inheriting from GrandFather with an additional attribute fatherName.
Create a class Son inheriting from Father with an additional attribute sonName and a method printName to display all names in a specific format.
Ensure constructors initialize attributes ...read more
Q2. Reverse Linked List Problem Statement
Given a singly linked list of integers, return the head of the reversed linked list.
Example:
Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Reverse a singly linked list of integers and return the head of the reversed linked list.
Iterate through the linked list and reverse the pointers to point to the previous node.
Keep track of the current, previous, and next nodes while reversing the linked list.
Update the head of the reversed linked list as the last node encountered during reversal.
Q3. BFS Traversal in a Graph
Given an undirected and disconnected graph G(V, E) where V vertices are numbered from 0 to V-1, and E represents edges, your task is to output the BFS traversal starting from the 0th ve...read more
BFS traversal in a disconnected graph starting from vertex 0.
Implement BFS algorithm to traverse the graph starting from vertex 0.
Explore neighbor nodes first before moving to the next level neighbors.
Consider the bidirectional nature of edges in an undirected graph.
Output the BFS traversal sequence for each test case in a separate line.
Q4. Reverse the String Problem Statement
You are given a string STR
which contains alphabets, numbers, and special characters. Your task is to reverse the string.
Example:
Input:
STR = "abcde"
Output:
"edcba"
Input...read more
Reverse a given string containing alphabets, numbers, and special characters.
Iterate through the string from the end to the beginning and append each character to a new string.
Use built-in functions like reverse() or StringBuilder in languages like Python or Java for efficient reversal.
Handle special characters and numbers while reversing the string.
Ensure to consider the constraints provided in the problem statement.
Test your solution with different test cases to validate th...read more
Q5. Right View of Binary Tree
Given a binary tree of integers, your task is to output the right view of the tree.
The right view of a binary tree includes the nodes that are visible when the tree is observed from t...read more
The task is to output the right view of a binary tree, which includes the nodes visible when observed from the right.
Traverse the tree level by level and keep track of the rightmost node at each level.
Use a queue for level order traversal and a map to store the rightmost nodes.
Print the values of the rightmost nodes stored in the map as the right view of the tree.
Q6. Prime Numbers Identification
Given a positive integer N
, your task is to identify all prime numbers less than or equal to N
.
Explanation:
A prime number is a natural number greater than 1 that has no positive d...read more
Identify all prime numbers less than or equal to a given positive integer N.
Iterate from 2 to N and check if each number is prime
Use the Sieve of Eratosthenes algorithm for efficient prime number identification
Optimize by only checking up to the square root of N for divisors
Turn on one switch for a while, then turn it off and turn on another switch. One bulb will be on, one will be off, and one will be warm.
Turn on switch 1 for a few minutes, then turn it off.
Turn on switch 2 and enter the room with bulbs.
The bulb that is on corresponds to switch 2, the warm bulb corresponds to switch 1, and the off bulb corresponds to switch 3.
The minimum number of attempts needed is 14.
Start dropping the first egg from the 14th floor, then move up by one floor for each attempt until the first egg breaks.
Once the first egg breaks, use the second egg to test each floor starting from the last unbroken floor.
The worst-case scenario is dropping the first egg 14 times and the second egg 13 times, totaling 14 attempts.
Make one horizontal cut through the middle of the cake, then make two vertical cuts perpendicular to each other.
Make a horizontal cut through the middle of the cake to create two equal halves.
Make one vertical cut through the center of one of the halves.
Make another vertical cut through the center of the other half, perpendicular to the first cut.
You will end up with 8 equal pieces of cake.
Yes, I can design an ER diagram for an online shopping portal.
Entities: User, Product, Order, Payment, Cart
Relationships: User places Order, Order contains Product, Payment for Order, User has Cart
Attributes: User (id, name, email), Product (id, name, price), Order (id, date), Payment (id, amount)
BCNF is a normal form in database management systems that ensures all determinants are candidate keys.
BCNF stands for Boyce-Codd Normal Form.
It is a stricter version of 3NF (Third Normal Form).
In BCNF, every determinant must be a candidate key.
It helps in reducing redundancy and anomalies in the database.
Example: If a table has columns A, B, and C, and A determines B and B determines C, then it is not in BCNF unless A is a candidate key.
By burning one candle at both ends, you can calculate 45 minutes using only 2 candles.
Light one end of the first candle and both ends of the second candle simultaneously.
When the second candle burns out completely, 30 minutes have passed.
Light the other end of the first candle and let it burn. When it meets the first end, 15 minutes have passed.
C is a procedural programming language while C++ is an object-oriented programming language with features like classes and inheritance.
C is a procedural programming language, while C++ is a multi-paradigm language with support for object-oriented programming.
C does not support classes and objects, while C++ does.
C uses structures for data organization, while C++ uses classes.
C does not have features like inheritance and polymorphism, which are present in C++.
C++ allows functi...read more
Q14. remove node in linked list
To remove a node in a linked list, update the previous node's next pointer to skip the node to be removed.
Traverse the linked list to find the node to be removed
Update the previous node's next pointer to skip the node to be removed
Free the memory allocated to the node to be removed
Q15. design parking lot
Design a parking lot system with features like parking, retrieving, and displaying available spots.
Create a class for ParkingLot with attributes like total spots, available spots, and a list of parked vehicles.
Implement methods for parking a vehicle, retrieving a vehicle, and displaying available spots.
Consider using data structures like arrays or lists to manage parked vehicles and available spots.
More about working at SAP
Top HR Questions asked in Sreevari Enterprises
Interview Process at Sreevari Enterprises
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month