I was given a task. Write an algorithm so that, the input of 2 lists of data, will have at least one in common.
So, this is my algorithm: (I write the code in php)
$arrayA = array('5', '6', '1', '2', '7');
$arrayB = array('9', '2', '1', '8', '3');
$arrayC = array();
foreach($arrayA as $val){
if(in_array($val, $arrayB)){
ar...
Please order the function belows by growth rate from fastest to slowest:
n^10
2^n
nlog(n)
10^6
And my answer is:
2^n
n^10
nlog(n)
10^6
Is my answer correct?
...
I'm sorry for deleting the original question, here it is:
We have a bag or an array of n integers, we need to find the product of each of the (n-1) subsets. e.g:
S = {1, 0, 3, 6}
ps[1] = 0*3*6 = 0;
ps[2] = 1*3*6 = 18; etc.
After discussions, we need to take care of the three cases and they are illustrated in the following:
1. S is a se...
So I am to loop through copyFrom.pixelData and copy it into pixelData.
I realize that I need to check the conditions of i and j, and have them not copy past the boundaries of pixelData[x][y],
I need another 2 loops for that? I tried this, but was getting segmentation fault..
Is this the right approach?
void Image::insert(int xoff, ...
Hello, I am doing some exercices to understand how the virtual memory and paging works, my question is as follows :
Suppose we use a paged memory with pages of 1024 bytes, the virtual address space is of 8 pages but the physical memory can only contain 4 frames of pages. Replacement policy is LRU.
What is the physical address in main ...
Hello everyone:
This is a CSS related question, I got one good answer from my previous question, which suggested the use of some CSS code like overflow:auto together with a fixed height container.
And here is my actual implementation : on uni server
If by any chance you cannot access that server, try this
Please follow the instructio...
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<iomanip>
using namespace std;
int main()
{
ifstream in_stream; // reads itemlist.txt
ofstream out_stream1; // writes in items.txt
ifstream in_stream2; // reads pricelist.txt
ofstream out_stream3;// writes in plist.txt
ifstream in_stream4;// read recipt.tx...
Could someone help me clarify the following conecpts, and the relationship among them?
Maskable interrupt
Unmaskable interrupt
Hardware interrupt
Software interrupt
CPU INTR pin
the IF bit of EFlags register
Some specific questions:
What's the relationship between Maskable/Unmaskable interrupt and Hardware/Software interrupt?
What'...
could someone also tell me if the actions i am attempting to do which are stated in the comments are correct or not. i am new at c++ and i think its correct but i have doubts
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<iomanip>
using namespace std;
int main()
{
ifstream in_stream; // reads itemlist.txt
ofstream out...
I haven't yet implemented this, I'm still in the thinking stage, but I have to go through a file and replace a certain string with another string. For example,
<img src="/images/logo.gif" ...
should become
<img src="/proxy/www.example.com/images/logo.gif" ...
Any advice on how I can approach this? Perhaps there exist some "string r...
I need some help in code to be able to handle the following logic.
The program gets many input in Integers like 10,16,3,17,21,29,6
Logic to be done :
scenario : 1
First select the biggest 4 numbers of input which is 16,17,21,29
Now assign the values to A,B,C and D
A = smallest in the selected 4
B = biggest in the selected 4
C = se...
I have a program that converts currency using a specific design pattern. I now need to take my converted result and using the decorator pattern allow the result to be converted to 3 different formats: 1 - exponential notation, rounded to 2 decimal points.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using...
This program is supposed to read files and write them. I took the file open checks out because they kept causing errors. The problem is that the files open like they are supposed to and the names are correct but nothing is on any of the text screens. Do you know what is wrong?
#include<iostream>
#include<fstream>
#include<cstdlib>
#incl...
int price=' '; // attempt to grab a decimal number - but not the correct way
int itemnum=' '; // attempt to grab a whole number - but not the right way
while((price== (price*1.00)) && (itemnum == (itemnum*1)))
What is a way to get numbers in 2 diff columns where one column is whole numbers and the other are numbers with decimal plac...
Given a date of birth, how would I go about calculating an age in C?
For example, if today's date is 20/04/2010 and the date of birth given is 12/08/86, then age will be 23 years, 8 months, and 8 days.
Any suggestions would be appreciated.
Thanks!
...
I have this function semi-working, but it seems that the image that comes out is overly-blurred. this is because it is processing already blurred portions, I imagine?
I was told I need to write it to a new image, but I can't figure out how to create that. When I was using the Image tempImage constructor, I was getting errors of segmenta...
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<iomanip>
using namespace std;
int main()
{
ifstream in_stream; // reads ITEMSLIST.txt
ofstream out_stream1; // writes in listWititems.txt
ifstream in_stream2; // reads PRICELIST.txt
ofstream out_stream3;// writes in listWitprices.txt
ifstream in_stream4;/...
i get errors when i try to open a file using the file path
out_stream5.open("C:pathshowitems.txt", ios::out);
warning C4129: 'o' : unrecognized character escape sequence
error C2100: illegal indirection
...
Hi,
I already solved most the questions posted here, all but the longest path one. I've read the Wikipedia article about longest paths and it seems any easy problem if the graph was acyclic, which mine is not.
How do I solve the problem then? Brute force, by checking all possible paths? How do I even begin to do that?
I know it's goin...
Hello all,
I am really stuck with these 2 question for over 2 days now. trying to figure out what the question means.... my tutor is out of town too....
write a regular expression for the only strings that are not generated over {a,b} by the expression: (a+b)*a(a+b)*. explain your reasoning.
and i tried the second question, do you thi...