C/C++ :: Analysis And Evaluation Algorithms?

Mar 25, 2015

#include <iostream>
#include <vector>
#include <list>

[Code].....

The problem is it's not finding the shortest path.

View 1 Replies


ADVERTISEMENT

Visual C++ :: Analysis And Evaluation Algorithms

Mar 25, 2015

Undirected graph G = {V, E} is given by the list next to the DS. Let u, v of V. Construction of two paths algorithm A1 (u, v) and A2 (u, v) such that no edge in common and have the shortest total length.

View 1 Replies View Related

C++ :: GPA Evaluation System Through Array

Jun 2, 2013

Computerized GPA Evaluation System using Array

You are required develop a computerized GPA evaluation system of your class using array. The basic idea is to calculate the GPA (Grade Point Average) of each subject and then calculate the GPA of whole semester of all the students of the class and on the basis of that GPA calculate the grade and remarks of each student of the class. Suppose that the total students of the class are 50. Your system must also provide the facility of the following:

1.Searching a student result according to his/her roll number.
2.Updating the obtained marks of the students in case of any mistake in entering marks.
3.Display the result of student who is the topper of the class
4.Display the result of the student who got minimum CGPA out of the class.
5.Display how many number of students got greater than or equal to 3.0 CGPA.
6.Display how many number of students got greater than or equal to 2.00CGPA and less than 3.00.
7.Display the total number of students who got A grade in the semester.
8.Display the total number of students who got B grade in the semester.
9.Display the total number of students who got C grade in the semester.
10.Display the total number of students who got F grade in the semester.

Detailed Description:
You are required to take the student’s marks for four subjects (Programming fundamentals, Calculus, English and Computing) as input from the user at runtime. After that calculate the GPA of each subject and the whole semester. Assume that total marks of a subject are 100 and each subject is of 3 credit hours except programming fundamentals. Programming fundamentals subject has 4 credit hours.

Complete Assessment system is given below in the table:

S.#Percentage (%)GradeGPARemarks
185-100A4Excellent
280-84A-3.75Very Good
375-79B+3.50Good
470-74B3.0Satisfactory
565-69C+2.50Above Average
660-64C2.0Average
755-59D+1.50Pass
850-54D1.0Just Pass
9Below 50F0Fail

Table: Assessment Scheme
•Percentage of a subject = (obtained marks / total marks) * 100. Percentage works to find the grade of the student.
•GPA of whole semester = multiply GPA of each subject according to the percentage of obtained marks by the number of credit hours for that course, sum up the GPA of all the subjects, and then divide this sum by the total number of credit hours taken in semester.

For example suppose the GPA in subject X is 2.5, in subject Y 2.6, and in subject Z is 3. Assuming that each subject is of 3 credit hours then GPA of whole semester will be calculated as:
GPA= (3 * (2.5 + 2.6 + 3)) / 9
GPA= 2.7

On the basis of Semester GPA, you have to give grade and remarks to the student. You have to study the above table for other types of remarks according to grade.

•If a student has less than 50 marks in a subject, a message should display that “you have to repeat this subject “.

Code:

