Add office photos
Employer?
Claim Account for FREE

Carwale

3.4
based on 157 Reviews
Filter interviews by

20+ BSM Ship Management Company Interview Questions and Answers

Updated 5 Feb 2024
Popular Designations

Q1. A string is given consisting of lowercase alphabets. Write a function which returns yes if the string has all the lowercase letters appearing in it at least once. O(N) time and without using extra space

Ans.

Function to check if a string has all lowercase letters appearing at least once without extra space in O(N) time.

  • Create a boolean array of size 26 to keep track of the occurrence of each letter.

  • Iterate through the string and mark the corresponding index in the array as true.

  • Check if all the elements in the array are true and return yes if so.

  • Alternatively, use a bit vector to keep track of the occurrence of each letter.

View 2 more answers

Q2. Given a balance and 100 coins;out of which,one is heavier. Find minimum number of weighing required to find out heavier coin?

Ans.

Find minimum number of weighings required to find the heavier coin out of 100 coins with a balance.

  • Divide the coins into 3 groups of 33 each and weigh 2 groups against each other.

  • If one group is heavier, divide it into 3 groups of 11 each and weigh 2 groups against each other.

  • Repeat the process until the heavier coin is found.

  • Minimum number of weighings required is 4.

Add your answer

Q3. Delete nodes in linkedlist which have a greater value on right side?

Ans.

Delete nodes in linkedlist with greater value on right side

  • Traverse the linked list from right to left

  • Compare each node with the maximum value seen so far

  • If the current node has a greater value, delete it

  • Update the maximum value seen so far

Add your answer

Q4. Explain priority scheduling (preemptive , non-preemptive). Explain a case when a low priority process will preempt a high priority process

Ans.

Priority scheduling is a scheduling algorithm where processes are assigned priorities and executed based on their priority level.

  • Preemptive priority scheduling allows a higher priority process to interrupt a lower priority process that is currently running.

  • Non-preemptive priority scheduling allows a higher priority process to wait until the lower priority process finishes executing.

  • A low priority process can preempt a high priority process if the high priority process is wait...read more

Add your answer
Discover BSM Ship Management Company interview dos and don'ts from real experiences

Q5. Make 24 using 8, 8, 3, 3 using + = / * ( ) .

Ans.

Make 24 using 8, 8, 3, 3 using + = / * ( )

  • Use multiplication to get 8*3=24

  • Add the remaining 8 to get 32

  • Divide by the remaining 3 to get 10.67

  • Subtract the other 3 to get 7.67

  • Multiply by the remaining 3 to get 23.01

  • Add the remaining 8 to get 31.01

  • Divide by the remaining 8 to get 3.88

  • Add the other 3 to get 6.88

  • Multiply by the remaining 3 to get 20.64

  • Add the other 8 to get 28.64

View 1 answer

Q6. What is runtime polymorphism and compile time polymorphism? Difference between them?

Ans.

Runtime polymorphism is when the method to be executed is determined at runtime, while compile-time polymorphism is determined at compile-time.

  • Runtime polymorphism is achieved through method overriding.

  • Compile-time polymorphism is achieved through method overloading.

  • Runtime polymorphism is also known as dynamic polymorphism.

  • Compile-time polymorphism is also known as static polymorphism.

  • Runtime polymorphism is associated with inheritance.

  • Compile-time polymorphism is associated...read more

Add your answer
Are these interview questions helpful?

Q7. Given an array of size 98 and it has natural numbers from 1-100 but 2 numbers are missing. find them

Ans.

Given an array of size 98 with natural numbers from 1-100 but 2 numbers are missing, find them.

  • Calculate the sum of all numbers from 1-100 using the formula n(n+1)/2

  • Calculate the sum of all numbers in the array

  • Subtract the sum of array from the sum of all numbers to get the sum of missing numbers

  • Find the missing numbers by iterating through the array and checking which numbers are not present

Add your answer

