Topic — Add New » Posts Last Poster Freshness
[closed] Algorithms and Time Complexity 2 kartik 4 weeks

If you have an [b]array of n elements, how would you devise an O(n lg n) time algorithm for [/b]outputting a list of those elements that appear more than once in the original array.

Numeric puzzle 3 kartik 1 month

Given three strings X, Y and Z. Find all solutions to a numeric puzzle: X + Y = Z where each character in a string corresponds to some digit.
For simplicity, you may assume that strings are of the same length.
e.g.:
X = "abcd",
Y = "dbcc",
Z = "cdda"
hence we get:
2275 + 5277 = 7552

Largest Palindrome in a string - 2 23 1 month

How to find the largest palindrome in the string??

Power Set and Permutation of a set 5 1 month

Write a program to print power set of a given set

Largest Binary Search Tree in a given Binary Tree 9 Guddu Sharma 1 month

Given a binary tree, find the largest binary SEARCH tree in this binary tree.

When I mean largest, the tree with maximum number of nodes. And the binary search tree should be a sub-tree in the given binary tree.

Note: Not every binary tree is a binary search tree

prime number generator using seive algorithm 3 beginner0204 1 month

how to generate prime numbers using seive's algorithm in c???plzzz anybody ..help me out ..

Unfriendly Numbers 1 Red Lv 1 month

This is a problem from the website interviewstreet. And the direct brute search will certainly run out of the time limited. So I wonder is there anyone could think of a more efficient idea to solve this.After all, thank everyone involved in.

There is one friendly number and N unfriendly numbers. We want to find how many numbers are there which exactly divide the friendly number, but does not divide any of the unfriendly numbers.

Input Format:
The first line of input contai...

pairs of “ones” in a given integer 3 Guddu Sharma 1 month

Get the number of pairs of “ones” in a given integer. Eg: if the integer is 7 (binary: 0111), then the number of pairs of ones is 2.

finding ordered sequence 2 1 month

you have a set of N precedence relations of the form:
1. A > B
2. A > C
3. B > C
5. D > A

you can consider them to be a pair of two letters, with the first assumed greater than the second.
We have to print a sequence of letters such that if there is a relation say 'x' > 'y'
then 'x' should come before 'y'.
For the above example, it would be: D, A, B, C.
It is possible that many such sequences would exists, in that case outp...

How to find the duplicate number 3 Bablu 1 month

Suppose I have a file filled with number like 1,2,3,4,5,6,7,8,2 etc...
Assume there is only one duplicate in the file , how to find the duplicate number when we see our memory size has the limitation.

Assume : Input size is not more than 50 times of memory .
Which approach should I follow ?

Finding the strongly connect components of a digraph using C/C++? 1 CplusMan 1 month
 #include <iostream>
 using namespace std;

 const int n = 8;
 int G[][ n ] = { {0,0,0,1,0,0,0,0},
 {0,0,1,0,1,0,1,0},
 {1,0,0,0,0,0,1,0},
 {0,1,0,0,0,0,0,0},
 {0,0,0,1,0,0,0,0},
 {0,1,0,0,1,0,1,1},
 {0,0,0,0,0,0,0,0},
 {0,0,0,1,0,1,0,0} };

 int color[ n ], d[ n ], f[ n ], p[ n ], time;

 void DFS_visit( int u ) {
 // Your code here
 }

 void SCC() {
 // Your code here
 }

 // You may add other functions

 void main() {
 SCC();
 }
Time Complexity 2 kartik 1 month

how to calculate time and space complexity of a given program or an algoritm ??

Algorithm to remove duplicates from array 3 Aashish Barnwal 1 month

Write a program to remove duplicate elements from an array by printing them only once? What will be the minimum time and space complexity required for this program?

dynamic implementation using data structure 3 Aashish Barnwal 1 month

write a non recursive routine ancestor that points the ancestor of a given node whose info field contains a value.

Divide an array 5 Aashish Barnwal 1 month

Given an array of random real numbers sorted in descending order. Divide the array in 2 halves such that the sum of upper half is equal to or as close as possible to sum of lower half

How to Implement Kruskal Minimum Spanning tree. 2 1 month

You have given Number of vertex and information of all edges.

Phone Number 2 n22 2 months

You need to check that your friend, Bob, has your correct phone number. but you cannot ask him directly. You must write the question on a card and give it to Eve who will take the card to Bob and return the answer to you. What must you write on the card, besides the question, to ensure Bob can encode the message so that Eve cannot read your phone number?