Analytical flow-chart - decide what number must be in a specified box [closed] - flowchart

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 am having a lot of trouble in solving the following flowchart question.
Could you please help me as soon as possible as i have interview tomorrow?
4th question in the following link
http://placement.freshersworld.com/placement-papers/ThoughtWorks/Placement-Paper-Whole-Testpaper-18522
I cant the question as it has some structures that wont display properly here.
Please go to the link.
Thanks,
Arjun

The answer would be "3", since you want to stop the flow when the number in box 3 is the same as the number in box 8.
EDIT
If we skip to the last iteration of the loop, the steps are
Subtract: 9 - 9. Put result into box 6
Change Instruction 1. Increase box 6 by 2 (To box 8)
Is Box 8 (because we changed it in step 2) equal to box 3?
if box 8 and box 3 are the same, you end the flow.

Related

How can i insert information to a text file in two separate columns? [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.
I'm trying to make a little "money manager" program that keeps track of my withdrawals and deposits each month. I would like to be able to write this information to a text file where i have one column for withdrawals and another for deposits. I think this would be easy if each withdrawal was accompanied with a deposit but that is not my case.
The reason i want to have the file formatted this way is so that when i tell the program to give me a full summary i can see my withdrawals on the left and my deposits on the right. I'm starting to think that a simple textfile is not what i want to use for this program. Should i try to use an excel spreadsheet or a table in an rdms?
Rather than display the raw file itself, you should read the file data into memory and display it in a UI Grid or ListView control that give you proper columns to work with. Don't try to format the data itself (I wouldn't use a text file this either, use a binary file), format the display of the data instead.
The way I would solve this is by storing the change to the account - positive values means money into the account, negative values taking money out of the account.
If you wish to show that in two columns, then you can display the it with more spaces for withdrawals than for deposits.
There are a few options I see:
Using an rdms
Almost always it is not necessary to create elaborate file formats if you can push it into an sqlite-database.
For your application I think you would use one table with the colums (enum {deposit or withdrawal}, int amount_in_cent, timestamp).
Using a csv-file
Writing a comma-separated file with "deposit,withdrawal,date" would be trivial. With a suitable program (awk) you can even print it with nice columns.
Using a tool made for the job
gnucash exists :-)
Pretty printed format
To expand on your proposal, you could specify one maximum amount (1 million dollars?) that you would move in one transaction and then separate the columns with 11 spaces (7 for the dollars, one for the comma, two for the cents and one for a trailing space). If you viewed that file as a text file, it would show pretty much what you want.
Ex.:
2.97 Cat food
10000.00 Salary