Q8. Develop tic-tac-toe game and write code using concepts of OOPS in CPP. (Initially told me to include artificial intelligence also but was later satisfied without it

Ans.

Develop tic-tac-toe game using OOPS concepts in CPP.

  • Create a class for the game board

  • Create a class for the players

  • Create a class for the game logic

  • Use inheritance and polymorphism for game objects

  • Implement functions for checking win/lose/draw conditions

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

Q9. Delete nodes in a linked list which have greater value on right side

Ans.

Delete nodes in a linked list which have greater value on right side

  • Traverse the linked list and compare each node with its right side node

  • If the current node's value is less than its right side node, delete the current node

  • Repeat the process until the end of the linked list is reached

Add your answer

Q10. Now implement one extra funtion called max() with give the maximum of all elements in the above stack with optimized time and space complexity?

Ans.

Implement max() function to find the maximum element in a stack with optimized time and space complexity.

  • Use an additional stack to keep track of the maximum element at each step.

  • When pushing an element onto the stack, compare it with the top element of the maximum stack and push the larger one.

  • When popping an element from the stack, also pop the top element from the maximum stack if they are equal.

  • The top element of the maximum stack will always be the maximum element in the...read more

Add your answer

Q11. What is inheritance? What are diffence types of inheritance?

Ans.

Inheritance is a mechanism in object-oriented programming where a class inherits properties and behaviors from another class.

  • Inheritance allows code reuse and promotes code organization.

  • There are different types of inheritance: single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance, and hybrid inheritance.

  • Single inheritance involves a class inheriting from a single base class.

  • Multiple inheritance involves a class inheriting from multiple ba...read more

Add your answer

Q12. In the above question calculate sum of only even numbers of fibonaaci series?

Ans.

The sum of even numbers in the Fibonacci series is calculated.

  • Generate the Fibonacci series up to a given limit

  • Iterate through the series and check if each number is even

  • If the number is even, add it to the sum

  • Return the sum of the even numbers

Add your answer

Q13. Find all permutations of a given string. (Not in lexicographic order)

Ans.

Find all permutations of a given string.

  • Use recursion to swap each character with every other character in the string.

  • Repeat the process for each substring.

  • Add the permutation to an array.

Add your answer

Q14. Difference between Methods and Constructors.(At least five)

Ans.

Methods are functions that perform a specific task, while constructors are special methods that initialize objects.

  • Constructors have the same name as the class they belong to.

  • Constructors are called automatically when an object is created.

  • Constructors can be overloaded with different parameters.

  • Methods can be called multiple times with different arguments.

  • Methods can have a return type, while constructors do not.

Add your answer

Q15. What is OOP? Describe its properties?

Ans.

OOP is a programming paradigm that organizes code into objects with properties and behaviors.

  • OOP stands for Object-Oriented Programming.

  • It focuses on creating reusable code by organizing it into objects.

  • Objects have properties (attributes) and behaviors (methods).

  • Encapsulation, inheritance, and polymorphism are key principles of OOP.

  • Example: In Java, a class represents an object with its properties and methods.

Add your answer

Q16. What are stacks and its properties?

Ans.

Stacks are a data structure that follows the Last-In-First-Out (LIFO) principle.

  • Stacks have two main operations: push (adds an element to the top) and pop (removes the top element).

  • Stacks can be implemented using arrays or linked lists.

  • Common applications of stacks include function call stack, undo/redo operations, and expression evaluation.

  • Example: A stack of books, where the last book placed is the first one to be removed.

Add your answer

Q17. Print fibonaaci series less than equal to 1000?

Ans.

Print Fibonacci series less than or equal to 1000.

  • Start with two variables, a and b, initialized to 0 and 1 respectively.

  • Print a and update a to the value of b, and b to the sum of the previous a and b.

  • Repeat until a exceeds 1000.

Add your answer

Q18. Convert a given number to its hexadecimal form

Ans.

Convert a number to its hexadecimal form

  • Use the built-in function to convert the number to hexadecimal

  • Alternatively, use the algorithm to convert the number to hexadecimal manually

  • Ensure to handle negative numbers appropriately

Add your answer

Q19. Explain singleton class and write code for it.

Ans.

Singleton class is a class that can only have one instance at a time.

  • Singleton pattern is used when we need to ensure that only one instance of a class is created and that instance can be accessed globally.

  • The constructor of a singleton class is always private to prevent direct instantiation.

  • A static method is used to access the singleton instance.

  • Example: public class Singleton { private static Singleton instance = new Singleton(); private Singleton() {} public static Single...read more

Add your answer

Q20. Detect and remove cycle in a linked list

Ans.

Detect and remove cycle in a linked list

  • Use two pointers, one slow and one fast, to detect a cycle

  • Once a cycle is detected, move one pointer to the head and iterate both pointers until they meet again

  • Set the next node of the last node in the cycle to null to remove the cycle

Add your answer

Q21. Check if given tree is BST or not?

Ans.

Check if given tree is BST or not

  • A binary tree is a BST if the value of each node is greater than all the values in its left subtree and less than all the values in its right subtree

  • Perform an in-order traversal of the tree and check if the values are in ascending order

  • Alternatively, for each node, check if its value is within the range defined by its left and right subtrees

Add your answer

Q22. Fnd if a binary tree is bst or not

Ans.

Check if a binary tree is a binary search tree or not.

  • Traverse the tree in-order and check if the elements are in sorted order.

  • Check if the left child is less than the parent and the right child is greater than the parent.

  • Use recursion to check if all the subtrees are BSTs.

  • Maintain a range for each node and check if the node value is within that range.

Add your answer

Q23. What are virtual functions?

Ans.

Virtual functions are functions in a base class that can be overridden by derived classes to provide different implementations.

  • Virtual functions are declared in a base class and can be overridden in derived classes.

  • They allow polymorphism, where a pointer to a base class can invoke different derived class implementations.

  • Virtual functions are resolved at runtime based on the actual object type.

  • They are used to achieve runtime polymorphism and dynamic binding.

Add your answer

Q24. What is abstract class?

Ans.

An abstract class is a class that cannot be instantiated and is meant to be subclassed.

  • An abstract class can have both abstract and non-abstract methods.

  • It can provide a common interface for its subclasses.

  • Subclasses of an abstract class must implement all the abstract methods.

  • Abstract classes can have constructors.

  • An abstract class cannot be instantiated directly, but its subclasses can be.

Add your answer

Q25. Write code for reversing the linked list

Ans.

Code for reversing a linked list

  • Create a new empty linked list

  • Traverse the original linked list and insert each node at the beginning of the new list

  • Return the new list

Add your answer

Q26. Explain Prims and Kruskal’s algorithms

Ans.

Prims and Kruskal's algorithms are used to find the minimum spanning tree in a graph.

  • Prims algorithm starts with a single vertex and adds the minimum weight edge to the tree until all vertices are included.

  • Kruskal's algorithm starts with all vertices as separate trees and merges them by adding the minimum weight edge until all vertices are included.

  • Both algorithms have a time complexity of O(E log V) where E is the number of edges and V is the number of vertices.

  • Prims algorit...read more

Add your answer
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top SDE (Software Development Engineer) Interview Questions from Similar Companies

4.1
 • 10 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