database design and algorithm for Public Transport? [closed] - database

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.

Related

SQL Server Partitioining on Date field [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 9 years ago.
Need help - How to create partition in SQL server which will held 2011, 2012, 2013 data in separate file groups.
I'm struggling to understand between RANGE RIGHT or RANGE LEFT....
Please specify version of you sql server, and read this: http://msdn.microsoft.com/en-us/library/ms187802.aspx
As for RANGE LEFT/RIGHT difference and decision to choose one for datetime column (I'm assuming datetime, but what exactly is the type in your case?), the command would look like this for int type:
CREATE PARTITION FUNCTION OrderDateRangePFN(int)
AS
RANGE [LEFT | RIGHT] FOR VALUES (100,200,300)
When you use RANGE LEFT, the first partition will contain values <=100. With RANGE RIGHT it'll be <100, and that's the difference really (please note that also NULLs will be handled differently).
In your example, if you wish to create partition function on datetime column, with RANGE LEFT your boundary values would have to be specified like this:
('20111231 23:59:59.997','20121231 23:59:59.997','20131231 23:59:59.997')
With RANGE RIGHT it'll be more elegant and plain:
('20111231','20121231','20131231')

How to plan out a theatre using labels [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.
For a school project, we have to develop a theatre booking system, with a graphical representation of the theatre, which is labelled in a really annoying way. Our tutor said we should represent the theatre with a 2-d array of labels, but referencing each label to change the colour is tricky, say if the user booked seat 10,10 then that wouldn't be 10,10 in the array.
Does anyone know of any good methods of solving this? Because I am stumped.
Here is a link to the seating plan: http://i.stack.imgur.com/U14ut.png
I would suggest that you use an array of labels for each row. For example for row A create labels named lblRowA with indexes 1 to 14 and repeat for the other rows (having an array for each row). That should make it easy to map requests onto real world seating.
In addition to the 2-D array of labels, you can use two 2-D arrays of the same size, one for the row letter and one for number of each seat represented by the array of labels.
For example, for labels(4, 7) the seat number might be seatNumbers(4,7) and the row letter might be rowLetters(4,7).
If you know how (or can figure it out), you use one 2D array of a class or structure where each member contains the two values, and possibly reservation information, etc. In that case, you could address the seat information with something like seats(4,7).rowLetter, seats(4,7).seatNumber, and seats(4,7).reserved. You could also have a reference to the seat labels in the seats class.

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.

How to write a C program of two bodies exerting a gravitational force on each other? [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 've been set the following problem and don't have a clue how to start any help would be much appreciated.
In 2-D, read in the initial positions, velocities and masses of two bodies (suns, stars etc) . You will need to define suitable units for these. Then using the gravitational equation, calculate the force on each body from the other, and use Newton’s 3rd law to calculate the acceleration of that body. Generate a file with the positions of both bodies at each timestep for a long time period. Use this file to plot the paths of the two bodies.
Store the initial position, velocity and masses.
Calculate the magnitude and direction of the gravitational force.
Knowing the force, you can calculate the acceleration of each body.
Knowing the acceleration you can calculate the new velocity.
Knowing the velocity you can calculate the new position.
Using suitably small time steps you can get a reasonably good approximation to continuous motion.

Resources