Challenge with the inverse of time [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'm assigned with creating the inverse of a program I wrote a program that gave me the total number of seconds
when I put in the hour minutes and seconds
(ex) 1hr28m42s=5322seconds
-now I need to make it so that when i put in the seconds it
tells me the time, (ex)9999seconds=2h46m39s
I've tried to google the inverse of numbers, but alot of results
just come up with the inverse of points or matrixes, i tried searching
on stackoverflow with the tag inverse but i dont know if im doing it right
if you guys have seen this question asked already im sorry and please
redirect me!
So far i only assigned variables for second coversion and not minutes and hours
but even that is no good, i could post my other code for my first ask converting
time into seconds if anything
How do I cap off an integer at a certain point so that it resets after?
(example) if x goes over 60 it goes back to 1? thanks guys
code so far:
//Assigned variables to distinguish time
int second = 1;
int minute = second + 59;
int hour = minute * 60;
int x; // x tells you the time
//Enters the seconds for conversion
System.out.println ("Enter the seconds to be converted: ");
second = scan.nextInt();
//This print tells you the above information in terms
//of total seconds capping off at 60
x = second + (second /60) + (second/60/60);
System.out.println ("The total time in seconds is " +x);
You want to approach it differently (at least using most programming languages).
You already know that going from 2 hours, 12 minutes and 5 seconds you take the number of seconds in 2 hours, add the number of seconds in 12 minutes and then add the last 5 seconds.
For the other way around you do it this way.
You start with 7925 seconds.
Check how many whole hours fits in this interval (2 hours).
Calculate how many seconds remains (725).
From the remaining seconds, check how many whole minutes fit in this interval (12).
Calculate the number of remaining seconds (5).
Now you are done and have 2 hours, 12 minutes and 5 seconds.

Bandwidth Consumption on a deeper level [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'm using an Ubuntu OS and I know one can get an average usage of bandwidth of a PC by reading the file /proc/net/dev file. However, suppose I'm transmitting files to two nodes at the same time (Total transmitting BW: 100 Mpbs). Can anyone suggest me a good idea how to get/store the information of 'Transmitting BW to Node X/Y" (X: 50 Mbps/ Y: 50 Mbps). Suggestions in C/C++ or python are highly appreciated! :)
The kernel doesn't ordinarily care beyond what the next hop for a packet is and what interface to drop it on to get it there. To make it care, you need some of linux's high-end routing capabilities. Try this:
DEV=`ip route|sed -nr 's/^default.* dev ([^ ]*).*/\1/p'`
/sbin/tc qdisc del dev $DEV root >/dev/null 2>&1
TQ="/sbin/tc qdisc add dev $DEV"
TC="/sbin/tc class add dev $DEV"
TF="/sbin/tc filter add dev $DEV"
$TQ root handle 1: htb default 0
$TC parent 1: classid 1:1 htb rate 100mbps # interesting destination 1
$TC parent 1: classid 1:2 htb rate 100mbps # ...
$TF parent 1: protocol ip u32 match ip dst 123.231.132.213 classid 1:1
$TF parent 1: protocol ip u32 match ip dst 1.2.3.4 classid 1:2
and then you can get stats with tc -s class show dev $DEV. I don't know an easier way to do this, sorry.
Have a look at the jnettop utility, either to get the information you need directly, or to find the appropriate techniques in its source code.

DataMining / Analyzing responses to Multiple Choice Questions in a survey [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a set of training data consisting of 20 multiple choice questions (A/B/C/D) answered by a hundred respondents. The answers are purely categorical and cannot be scaled to numerical values. 50 of these respondents were selected for free product trial. The selection process is not known. What interesting knowledge can be mined from this information?
The following is a list of what I have come up with so far-
A study of percentages (Example - Percentage of people who answered B on Qs.5 and got selected for free product trial)
Conditional probabilities (Example - What is the probability that a person will get selected for free product trial given that he answered B on Qs.5)
Naive Bayesian classifier (This can be used to predict whether a person will be selected or not for a given set of values for any subset of questions).
Can you think of any other interesting analysis or data-mining activities that can be performed?
The usual suspects like correlation can be eliminated as the response is not quantifiable/scoreable.
Is my approach correct?
It is kind of reverse engineering.
For each respondent, you have 20 answers and one label, which indicates whether this respondent gets the product trial or not.
You want to know which of the 20 questions are critical to give trial or not decision. I'd suggest you first build a decision tree model on the training data. And study the tree carefully to get some insights, e.g. the low level decision nodes contain most discriminant questions.
The answers can be made numeric for analysis purposes, example:
RespondentID IsSelected Q1AnsA Q1AnsB Q1AnsC Q1AnsD Q2AnsA...
12345 1 0 0 1 0 0
Use association analysis to see if there are patterns in the answers.
Q3AnsC + Q8AnsB -> IsSelected
Use classification (such as logistic regression or a decision tree) to model how users are selected.
Use clustering. Are there distinct groups of respondents? In what ways are they different? Use the "elbow" or scree method to determine the number of clusters.
Do you have other info about the respondents, such as demographics? Pivot table would be good in that case.
Is there missing data? Are there patterns in the way that people skipped questions?

Lost update in Concurrency control? [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 two transactions T and U which are executed simultaneously in a DB. How does one provide an example of the lost update problem?
We can assume that we have three accounts A,B,C and they each have £100,£200 and £300 respectively.
The "lost update" problem relates to concurrent reads and updates to data, in a system where readers do not block writers. It is not necessary for the transactions to be exactly simultaneous.
Session #1 reads Account A, gets 100.
Session #2 reads Account A, gets 100.
Session #2 updates Account A to 150 (+50) and commits.
Session #1 updates Account A to 120 (+20) and commits.
In this scenario, because Session #1 does not know that another session has already modified the account, the update by Session #2 is overwritten ("lost").
There are several ways to solve this, e.g. version numbers or before-and-after compares.
(3) Update Account A to 150 Where Account is 100 -> Account A is now 150
(4) Update Account A to 120 Where Account is 100 -> Update fail because account A is 150 and not 100
This occurs when two transactions that access the same database items have their operations interleaved in a way that makes the value of some database item incorrect.