X
Submit Question

IBM  Questions

View By:

Q1 How to show different color for visited links?

You are developing a web browser and need to display all visited links on a page. The visited links need to use a different color then that used to display scheme than the unvisited links. Now, given a history of links you have visited before, how would you go about writing the piece of code that makes the determination if you have seen this link before? Answer or not? The answer could be a simple string comparison, but then think about the time it will take for the client to render any HTML page. Alternatively, so, given a history of URLs, come-up with an elegant way (algorithm, data structure, etc.) to make the determination if a given link already exits in the history list?

Hash Table  |  Level - 2

Answer Write Code Visit Question Page

Q2 What is the difference between Hash Map and Hash Table?

-> HashMap is not thread-safe while Hashtable is a thread-safe collection. -> HashMap is not synchronized it perform better than Hashtable. -> Hashtable is obsolete class and you should be using ConcurrentHashMap in place of Hashtable in Java.

Hash Table  |  Level - 1

Answer Write Code Visit Question Page

Q3 How to write a C function for unsigned power(double x, unsigned int n) using minimum number of multiplications?

Write a C function for unsigned power(double x, unsigned int n) using minimum number of

multiplications. Count the number of multiplications used.

Math & Computing  |  Level - 1

Answer Write Code Visit Question Page

Q4 A queue with constant time operations

Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.

Data Structure  |  Level - 2

Answer Write Code Visit Question Page

Q5 What is the minimum number of comparisons to find the maximum and the minimum.

You have given an array. Find the maximum and minimum numbers in less number of comparisons.

C++  |  Level - 1

Answer Write Code Visit Question Page

Q6 Find the next largest palindrome of a given number.

A palindrome number is of the format 1234321. Given a number x, find the smallest palindrome greater than x

C++  |  Level - 2

Answer Write Code Visit Question Page

Q7 The game of picking up coins alternately.

There are n coins in a line. (Assume n is even). Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger amount of money wins.
  1. Would you rather go first or second? Does it matter?

  2. Assume that you go first, describe an algorithm to compute the maximum amount of money you can win.

C++  |  Level - 2

Answer Write Code Visit Question Page