#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
main() {

char a,b,c,d;

[Code] .....

View 6 Replies View Related

C++ :: Order Of Expression Evaluation In If Statement

Jul 28, 2012

This feels to me like a relatively "deep" C syntax question. Reviewing K&R reveals some interesting, related specifications, but I could not nail this down. The issue is, What determines the order in which expressions are evaluated in an if() statement? Now, K&R gives details with regard to the precedence of operator evaluation, but otherwise I could find only 2 sections detailing the order of expression evaluation (I mention these below). A simple code example demonstrates why this is a burning question to me:

Code:
int checkit(int* pi, BOOL bHavePosValue) {
if ((NULL != pi) && *pi > 0) {
bHavePosValue = TRUE;
return (*pi);}
bHavePosValue = FALSE;
return (0);}

So what if pi is passed in NULL? Is it possible for the *pi expression to be evaluated Before the (NULL != pi) expression? If so, you could have an access fault. If not, what rule of C ensures left-to-right evaluation? Is this a simple case of the left-to-right associativity that K&R shows on page 49 (in the table of operator precedence) for the && operator? Or is there some more general rule that applies?

The two mentions in K&R I did find are that function argument evaluation order is Not defined (pg 86). Also, beyond the order specified in the reference section for operators, they state there is no other defined order. In particular, they state:

"Expressions involving a commutative and associative operator (*, +, &, |, ^) may be rearranged arbitrarily, even in the presence of parentheses; "

That surprised me! I suppose the point is that compiler-made changes in this case cannot change the result. I wonder whether this or other similar rules in C were superseded in C++ ?

In a similar vein, what about the expression evaluation order for the for(,,) statement - does it have guaranteed left-to-right order?

View 2 Replies View Related

C :: Textual Analysis - Pattern Matching

Feb 11, 2014

I am looking to write a program that, given a particular word, looks at a plain text document and gives a list of words that appear within x words of the given word along with a count of how many times it appears.

Do I need to use regex to do the pattern matching here? Is there a particular data structure that I should use that is particularly suited to a task like this? I don't want to reinvent the wheel, it seems like there should be libraries that would already do this sort of thing but searches have turned up nothing.

View 5 Replies View Related

C++ :: Some Algorithms For Compressing Images?

Feb 16, 2014

RLE(Run Length Encoding)
using namespace std;
class Bitwriter{
private:

[Code]....

View 1 Replies View Related

C++ :: Floating Point Numbers / Numerical Analysis

Oct 30, 2013

I have the problem of trying to find the smallest natural number that makes two consecutive terms in single precision floating point notation in the riemann zeta function equal. So basically the riemann function of 2 is given by:

sum of 1/(k^2) from k=1 until infinity, so : 1/(1^2) + 1/(2^2) + 1/(3^2) + ...... until infinity.

Now the question asks to stop at the smallest natural number n, at which the sum 1/1^2 + 1/2^2 + ......+ 1/(n^2) is equal to the sum 1/1^2 + 1/2^2 + ..... + 1/((n+1)^2) in single precision floating point notation.

Now well the obvious way to look for n would be on this way:

float i = 1.0;
float n = 1/(i);
float n1 = 1/(i+1.0);
while ( n != n1){
i += 1.0;
n = 1/i;
n1 = 1/(i+1.0);}

But first of all this is obviously completely inefficient and I dont think it will yield a valid answer for any float variable, i.e. I dont think the sum until 1/n^2 and 1/(n+1)^2 will ever differ. I tried it out with the largest possible value of a variable of type float and the values were still seen as unequal in C++. How to do this? Will C++ find a value for n for which the condition holds? Is the compiler or my hardware important for this, i.e. would I get different results on a different pc?

View 2 Replies View Related

C :: Time Scheduling Algorithms Program

Jan 20, 2014

I am an IT college student and this is a self-assigned project i have done in an attempt to learn programming in C AND at the same time how time scheduling of an OS works (Both done in order to prepare for upcoming semester exams) using FCFS ,SJF, RR and PS algorithms (planning on adding SRT too sometime soon). (took me 9 hours total work time including validations). What i wanna know is from more seasoned coders if i am on the right track. *cross fingers*

Code:

#include <stdio.h>
#include <stdlib.h>
#define P_Q 1000

int main(int argc, char *argv[])
{
float min_value,
}

[code]....

View 11 Replies View Related

C++ :: Text Editor Printing Algorithms?

Mar 26, 2013

They should apply for: backspace, return, regular char input, vertical scrolling. There is only one buffer, and it is not allowed to side scroll past max col, instead it must scroll down, appending the line cur_y + 1.

View 4 Replies View Related

C/C++ :: Sorting Algorithms And Comparison Count

Jan 30, 2014

I am trying to count the number of comparisons for each of the following sorting algorithms, Selection, Insertion, Bubble, Merge, and Quick sort. This is using an array of numbers that are sorted, reversed, and randomly arranged.

I currently increment the "number of comparison" variable before every conditional statement that compares two numbers and am getting the following results:

Number of Items in Array = 100
Selection: random = 5049; reverse = 5049; sorted = 5049;
Insertion: random = 2640; reverse = 5049; sorted = 99;
Bubble: random = 9207; reverse = 9900; sorted = 99;
Merge: random = 1221; revere = 988; sorted = 1028;
Quick: random = 690; revere = 587; sorted = 636;

View 1 Replies View Related

C++ :: Library (Eigen / Boost) To Calculate Principle Component Analysis (PCA)?

Mar 4, 2013

I have a text file which consists of 907 objects and 1000 feature vector for each object. Is there any Library (Eigen/Boost) to calculate Principle Component Analysis(PCA)?

View 1 Replies View Related

C/C++ :: Statistical Analysis Of Vector Data Set Of Integers - Frequency Distribution?

Feb 16, 2014

I am working on my second c++ project that is a statistical analysis of a vector data set of integers. I created a struct called range with a maximum value, minimum value and count for occurrence. The frequencies are stored in a vector<range>.

I have tried messing around with the increment to get the high range test above the maximum element, though my ranges cumulatively increase by 9.9. I'm not sure how the professor's program has the distance between high and low ranges as 10 instead of 9.9, which is the increment. I'm also unsure why half way through his buckets, the ranges appear as 9.99 briefly and then return to 10 after (40.00 - 49.99 then 49.99 - 59.99). I feel like I am missing something very obvious on line 04 or 10 in my code.

Here is the code for the frequency that accepts a vector reference for my data set of integers.

void frequency(vector<int>& data_set){
double max = findMax(data_set);
double min = findMin(data_set);
double increment = (max - min) / 10;
double percentage = 0.0;

[Code] ....

View 1 Replies View Related

C++ :: Multi-level Algorithms For Date-driven Scheduling

Apr 18, 2012

What is Multi-level algorithms for date-driven scheduling?

View 8 Replies View Related

C++ :: Analysis Of Discrete Wavelet Transform - Modifying For Loop To Make It Faster

Aug 25, 2014

I have this code which performs the analysis part of discrete wavelet transform. It works pretty well. However, I wish to reduce the time that it consumes even further. I did use reserve() and it worked upto few msec.

int rows = signal.size();
int cols = signal[0].size();
int cols_lp1 =(int) ceil( (double) cols / 2);
vector<vector<double> > lp_dn1(rows, vector<double>(cols_lp1));
vector<double> temp_row;
temp_row.reserve(512);

[Code] ....

View 5 Replies View Related

C++ :: Output Compiled Script Into Binary File - Scripting Tool Algorithms

Dec 25, 2014

I am working on a script compiler that must output compiled script into binary file. Compiling etc is not a problem. The problem is detecting some specific cases. Nothing seems to work. If it works, then it breaks as soon as i modify the script.

Here is example "script1":

Code:
1VAR1 c1 = 44
2VAR2 c2 = 66
3beginscript
4if(c1=44)
5do_nothing

[Code] ....

Second example "script2", when there can be also some command between ENDIF and ENDIF. In this case: do_nothing command.

Code:
1VAR1 c1 = 44
2VAR2 c2 = 66
3beginscript
4if(c1=44)
5do_nothing

[Code] ....

The INDEXES before each line are not in actual script. They are just to point YOU to specific lines. Although the INDEXes are in compiled script!! This is very important. As you see there can be simple IF_ENDIF and nested (more complex) IF_ENDIF.

i.e IF_ENDIF inside another IF_ENDIF.

There are also IF_ELSE_ENDIF and some other ones, but im trying to make simple IF_ENDIF work first.

ENDIF is "SPECIAL" command, the IF, DO_NOTHING are "usual" commands.

"Usual" commands must always jump over(!) the ENDIF. ALWAYS!!

They must "ignore" them!

One strong RULE is like this for usual commands: always jump over any ENDIF, not matter what. If there is one, two or more ENDIF's in a row, then just jump over them to the closest NEXT usual block command. If there is some "usual" block command between multiple ENDIFs, then jump to this command and this command must therefore check whats next command right after it. And do the same: check if next command is ENDIF, if yes, jump over it, until "usual" block command is found.

This is the place im stuck. When i some time ago thinked about some ideas, i saw some patterns. One of them was that: Seems like if its nested IF_ENDIF, then every usual block command jumps out of it, i.e. right after the final ENDIF of this current nested IF_ENDIF.

But as soon as i added do_nothing between the two ENDIFs the so called "pattern" broke. In script2 above you see index 11 is do_nothing. Ok its in nested IF_ENDIF it should jump out to command index 17. But no, because there is do_nothing between index 13 and 16. If we jump out at index 11, the command 14 would never execute. This is a BIG NO. One idea i was thinking and trying was to use STL::FIND, STL::FIND_IF to find next "usual" command after specific index. But my code seems to crash sometimes and not work always.

Code:
bool NextNonENDIF(int i) {
return (i!=98);
}
int findNextBlockCmd(vector<int>&vec, int curidx)

[Code] ....

Here i pass him the vector that contains all the command TYPES in current script. Each command has its own TYPE or better called unique ID in which way compiler knows what is what. So in this case im trying to find a command thats NOT "ENDIF", in other words im trying to find next usual command after specific type of command. Lets just say the TYPE or unique ID of do_nothing is 555, im trying to find it.

How i should continue with this? What to use maybe stl::stack, some custom command indexing, some sort of labelling for usual commands in nested IF_ENDIFs or what?

In general, look script2, and i ask: There is index 11, this guy should look if there is any usual block command left for him before the final ENDIF at index 16. If there is, jump to it. If there is none, jump out of this nested IF_ENDIF to index 17.

Question: how to do it? What algorithms to use? I can use STL, BOOST, whatever. And i can use C++11.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved