The senario of my question is that one need to use a fixed size of array to keep track of certain number of "objects" .
The object here can be as simply as a integer or as complex as very fancy data structure. And "keep track" here means to allocate one object when other part of the app need one instance of object and recyle it for fut...
Okay so basically I'm trying to do a depth-first search for a mini-peg solitaire game. For those unfamiliar with the game it's pretty simple.
There's a board with 10 holes and 9 pegs, a peg is represented by a 1 and an empty spot by a 0. You can move a peg backwards or forwards two holes at a time (but you can only move to an empty ho...
Hi all,
I have my 2nd assignment for C++ class which includes Markov chains,
The assignment is simple but I'm not able to figure out what is the best implementation when reading chars from files
I have a file around 300k, one of the rules for the assignment is to use Map and Vector classes
in Map (key is only string) and values will be ...
I know you can use find command for this simple job. But I got an assignment not to use find or ls and do the job. Please help....
...
Hi.
I'm trying to solve the TSP with branch and bound algorithm.
I'm must bulid a matrix with cost but i have one big problem.
I have city with coordinates x and y.
The cost of travel is ceil(ceil(sqrt((x1-x2)^2+(y1-y2)^2))/v) + days in city.
V is speed.
Days in city depend from day when w come to city.
For example when we arrived on...
I need BFS and DFS sml code.
does anyone how should I write it?
...
I need to implement a digraph(Directed graph) in c++ as part of a homework and i'm having some issues with how to represent the vertices and edges data types.
Can anybody please point me to a example or a simple c++ class that implements this so i can study it and extend from there?
I've googled for a bit but i only found results abou...
Given an array of size n, I need to a write a function which deletes every mth element in the array till only one element exists in the array and return that value.
Can somebody just give me the hints?
...
I am trying to code a class that makes use of Push and Pop from a stack (with single linked list). I am not sure how to write the push and pop functions. Please help me, I really need a simple example written in Python with the following functions.
Push
Pop
ifEmpty
...
Proposed answer:
Strings are simply arrays of characters so the O-notation will be dependent on the number of characters in the string (if the loop depends on the length of the string). In this case the O-notation wouldn't be affected because the length of the string is a constant.
Any other ideas? Am I reading this question corre...
this is a magic square generator, but do not know C++, I have some difficulties to convert this code:
#include <vector>
#include <iostream>
using namespace std;
//There two series will be on even in case of magic square
// One of even order will be for multiple of 4
void BuildDoublyEvenMagicSquare(vector<vector<int> > &mat, int Order);
...
which of the followng statement can be used to identify alphanumeric patter?
A) a-zA-Z0-9/./,/-/\n
B) ^[a-zA-Z]
C) ^a-zA-Z
D) /^[a-zA-Z0-9/./,/-/\n]+$/
...
I've just completed the coding section of simple homework assignment for my C++ class. The second part of the assignment requires us to verify our code's input validation. (The program takes several different values as inputs from a user and prints those values to a file)
I was hoping that I could use bash script for this. Is there a...
I'm a student at a US college, and I've been assigned a programming project to complete on my own. I wrote a program to solve a somewhat complex problem, and I'd like to release it under an open-source license so that others can use it and learn from it. However, I'm not entirely sure to whom the code's copyright belongs. The class' syll...
I am inputting this text file into the command line:
800 5 10
800 1 8
800 7 7
810 2 9
845 2 10
850 1 3
first column is time,then priority,then length
the output is sorted by time plus the length, and the next item is outputted if the time of the item is less than or equal to the curren...
Hi
I need to write SCC algorithm in standard ML. but I don't know how to do that.
I have following TYPEs whitch has to be uesd in code:
type vertex = int
type edge = int * int
type graph = (vertex * vertex list) list
fun dfs (g: graph) (n: vertex): vertex list =
let
fun helper (todo: vertex list) (visited: vertex list): vertex ...
I am trying to solve this problem:
In an integer array all numbers occur exactly twice, except for a single number which occurs exactly once.
A simple solution is to sort the array and then test for non repetition. But I am looking for better solution that has time complexity of O(n).
...
Hi I was wondering that if you had an array of integers, how you would use sort it using selection sort in descending order. I know how to do it in ascending order but I don't know how to do in it descending order.
Thanks!
...
In 3D space, given P1 and P2, and two links attached end to end with lengths L1 and L2 respectively, link1 starts at P1. Write a function that finds the configurations of the links that put the 2nd link’s end at point P1. I dunno where to start... What exactly "link configuration" should be (as output): A vector (like 2i -3j+5k)? Or a...
So I am in a Java class in school, and I have a relatively simple assignment that I just can't figure out. It's not a problem to research the answer, so I am throwing it out to the brightest people out there. My simple java program takes 4 numbers as input, and then it is just supposed to spit those numbers right back out, but in order s...