Commit bc2c042d authored by Eky's avatar Eky

Week 4 work!

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>week4</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=14
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=14
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=14
module week4 {
requires java.desktop;
}
\ No newline at end of file
Procedure FREQ
{
array; //instantiate array
mostFreq = array[0]; //initial value of most frequent element set to first element
tempValue = 0; //temporary variable used to compare elements
freqCount = 1; //frequency of previous element checked
tempCount; //temporary variable to track frequency of current element
for(i=0 to i < array.length)
{
tempValue = array[i]; //set tempValue to current element in loop for comparison
tempCount = 0; //set tempCount (and reset to 0 between loops)
for(j=0 to j<array.length)
{
if(tempValue = array[j] //whenever there is a match in elements, increment tempCount
{
tempCount = tempCount + 1;
}
}
if(tempCount > freqCount) //compare previous loop's result with current stored freqCount, if greater then:
{
mostFreq = tempValue; //set the most frequent value to that of the element being analysed
freqCount = tempCount; //set number of times element in question appears to that of tempCount
}
}
return mostFreq;
}
[Using coins, one can place a paper clip under the first in the sequence for every other coin in the sequence of the same value
(including the first), this sets the first 'count' for the number of coins of this value. This can then be repeated with the
next coin in the sequence; remove the smallest pile of paper clips each time this is done. Once one reaches the end of the
sequence, the most frequently occurring value will simply be the coin with paper clips beneath it (as all others will have been
removed)]
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment