One word-count per line [closed] - c

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Looking for pseudo code to help me figure this question out:
After processing the text file into your concordance you will print all of the words and their counts. Print one word-count pair per line.
So if the text file had two "and"s it would print and:2, not and:1, and:2.
count = 1;
if (*value > 1){ //finds all words repeated at least once
count++;
printf("%s:%d\n, word, count):
??

If the file is not big enough, you can store each word of the file in a hashtable which would store words as keys and their count as values. If there is a hash collision or the word is already in hash table, increment count else keep on adding new words into hash.

Related

How to implement Foulke's algorithm in C [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Foulke's algorithm is defined by
(In + U)2 = In+ U + U2
with:
In : the identity matrix
U : square adjacent matrix
I want to implement this algorithm in C by recurrence.
Any help is appreciated.
Your formula is wrong. Substitute U with identity matrix and you will see that the equality does not hold. You need to change it to (In + U)^2 = In+ 2*U + U^2. Just like numbers. Makes sense, huh?
Otherwise all you need to do is to implement a function that multiplies to two-dimensional matrices and returns the result in a two-dimensional array. I don't think using recursion for this problem is a good option.
I recommend you to use BLAS library. Or you want to make all yourself without any algebra-library?

Sorting with just one loop. Help me with its efficiency [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have came up with a new sorting algorithm with just one do while loop in it, but i don't
know how to calculate the efficiency of it in best,average and worst case so please help me in calculating it.
The loop starts with i=1 and the end condition for while loop is i<=n-2 and some times the value of i increases in the loop and some times i value will be decremented based on some condition.
I think i will better understand if u illustrate through simple examples.
please help me............
Thank you in advance for those who help me.....
some times i value will be decremented based on some condition
This vagueness makes it impossible to analyze. If the "condition" is always true and i is decremented to zero, then the loop runs forever. So based on what you say, the time complexity could be anything from Theta(n) to infinity.
The way to work out time complexity is to calculate (or put an upper bound on) the number of operations performed, as a function of n. "Operations" in the case of sorting usually means comparisons and copies/moves, but if your algorithm does anything unusual then of course that has to be included.

database design and algorithm for Public Transport? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
We want to implement Public Transport Guide for Android.
Inputs will be beginning and destination point. Outputs will be the directives that
tell how can be gone to the destination with using buses, subways,... e.c
This is not easy for big cities and we must have a well-designed database for quick answer. Tranport algorithm must give optimum lines to the passanger.
I wanna see your precious ideas for database and algorithm design.
Thank you very much for answers.
Most likely you will need a graph there to calculate shortest path.
Your graph will be G=(V,E) such that V = {all possible stations} and E = {(u,v) | there is a transport connecting station u to station v}.
If your graph cannot fit into memory [which is probably the case for a big city], you might want to make a function successors(u) = { v | (u,v) in E } which will allow you to calculate the graph on the fly.
In this older question there is some discussion how to efficiently find a path between two vertices in a dynamic environment similar to the one you are describing.

database size question [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
How much database space would you need to hold user information for 100,000 users?
That depends heavily upon what information you hold.
If it's a username, an MD5 of a password, and a few short fields, I'd say:
6 + 32 + 5 x 200 = 1,038 bytes ~ 1,040 bytes
So for 100,000 records, I'd say that:
1,040 x 100,000 = 104,000,000 ~ 100,000,000 bytes
Which is around 100 mb.
Not that much.
100,000 times the amount of database space you would need for 1 user.

How to Generate bit mask for a number from the number itself? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Is there any way with which I can generate bit mask of a number without changing the number itself?
I am new to programming and I have seen hard-coded bit-masks only.
Can we do any operations on the number to generate the bitmask, from the number itself (i.e.: a dynamically generated mask, depending the value of the number)
Thanks.
Why not? Use the number itself as a mask:
//returns true if bit n is 1 and false otherwise
bool get(int index, int mask)
{
return (mask >> index) & 1;
}

Resources