From StackOverflow,
---
fgets() can decode UTF-8 encoded files if you use Visual Studio 2005 and
up. Change your code like this:
infile = fopen(inname, r, ccs=UTF-8);
On Sat, Nov 23, 2013 at 8:25 PM, Nishant Pandey
nishant.bits.me...@gmail.com wrote:
Q) *C
should be (a) - (b) -(c)
now to convert into tree as you have mentioned above you have to
remove edge (b)-(c).
so output will be (a)-(b) or (a)-(c)
which is wrong.
On 5/12/13, Karthikeyan V.B kartmu...@gmail.com wrote:
@atul anand : acyclic graph can be converted to a tree using prim/kruskal
will work if given graph is a binary tree.
problem can be solved using dfs as suggested above
On 5/11/13, Karthikeyan V.B kartmu...@gmail.com wrote:
Since it is an acyclic graph, find the appropriate node that can be the
root of this tree.
Now apply the logic to find the diameter
Since it is an acyclic graph, find the appropriate node that can be the
root of this tree.
Now apply the logic to find the diameter of the tree here, which finds the
longest path in the graph as follows:
int diameter(Tree * t) { if (t == 0) return 0; int lheight =
height(tree-left); int rheight
Assuming the BST is balanced,
1.Convert BST to Sorted Doubly-Linked list in-place
2.have two pointers start and end at head and tail of the list
repeat until start-data + end-data == sum
increment start if start-data + end-data sum
decrement end if start-data + end-data sum
3.print the values
int main()
{
int n=10;
coutEnter the value of n:;
cinn;
int i=0;
ifstream file(C:\\Users\\kvb\\Desktop\\sample.txt);
string line;
string buffer[n];
if(file.is_open())
{
while(file.good())
{
getline(file,line);
O/p will not be 0.
1.00 is the result which when read as %d takes the decimal value of
float 1.00 stored in memory - it will not be 1.00 or 0.
Since float is not stored as direct binary in memory as integer is stored,
instead there's a separate procedure for storing float as binary
@Aditya :
Since km and we need the element that apears exactly k times, i think u
need to find the smallest number in the array and the corresponding index
is the number that is repeated most number of times.
--
You received this message because you are subscribed to the Google Groups
Assuming that u can either move down or right,
Using Dynamic Programming,
a DP equation can be framed like this : Paths[i][j] = paths[i][j-1] +
paths[i-1][j]
By filling the entire matrix, result will be in Paths[m-1][n-1].
--
You received this message because you are subscribed to the Google
Assuming that : all numbers of the array range from [0,n-1] n being the
size of the array
Copy array A to B
Make all integers negative
Scan the array while B[B[i]] = B[B[i]] + n
Now scan the array for the smallest non-negative element : element of
original array having the index of the
Hello ,
In the next 3 minute you will
Help Solve the Water Crisis
LET'S GO:
https://waterforward.charitywater.org/4ZT6ToxZ
- the charity: water team
WaterForward, 387 Tehama Street, San Francisco, CA 94103, USA.
Click here to unsubscribe:
There are a couple of advantages :
1. efficiently determine the predecessor and successor nodes starting from
any node.
2. Any node can be accessible from any other node.
Many problems on tree use recursion / stack to solve
But if the same problem when solved using threaded binary tree gives a
Hi,
Use hashing, but with perfect hashing which does all these operations in
O(1).
Refer to Introduction to Algorithms by CLRS to learn about perfect hashing.
--
Merge pairs of rows until u get a single row, while merging remove the
duplicates
--
Hi,
Result of A U B has 5 tuples and C has 2 tuples.
condition is either A.Id 40 or C.Id 15
First consider C.Id 15 : 1 tuple from C satisies this condition
Hence join this 1 tuple with 5 tuples of A U B = 5 new tuples
A.Id 40 yields 2 tuples from A U B - join this with the remaining tuple
Find the number of intersections for a ray passing from the exterior of the
polygon to the point needed.
If odd, the point lies inside the polygon.
If even, the point lies outside the polygon.
On Thu, Dec 6, 2012 at 3:54 AM, Don dondod...@gmail.com wrote:
Given a simple polygon (specified by
@navin and @atul:
inorder traversal without recursion and stack can be done using Morris
traversal in O(1) space.
Refer the following link for Morris traversal
http://www.geeksforgeeks.org/archives/6358
now the problem takes O(n) time and O(1) space.
--
You received this message because you
Hi,
4 sections time 2 hrs
Basic Aptitude - Quants, Data interpretation
English - comprehension,verbal,etc.
Basics of computer - OS,DS,DBMS
Advanced computers - Advanced Data Structures
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post
A network of N computers is such that each computer is connected to every
other.Transferring one byte of information between two computers takes one
unit of time. In the beginning, a file resides on only one computer on the
network. The size of the file is M bytes. Come up with a strategy to
Hi,
Section A - objective type 10 technical questions in OS,Algorithms,DS,C.
each carries one mark. no negative marks
Section B - coding 2 questions
first was very simple
second - spiral level order traversal of a BST
--
You received this message because you are subscribed to the Google Groups
calculate the balance factor for all nodes and find any node with factor
1 or factor -1 and perform AVL rotation from that node
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
Tries
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
Complexity : O(n^3)
import java.util.*;
public class Solution {
public ArrayListArrayListInteger fourSum(int[] num, int target) {
// Start typing your Java solution below
// DO NOT write main() function
ArrayListArrayListInteger arr=new ArrayListArrayListInteger();
Arrays.sort(num);
int
Hi all,
Generate combinations (taken k out of n) of a given string
Eg: Input : abcd
Output:
abc
acd
abd
bcd
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from
It does not return a valid address.
The result of malloc(0) is implementation defined and therefore unreliable.
Some compiler implementations will cause it to return a NULL pointer,
others may return some other value (but it still can't/shouldn't be used to
access memory).
The memory cannot be
Hi,
k-way merge procedure of external sorting should be applied
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Hi,
bool issymmetric(node* root)
{
return ismirror(root,root);
}
bool ismirror(node* root1,node* root2)
{
if(!root1 || !root2) return root1==NULL root2==NULL;
return root1-data==root2-data ismirror(root1-left,root2-right)
ismirror(root1-right,root2-left);
}
--
You received this
Hi,
Hashing can be used.
Perfect/Universal hashing resolves collision and makes retrievals in
constant time.
for n elements it gives O(n)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Hi,
Regd OS,
1.deadlock
2.diff between linux, windows and solaris in terms of internals design
3.diff between mutex and semaphore
4.spin lock
5.interrupts
6.steps in page fault handling
6.steps involved in booting an os
7.what is kernel
8.paging segmentation
9.process scheduling algorithms
Hi,
Start from right top corner
If matrix element key move to previous column
else if matrix element key move to next row
int search(int** a,int key,int m,int n)
{
if (key a[0][0] || key a[m-1][n-1]) return 0;
int min=a[0][n-1],i=0,j=n-1;
while(i=m-1 j=0)
{
@Arun
This is the java program to execute the fsck cmd from java pgm...
If any problem pls let me know
//code
import java.io.*;
public class JavaRunCommand {
public static void main(String args[]) {
String s = null;
try {
Process p =
Hi,
The NameNode splits the job into several tasks and submits to the different
DataNode(i.e nodes) , the split size varies from 64KB to 128MB. The
NameNode assigns the data split to a datanod.
Namenode actually has a table to store the mappings of data node and block
stored in it.
it is
@bharat : hadoop has a* job tracker* which *resolves the dependencies*
and *splits
the job into blocks* and *assigns to datanodes*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
Hi,
use the following cmd on linux environment installed with hadoop stable api
fsck -blocks -files -locations
this cmd displays all the blocks - data node mappings.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
Hi,
PSG College Of Technology,Coimbatore and Dept Of CSE conducts a National
level technical symposium on Feb 25,26
Visit http://www.kruzade.org/
for more details
There are more brainstorming technical events too
Register asap...
Regards,
Karthikeyan.V.B
III yr CSE
PSG TECH
CBE
--
You
Hi,
The disjoint set data structure has FIND and UNION operations
for optimized versions of Find we use path compression and for union we use
union by rank,
which costs O(M log* n) , n is the input size and M the no. of makeset
opns.
log* n is inverse ackermann's function
Can anyone tell me
hi,
can anyone tell me how i can convert exe back to c source?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Hi,
sorry i mis-understood the problem
ll check and submit asap..
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Hi,
1.find the sum of the digits of the number
[acc. to fact that number+9 has the same sum of the digits as number]
2. for i=sum_of_the_digits_of_the_number; i=number; i=i+9
3.find if number is divisible by i then print it
code:
#includestdio.h
int sum_of_the_digits(int n)
{
if(n==0)
Hi,
Consider, arr1={1,2,3} and arr2={-1,-2,-3}
using sum of squares method sum(arr1) = 14 ans sum(arr2) = 14 (since square
of 1 and -1 is 1)
so it won work with this case
1.better take the square and negate it before adding
or
2.take sum of cubes
pls correct me if i'm wrong
Regards,
Hi,
I have learnt insertion using perfect hashing.
Can anyone pls provide me the pseudo code for delete and search operations
using perfect hashing?
Since it involves randomization , i don know how retrieval and delete can
take place?
Pls help me asap.
Thanks in advance
Regards,
Hi,
Using Backtracking,
void swap(char* x,char* y)
{
char temp;
temp=*x;
*x=*y;
*y=temp;
}
void permute(char* a,int i,int n)
{
int j;
if(i==n)
printf(%s\n,a);
else
{
for(j=i;j=n;j++)
{
swap((a+i),(a+j));
permute(a,i+1,n);
swap((a+i),(a+j));
}
}
}
But this takes O(n*n!) time
--
You received
Segregate even and odd psoitioned nodes in a linked list
Eg:
2-3-1-9-7-5
The output should be two separate lists
2-1-7
3-9-5
*My code is:*
void segregate(node* head)
{
int i=1;
node* sec=head-next;
node *odd=head,*even=head-next;
while(even)
{
if(i%2)
{
odd-next=even-next;
even-next=NULL;
Hi,
*int sum(int num1,int num2)
{
for(int i=0;inum2;i++)
num1++;
return num1;
}*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe
Hi,
Facebook is conducting a Programming challenge through which u could get
placed in it
Pls login to ur account and visit Careers at the bottom and click
Programming Challenge tab in it
It's about 1 to 2 hrs.
Some practise questions are also given...
Regards,
Karthikeyan.V.B
PSG TECH,
CBE
Trie data structure can be used...
In the trie, you can record item count in each node representing frequency
of word consisting of characters on the path from root to current node.
The time complexity to setup the trie is O(Ln) (where L is number of
characters in the longest item). To find the
Hi,
Actually i m sorry since i didn explain the algo fully
i checked with the code the o/p is:
run:
6:1
7:0
8:1
9:2
10:2
11:1
12:1
13:1
14:1
where sum 9 has two triplets
so,totally (1+0+1+2+2+1+1+1+1=10)
Regards,
KARTHIKEYAN.V.B
PSG TECH
CBE
--
You received this message because you are
Hi,
*TSUM:*
This is also a brute-force approach..
Pls correct me if i m wrong
Algorithm:
1.sort the array
2.find the sum of the three min elements - sum_min
3.find the sum of the three max elements - sum_max
4.for each value in [sum_min,sum_max]
binary search for the triplet
int
Hi!
Pls some problems related to linked list.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
Congratulations:)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit
detects the loop in the linked list
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For
Hi,
Create a binary search tree with elements , while inserting check for equal
elements and delete it.
But for insertion of n elements in a BST takes O(nlogn)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email
Find the set of anagrams from a file of english words
[Hint: anagrams are permutation of the word eg: ate , eat ,
tea are all anagrams]
in linear time and space.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
Hi,
Thanks a lot...
Regards,
Karrthikeyan
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
Hi,
Portability focuses on *adaptation of software* in various OS, by
recompiling the source to make the binary compatible with the target OS and
not necessarily modifying the source. If the source code strictly follows
POSIX standard less likely one end up modifying it.
Platform independence
Hi,
Find the highest and second highest element in an array in O(n) time
Input : arr[]={1,4,0,7,8,9}
Output : 9 and 8
Thanx in advance
Regards,
Karthikeyan
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
let no of boys be x and no of girls be y.
then,
x=y+1
2(y-1)=x
solving these we get x=4,y=3
so,x+y=7
there are 7 children.
am I right
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
+1
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at
This is the link for the book
*http://www.4shared.com/document/_Y7p3MLT/Head_First_Servlets_and_JSP.html*
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from
//use dynamic programming approach
//it is O(n) time and O(1) space
#includestdio.h
#define N 5
void main()
{
int a[N]={1,2,3,4,5},i;
int prod1[N];
int p=1;
for(i=0;iN;++i)
{
prod1[i]=p;
p*=a[i];
}
int prod2[N];
p=1;
for(i=N-1;i=0;--i)
{
prod2[i]=p;
p*=a[i];
}
int products[N];
reversing the linked list
static void reverse(struct node** head_ref)
{
struct node* p=NULL;
struct node* curr=*head_ref;
struct node* q;
while(curr!=NULL)
{
q=curr-next;
curr-next=p;
p=curr;
curr=q;
}
*head_ref=p;
}
--
You received this message because you are subscribed to the Google Groups
Hi
Can anyone say me which is the best hashing tecnicque which can store
duplicates and minimize time complexity?
Pls reply
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
use one queue
Enqueue all the nodes in normal level order traversal in the queue
as 1 2 3 4 5 6 7
Each level contains 2 to the power n nodes in the queue.
have two pointers ptr1 and ptr2
point ptr1 to the start node of 2 power n nodes range and ptr2 to the last
node of this range.
For odd
63 matches
Mail list logo